[Rd] suggested modification to the 'mle' documentation?

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Fri Dec 7 14:10:22 CET 2007


Ben Bolker wrote:
>   At this point I'd just like to advertise the "bbmle" package
> (on CRAN) for those who respectfully disagree, as I do, with Peter over
> this issue.  I have added a data= argument to my version
> of the function that allows other variables to be passed
> to the objective function.  It seems to me that this is perfectly
> in line with the way that other modeling functions in R
> behave.
>   
This is at least cleaner than abusing the "fixed" argument. As you know,
I have reservations, one of which is that it is not a given that I want
it to behave just like other modeling functions, e.g. a likelihood
function might refer to more than one data set, and/or data that are not
structured in the traditional data frame format. The design needs more
thought than just adding arguments.

I still prefer a design based a plain likelihood function. Then we can
discuss how to construct such a function so that  the data are
incorporated in a flexible way.  There are many ways to do this, I've
shown one, here's another:

> f <- function(lambda) -sum(dpois(x, lambda, log=T))
> d <- data.frame(x=rpois(10000, 12.34))
> environment(f)<-evalq(environment(),d)
> mle(f, start=list(lambda=10))

Call:
mle(minuslogl = f, start = list(lambda = 10))

Coefficients:
 lambda
12.3402

It is not at all an unlikely design to have mle() as a generic function
which works on many kinds of objects, the default method being
function(object,...) mle(minuslogl(obj)) and minuslogl is an extractor
function returning (tada!) the negative log likelihood function.
>   (My version also has a cool formula interface and other
> bells and whistles, and I would love to get feedback from other
> useRs about it.)
>
>    cheers
>     Ben Bolker
>
>   


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-devel mailing list