[R] constrainOptim

Ben Bolker bolker at ufl.edu
Wed Jan 28 19:54:27 CET 2009

June Wong <neptune545 <at> hotmail.com> writes:

> Dear R helpers
> I have a question regarding the constrainOptim. 
> I'm coding the nested logit and would like to set a bound of rho to (0,1] as
an extreme value distribution
> where rho = exp(lambda)/1+exp(lambda)
> I wonder if I can do that directly in optim (say rho > 0 & <= 1) or need to
use constrainOptim
> I read the help but still don't know how to set ui and ci
> Thanks,
> June

  optim() can do box constraints (i.e., independent inequality
constraints on parameters): use method="L-BFGS-B" and
the lower and upper arguments to set the bounds for
each parameter (to -Inf and Inf if there are no bounds).
If you want to set bounds on rho you have to use rho as
the parameter in your model -- this is tricky if you
can't solve for rho, but in your case lambda=log(rho/(1-rho))

  Ben Bolker

More information about the R-help mailing list