Subject: Re: [R] optim function
Date: Fri, 13 Jul 2018 17:06:56 -0400
From: J C Nash <profjcn...@gmail.com>
To: Federico Becerra <fbece...@mdp.edu.ar>

Though I wrote the original codes for 3 of the 5 solvers in optim(), I now 
suggest using more recent ones, some
of which I have packaged. optimx on R-forge (not the one on CRAN yet) has 
optimr() function that has same
syntax as optim but more options. See 
https://r-forge.r-project.org/projects/optimizer/.

You need an objective function  myobj(parameters, other_data) that is smaller 
the better the model fit.

Then solution <- optimr(startparameters, myobj, method="chosen-method")

will try to optimize. If you can supply a gradient function, then you will 
usually do much better.

My book, Nonlinear Parameter Optimization Using R Tools (2014) gives quite a 
few examples, but doesn't
have the optimr() function -- it's more recent.

And do -- repeat do -- check your function VERY carefully. It is worth it. If 
the objective is in any
way wrong, badly scaled, etc. you WILL get into trouble.

John Nash




On 2018-07-13 02:43 PM, Federico Becerra wrote:
> Good afternoon,
> 
> I am a Biology researcher working on Functional Morphology and Behaviour in 
> mammals. Nowadays, I have a series of
> morphological data that I would like to test against different models for 
> which I would need to optimize them -namely,
> "randomly manipulating" all models parameters in order to find the model that 
> fit best upon my data.
> 
> I've been told that the function "optim" is THE function for me, but I've 
> been having problems to program it and set all
> constraints.
> 
> Is there anything you could help me (guide me) with? I've asked already 
> several "experts" in the internet but noone gave
> me a real solution.
> 
> Thanks a lot, have a nice day,
> Federico
>

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to