Re: [Rd] Problem with mle in stats4 (R 1.9.1)

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Tue 14 Sep 2004 - 09:13:49 EST

Peter Dalgaard <p.dalgaard@biostat.ku.dk> writes:

> > (original posting with quick workaround
> > http://tolstoy.newcastle.edu.au/R/help/04/07/1778.html)
>
> Could well be fix, not just workaround.... Given that optim wasn't
> designed to be able to hold arguments constant, any fix is going to be
> somewhat kludgy.

Had another look and your workaround turned out to be a bit too kludgy. This seems to work (the eval() is important):

        if (!is.null(call$control$ndeps))
           call$control$ndeps <- eval(call$control$ndeps)[-i]
        if (!is.null(call$control$parscale))
           call$control$parscale <- eval(call$control$parscale)[-i]

and a bit further down, I think you need to move the assignment to "call" inside the "for (i in which)" loop, so that the changes don't accumulate.

Leaves one issue, namely *where* to eval, and the above code is not quite right (you might capture a local variable of profile.mle, and if you called mle from a function, references to local variables inside that function can not be passed). Then again it actually never was right since the try(eval(call),....) call has the same issue. We really ought to save the environment of the original call to mle to be safe. How best to do that is a bit unclear to me. Could add a slot of just set the environment of the call (but that seems not to be documented to work...).

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

______________________________________________
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue Sep 14 09:18:33 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:15 EST