[R-sig-ME] stuck with maximum likelihood problem

Ben Bolker bbolker at gmail.com
Sat Aug 14 19:01:41 CEST 2010


> Here is my situation in a simple description:
>
> I have an equation that has one parameter and 3 data variables.  I need to
> get R to determine the parameter value that maximizes the sum calculated
> from the equation.
>
> I know this is simple problem but my search into functions of R got me
> confused.  I think I should use the optim function but I also read about the
> trust function.  I found some very useful examples for the optim function
> but they related to specific distributions (i.e. normal, poisson)
>

  Your question is pretty vague ...

  Suppose you define a function  objfun() that takes the parameter as
its first argument (for simplicity, let's say that it just uses the
values of the
data drawn from the global workspace) so that objfun(p) returns the value
you are trying to maximize.

  Then

  optim(startval,fn=objfun,control=list(fnscale=-1))

  should find the value of the parameter that maximizes the function
(by default optim() does minimization: the fnscale=-1 option makes
it do maximization instead




More information about the R-sig-mixed-models mailing list