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 ______________________________________________ R-help@r-project.org mailing list 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.