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.

| cite | improve this answer | |
  • $\begingroup$ This is exactly what I want to do :) Now to make it work! $\endgroup$ – fmark Jun 23 '12 at 8:09
  • $\begingroup$ @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. $\endgroup$ – NRH Jun 24 '12 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:


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:

| cite | improve this answer | |
  • $\begingroup$ 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. $\endgroup$ – Stéphane Laurent Jun 22 '12 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.