From tlumley at u.washington.edu  Tue Apr 26 17:57:29 2005
From: tlumley at u.washington.edu (Thomas Lumley)
Date: Tue Apr 26 17:57:39 2005
Subject: [Rd] "wild" function example in optim
In-Reply-To: <20050426154749.33905.qmail@web61201.mail.yahoo.com>
References: <20050426154749.33905.qmail@web61201.mail.yahoo.com>
Message-ID: <Pine.A41.4.61b.0504260851450.131934@homer03.u.washington.edu>

On Tue, 26 Apr 2005, Werner Bier wrote:

> Dear all,
>
> Firstly, I do apologize if my question is simple and posted in the wrong 
> place but I had no reply from the R-help mailing list (maybe it is too 
> simple!).
>
> I was wondering why parscale is set to 20 in the "wild" function example 
> used in ?optim. This function has only one parameter and if we set 
> parscale equal to 1 then the solution near the global minimum is not 
> found.
>
> I would use parscale only in cases the object function has more than one 
> parameter to be optimised, shouldn't I?
>

parscale is more important in cases with more than one parameter 
(and with one parameter you could set fnscale instead of parscale to get 
the same effect)

However, a sufficiently badly scaled one-d problem can still benefit from 
fnscale or parscale.
> f
function(x) 1e-10*x^2
> g
function(x) 2e-10*x
> optim(7,f,g,method="CG")$par
[1] 7
> optim(7,f,g,method="CG",control=list(parscale=1e5))$par
[1] 1.209735e-14
> optim(7,f,g,method="CG",control=list(fnscale=1e-10))$par
[1] 1.673141e-15

 	-thomas


 	-thomas


[Rd] "wild" function example in optim
Thomas Lumley