[R] profile mle in stats4 with ndeps option for optim

Daniel Hoppe daniel.hoppe at univie.ac.at
Wed Aug 4 10:37:17 CEST 2004


When I use 

	fit <- mle(pnbd.ll, start=list(r=1,a=1,s=1,b=1), method="BFGS",
control=list(trace=traceLevel, REPORT=1, ndeps=c(1e-3,1e-3,5e-4,1e-3)))

and afterward profile(fit), the fit contains only NAs. This is due to
the fact, that optim still gets ndeps of original length while one
parameter has been excluded, so optim directly returns with an
(unreported) error message in line 87 of mle.r. For me, the hack 

diff mle.R mleorig2.r
<         if (!is.null(call$control$ndeps))
<         {
<               exclude <- which(names(call$start)==pi)
<               call$control$ndeps <- call$control$ndeps[-(exclude+1)]
<         }

works. I guess that the similar problem will occur for parscale. Beside
this I wonder if in this code snippet  (lines 87ff in mle.r)

        pfit <- try(eval(call), silent=TRUE)
        if(inherits(pfit, "try-error")) return(NA)
        else {

silent=TRUE has been set for any specific reason. In my experience with
programming in Java, it has nearly always turned out to be a bad choice,
not to report exceptions as debugging effort increases. Maybe there is a
global option I do not know of which can override silent=TRUE?

Best Regards,


More information about the R-help mailing list