[R] selection of optim parameters
Rubén Roa
rroa at azti.es
Tue Jul 6 08:31:41 CEST 2010
> -----Mensaje original-----
> De: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] En nombre de Fabian Gehring
> Enviado el: lunes, 05 de julio de 2010 21:53
> Para: r-help at r-project.org
> Asunto: [R] selection of optim parameters
>
> Hi all,
>
> I am trying to rebuild the results of a study using a
> different data set. I'm using about 450 observations. The
> code I've written seems to work well, but I have some
> troubles minimizing the negative of the LogLikelyhood
> function using 5 free parameters.
>
> As starting values I am using the result of the paper I am rebuiling.
> The system.time of the calculation of the function is about 0.65 sec.
> Since the free parameters should be within some boundaries I
> am using the following command:
>
> optim(fn=calculateLogLikelyhood, c(0.4, 2, 0.4, 80000, 0.8),
> lower=c(0,0,0,0,0), upper=c(1, 5, Inf, Inf, 1), control=list(trace=1,
> maxit=1000))
>
> Unfortunately the result doesn't seem to be reasonable. 3 of
> the optimized parameters are on the boundaries.
1) Your parameters seem to vary over several orders of magnitude. The control argument has a parscale parameter that can be used to re-scale all parameters to the same order of magnitude. Alternatively, your could estimate the log of your parameters, say par=c(log(0.4), log(2), log(0.4), log(80000), log(0.8) (and equivalent changes in lower and upper), and in your function, instead of the parameter value, use exp(parameter value9. That way the _numerical optimization_ occurs in the log space whereas the _function evaluation_ occurs in the original space. This transformation approach would make your parameter estimates and their hessian matrix (in case you are interested in the hessian) be output in the transformed space, so estimates and their covariance matrix will have to be back-transformed. For estimates just use exp(), whereas for the covariance matrix you might have to use something like Taylor series.
2) Did you use "L-BFGS-B" in the method argument of optim()? This method admits box-constrained optimization whereas the default (which you seem to be using, Nelder-Mead) in unconstrained, as far as I know.
> Unfortunately I don't have much experience using
> optimizatzion methods.
> That's why I am asking you.
> Do you have any hints for me what should be taken into
> account when doing such an optimization.
>
> Is there a good way to implement the boundaries into the code
> (instead of doing it while optimizing)? I've read about
> parscale in the help-section. Unfortunately I don't really
> know how to use it. And anyways, could this help? What other
> points/controls should be taken into account?
About using parscale, see Ravi Varadhan's post "Re: optim() not finding optimal values" the 27th of June.
HTH
Rubén
____________________________________________________________________________________
Dr. Rubén Roa-Ureta
AZTI - Tecnalia / Marine Research Unit
Txatxarramendi Ugartea z/g
48395 Sukarrieta (Bizkaia)
SPAIN
More information about the R-help
mailing list