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

From: Christophe Pouzat <christophe.pouzat_at_univ-paris5.fr>
Date: Sat 23 Jul 2005 - 00:51:12 EST

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@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@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Sat Jul 23 00:58:45 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:55 EST