[R] numerical differentiation in R? (for optim "SANN" parscale)
Roger D. Peng
rpeng at stat.ucla.edu
Wed Jul 16 18:23:29 CEST 2003
'optim' does not require any differentiation of the objective function
for the "SANN" method. For the other four methods 'optim' will do
numerical differentiation for you if a gradient is not provided.
Furthermore, the 'parscale' argument has nothing to do with
differentiation. As far as I know, it is used to scale the values of
the parameters before choosing candidates (so that they are roughly
comparable).
-roger
BORGULYA Gábor wrote:
> Dear R users,
>
> I am running a maximum likelihood model with optim. I chose the
> simulated annealing method (method="SANN").
>
> SANN is not performing bad, but I guess it would be much more effecive
> if I could set the `parscale' parameter.
>
> The help sais:
> `parscale' A vector of scaling values for the parameters.
> Optimization is performed on `par/parscale' and these should
> be comparable in the sense that a unit change in any element
> produces about a unit change in the scaled value.
>
> Since I know the approximate optimal parameters of the function to
> optimise I could use these values to calculate `parscale'.
> If I understand the role of `parscale' well, I have to differentiate
> my function numerically.
>
> How can I perform the numerical differentiation in R? I thought about
> writing a small function, but I am sure it is already written. It must
> be present at least in some of the optimisation algorithms.
> Anyway, I couln't find it neither in the help, nor in the
> non-internal, displayable source of optim.
>
> Could anyone tell me where to find such a function?
> And if it really is what I need for `parscale'?
>
> Thank you!
>
> Gábor
More information about the R-help
mailing list