[R] About object of class mle returned by user defined functions

Christophe Pouzat christophe.pouzat at univ-paris5.fr
Fri Jul 22 16:51:12 CEST 2005


Dear Prof Ripley,

Your solution:

Call <- quote(mle())
Call$minuslogl <- minusLogLikelihood
...

Works beautifully (and simply)!

Thanks a lot,

Christophe.

Prof Brian Ripley wrote:

> confint has to be able to re-fit the function to form the profile 
> likelihood.  The fit you return refers to values inside the function 
> you used, and those are not available in the environment you call 
> confint from.  You need to ensure that those values are substituted 
> and not referred to.
>
> Compare
>
>> fitA at call
>
> mle(minuslogl = llgamma, start = list(shape = (mean(isi1)/sd(isi1))^2,
>     scale = sd(isi1)^2/mean(isi1)), method = "L-BFGS-B", lower = c(1e-05,
>     1e-05))
>
>> fit1 at call
>
> mle(minuslogl = minusLogLikelihood, start = initial.para, method = 
> "L-BFGS-B",
>     lower = optim.lower, upper = optim.upper)
>
> and the difference should be clear.
>
> You can fix this up by constructing a call containing the values and 
> not the names (one way is to use substitute()) and then eval() it.  
> Another way is something like
>
> Call <- quote(mle())
> Call$minuslogl <- minusLogLikelihood
> Call$start <- initial.para
> ...



-- 
A Master Carpenter has many tools and is expert with most of them.If you
only know how to use a hammer, every problem starts to look like a nail.
Stay away from that trap.
Richard B Johnson.
--

Christophe Pouzat
Laboratoire de Physiologie Cerebrale
CNRS UMR 8118
UFR biomedicale de l'Universite Paris V
45, rue des Saints Peres
75006 PARIS
France

tel: +33 (0)1 42 86 38 28
fax: +33 (0)1 42 86 38 30
web: www.biomedicale.univ-paris5.fr/physcerv/C_Pouzat.html




More information about the R-help mailing list