Sorry for a possibly ignorant question.

I have fit a mixed-effects model using the lmer function from the lme4 package, and the main fixed effect (a factor with three levels) in the model was significant according to a run with pvals.fnc (from the languageR package).

To illustrate the effect in an appealing way, I would like to plot three bars with the "baseline condition" (the intercept including the effect level 1), the "experimental condition 1" (the intercept + the effect level 2), the "experimental condition 2" (intercept + effect level 3), and the corresponding confidence intervals for these conditions.

However, how do I do that? The function plotLMER.fnc used to do that, but has stopped working for me (lme4_0.999375-32; languageR_1.0).
Model: mylmer <- lmer(outcome ~ (1|subject) + (1|item) + Factor, data)

So I have MCMC output in the form of:

              Estimate MCMCmean HPD95lower HPD95upper  pMCMC Pr(>|t|)
(Intercept)     0.4728   0.4718     0.2250     0.7368 0.0010   0.0008
Factor2        -0.0420  -0.0420    -0.1732     0.0931 0.5414   0.5710
Factor3        -0.1643  -0.1631    -0.3153    -0.0112 0.0328   0.0508

My idea was to construct the conditions from this data by simply using the intercept as the baseline condition, and construct the experimental conditions by adding the effect of each factor level to the intercept. The new (intercept + effect combined) CI would be constructed by turning the HPD interval into a standard deviation and then use the square root of the sum of squared standard deviations (like here)

Is this approach appropriate? If I do it, the CIs become become fairly large and the effect no longer looks significant (conflicting with the pvals.fnc output).

Is there a better way (code example would be great)?

If not, is there a "least worst" solution that could satisfy readers who strongly request the standard bar plot with CIs?

Problems in the back of my head, which I am too ignorant to properly formulate:
CI not equal to HPD.
Transforming CI to SD is inappropriate, as CI may be asymmetric.
Problems with determining CI at all in mixed models (like here).

  • $\begingroup$ Thanks chl, the version number was a type (zeros were supposed to be nines), but your tip helped. plotLMER.fnc works again after the update. So, my immediate issues are solved. However, I think I'll leave the question here anyway (unless a mod thinks otherwise?) if anybody wants to discuss other ways of getting intervals outside of the plotLMER function. $\endgroup$
    – Richard
    Commented Dec 2, 2010 at 12:28
  • $\begingroup$ Your question makes perfect sense to me, if we make abstraction of the R issues. Someone may have a good idea about how to derive relevant CIs in your case without resorting to any software consideration. $\endgroup$
    – chl
    Commented Dec 2, 2010 at 14:08

2 Answers 2


The DRAFT r-sig-mixed-models FAQ details (in the "Predictions and/or confidence (or prediction) intervals on predictions" section) how to obtain predictions and confidence intervals for cells in the design of a mixed effects model. The ezPredict() function in the ez package wraps the code for the lme4 case (well, obtaining predictions and variances, leaving the user to decide their own CI).

  • $\begingroup$ Thanks! I tried the example on the FAQ and it provided a nice-looking plot. $\endgroup$
    – Richard
    Commented Dec 2, 2010 at 12:41

The info into the r-sig-mixed-models FAQ is a little outdated now, as there is two new packages, lmerTest, cran.r-project.org/web/packages/lmerTest//lmerTest.pdf, and lsmeans, cran.r-project.org/web/packages/lsmeans/lsmeans.pdf, that can calculate 95% confidence limits for lmer and glmer output, maybe you can look into those? And coefplot2, r-forge.r-project.org/projects/coefplot2, I think can do it too (though in a not so sophisticated way, from the standard errors on the Wald statistics, as opposed to Kenward-Roger and/or Satterthwaite df approximations used in lmerTest and lsmeans)... Just a shame that there are still no inbuilt plotting facilities in package lsmeans (as there are in package effects(), which btw also returns 95% confidence limits on lmer and glmer objects calculated by refitting a model without any of the random factors, which is evidently not correct).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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