Skip to content

Using optim with parameters that are factors (instead of continuous parameters)

2 messages · Lucas Merrill Brown, Ben Bolker

#
Lucas Merrill Brown <lucas.merrill.brown <at> gmail.com> writes:
optim() is not really set up for discrete programming. You have a few
options:

 * use method="SANN" (simulated annealing); you can specify a rule for
choosing a new candidate solution.
 * make the likelihood surface slightly continuous -- i.e. a steep
logistic function that is "almost" stepwise
 * probably most easily (if you only have a single discrete parameter)
is compute a profile likelihood along that parameter -- i.e. solve the
optimization problem for each value from 0 to 5, and compare the
results ...

 See pp. 25-27 of 
http://www.math.mcmaster.ca/~bolker/emdbook/chap7A.pdf

  More generally see

http://cran.r-project.org/web/views/Optimization.html , but I think
the profile likelihood is going to work best for you ...