[R] Help MLE

Ben Bolker bolker at ufl.edu
Fri Oct 10 20:37:41 CEST 2008


LFRC <feliperiehs <at> yahoo.com.br> writes:

> 
> 
> Dear Ben Bolker,
> 
> Thanks a lot for your help.
> 
> I have two more questions:
> 
> 1) My goal is maximize the function (>     r = Y*log(comb)) but the
> parameters found, minimized the function (r = Y*log(comb)).
> 

  Oh.  Oops.  Just change the sign ( r = -Y*log(comb)) or
set fnscale=-1 (see ?optim) 

> 2) What this function do?
>   > model2 <- function(p) {
>   >   do.call("Model",as.list(p))
>   > }
> 
 
  I got a little carried away, this is R Magic.
mle() expects the function to be written out with
a list of parameters ( func(param1,param2,param3) ),
while optim and constrOptim want the function to
have a single vector argument ( func(paramvec) ).
model2() is a wrapper that converts a vector p
into a list and passes it to the Model function.

  Ben Bolker



More information about the R-help mailing list