Bug 14646 - confint.mle fault with fixed parameters of the likelihood function
confint.mle fault with fixed parameters of the likelihood function
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: S4methods
R 2.13.1
ix86 (32-bit) Windows 32-bit
: P5 enhancement
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-04 08:34 UTC by Jinsong Zhao
Modified: 2011-08-08 16:38 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jinsong Zhao 2011-08-04 08:34:28 UTC
Hi there,

confint.mle will trigger a error message when some parameters of the likelihood function were fixed:

Profiling...
Error in approx(sp$y, sp$x, xout = cutoff) : 
  need at least two non-NA values to interpolate

I searched the mailing list archive, and find that: About one year ago, Arnaud Le Rouzic <lerouzic_at_legs.cnrs-gif.fr> post a same question to R-help mailing list (http://tolstoy.newcastle.edu.au/R/e11/help/10/07/3271.html, Problem #1) The mini-example in the post is quoted here:

-----------8<--------------------------------
library(stats4)

minusLogL1 <- function(mu, logsigma2) { N*log(2*pi*exp(logsigma2))/2 + N*(var(x)+(mean(x)-mu)^2)/(2*exp(logsigma2)) } 

minusLogL2 <- function(mu) { logsigma2 <- 0; N*log(2*pi*exp(logsigma2))/2 + N*(var(x)+(mean(x)-mu)^2)/(2*exp(logsigma2)) }

N <- 100
x <- rnorm(N, 0, 1)

fit <- mle(minusLogL1, start=list(mu=0, logsigma2=0)) 
confint(fit)

fit2 <- mle(minusLogL1, start=list(mu=0), fixed=list(logsigma2=0))
 confint(fit2)

fit3 <- mle(minusLogL2, start=list(mu=0)) 
confint(fit3) 
----------->8-------------------------------- 

And about seven years ago,  Ben Bolker (bolker@zoo.ufl.edu) post a message to R-devel (http://tolstoy.newcastle.edu.au/R/devel/04a/1283.html). In that post, he suggested:

-----------8<--------------------------------
changed
call$fixed <- fix
to
call$fixed <- c(fix,eval(call$fixed))
for cases where there are non-trivial fixed arguments 
----------->8-------------------------------- 

After tested in R2.13.1, the above error disappeared. Thus, it may be the correct way to deal with this situation. However, why the patch was not accepted for seven years. Bug or feature?

Regards,
Jinsong
Comment 1 Brian Ripley 2011-08-08 16:38:49 UTC
Fixed in 2.13.1 patched (with a better patch)