[R] maximum likelihood with constraints in R
Ben Bolker
bolker at ufl.edu
Wed Oct 1 15:25:02 CEST 2008
Plat, H.J. <H.J.Plat <at> uva.nl> writes:
> There is lots of information about maximum likelihood estimation in R.
> However, I didn't came across anything about maximum likelihood
> with constraints.
> For example, estimation of parameters k(1) to k(20) with
> maximum likelihood, where sum(k(i)) = 0.
If the individual parameters don't need to be constrained,
then this is easy to do by estimating parameters k(1) to k(19)
and setting k(20) to -sum_{i=1}^19 k(i). e.g. something like
objfun <- function(k) { ## k is a vector parameters 1 to 19
kvec <- c(k,-sum(k))
### ... compute and return negative log-likelihood based on kvec ...
}
optim(fn=objfun,par=[starting values])
If you need "box constraints" (individual parameters independently
bounded above and below) you can use method="L-BFGS-B" in optim.
Ben Bolker
More information about the R-help
mailing list