How can I estimate 95% confidence intervals using profiling for parameters estimated by maximising a log-likelihood function using optim in R?

How can I estimate 95% confidence intervals using profiling for parameters estimated by maximising a log-likelihood function using optim in R?

I know I can asymptotically estimate the covariance matrix by inverting the hessian, but I am concerned that my data do not meet the assumptions required for this method to be valid. I'd prefer to estimate confidence intervals using some other method.

Is the profile likelihood method appropriate, as discussed in Stryhn and Christensen, and in Venables and Ripley's MASS book, §8.4, pp. 220-221?

If so, are there any packages that can help me do this in R? If not, what would the pseudo code for such a method look like?

The mle function from the stats4 package is a wrapper of optim, which makes it quite easy to produce profile likelihood computations. See help("profile,mle-method", package = "stats4") for more information.

• This is exactly what I want to do :) Now to make it work! Commented Jun 23, 2012 at 8:09
• @fmark, how easy it is to make it work correctly depends on the optimization problem. I use it a lot for teaching with fairly simple problems (one to three parameters) and "nice" models and for simple practical problems. However, if the likelihood is challenging to optimize and profile, it will probably not work out of the box.
– NRH
Commented Jun 24, 2012 at 20:34

There is the ProfileLikelihood package if you use nlme. Personally, I have not managed to use it.

Using the lme4a or lmeEigen package there is a profile() function which exactly aims to do what you want. Try something like that to install these packages:

install.packages("lme4a",repos="http://lme4.r-forge.r-project.org/repos")


or go to the website to get the zip archive. Similarly and unfortunately, I have not managed to use it :) Maybe we should wait for an update of lme4.

The method is detailed in the draft of Douglas Bates' book

EDIT: Cool ! The profile() function for lmer models is now available in the latest version of lme4, to be installed by typing:

install.packages("lme4",repos="http://r-forge.r-project.org")

• I realize I had not read the original question precisely enough. My answer is for the case of mixed models. I think NRH's answer below is for the case of classical models. Commented Jun 22, 2012 at 9:43