[R] question on "optim"

nashjc at uottawa.ca nashjc at uottawa.ca
Wed Sep 8 18:51:22 CEST 2010


Ben and Ravi have already pointed out that you have a problem with a
non-computable (e.g., divide by zero or similar) objective function. This
is common.

optim() has mostly unconstrained optimizers. L-BFGS-B does handle box or
bounds constraints. There is also Rvmmin, which is supposedly the same
algorithm as optim's BFGS (I'm the author, but not the implementor of
optim). However, Rvmmin has bounds constraints, so you could constrain the
parameter going to zero to be > .1 or something like that. You don't want
to use a bound that would cause the computational failure, because the
numerical gradient routine takes a step, essentially walking off the
cliff.

If you have analytic gradients, you can do much better usually.

Note that bounds in Nelder-Mead are fairly awkward to use, and our codes
are not very good for that.

You might also try bobyqa from the minqa package, but be warned that it is
an F1 race car relative to the Chevy of Rvmmin. Very good when set up
right, but sometimes tricky to set up.

John Nash


> Message: 33
> Date: Tue, 7 Sep 2010 07:38:55 -0700 (PDT)
> From: Hey Sky <heyskywalker at yahoo.com>
> To: R <r-help at r-project.org>
> Subject: [R] question on "optim"
> Message-ID: <741050.53212.qm at web113920.mail.gq1.yahoo.com>
> Content-Type: text/plain; charset=iso-8859-1
>
> Hey, R users
>
> I do not know how to describe my question. I am a new user for R and write
> the
> following?code for a dynamic labor economics?model and use OPTIM to get
> optimizations and parameter values. the following code does not work due
> to
> the?equation:
>
> ?? wden[,i]<-dnorm((1-regw[,i])/w[5])/w[5]
>
> where w[5]?is one of the parameters (together with vector a, b and other
> elements in vector w)?need to be estimated. if I delete the w[5] from the
> upper
> equation. that is:
>
> ?wden[,i]<-dnorm(1-regw[,i])
>
> optim will give me the estimated parameters. but the paramter w[5] is a
> key one
> for me.
>
>
> now my questions is: what reason lead to the first?equation does not work
> and
> the way to correct it to make it work?
>
> ?I wish I made the queston clear and thanks for any suggestion.
>
> Nan
> from Montreal
>



More information about the R-help mailing list