Solved – Confidence-intervals for conditions tested with a mixed-effects model

confidence intervalmixed modelr

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:

$fixed
              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).

Best Answer

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).