Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get coefficients and their confidence intervals in mixed effects models?

In lm and glm models, I use functions coef and confint to achieve the goal:

m = lm(resp ~ 0 + var1 + var1:var2) # var1 categorical, var2 continuous coef(m) confint(m) 

Now I added random effect to the model - used mixed effects models using lmer function from lme4 package. But then, functions coef and confint do not work any more for me!

> mix1 = lmer(resp ~ 0 + var1 + var1:var2 + (1|var3))                                        # var1, var3 categorical, var2 continuous > coef(mix1) Error in coef(mix1) : unable to align random and fixed effects > confint(mix1) Error: $ operator not defined for this S4 class 

I tried to google and use docs but with no result. Please point me in the right direction.

EDIT: I was also thinking whether this question fits more to https://stats.stackexchange.com/ but I consider it more technical than statistical, so I concluded it fits best here (SO)... what do you think?

like image 628
Tomas Avatar asked Jun 17 '12 15:06

Tomas


People also ask

How do you find the 95 confidence interval for the regression coefficient?

CIβi0.95=[^βi−1.96×SE(^βi),^βi+1.96×SE(^βi) CI 0.95 β i = [ β ^ i − 1.96 × S E ( β ^ i ) , β ^ i + 1.96 × S E ( β ^ i ) ] . Equivalently, this interval can be seen as the set of null hypotheses for which a 5% two-sided hypothesis test does not reject.

What are the confidence intervals of the coefficients?

The coefficient confidence intervals provide a measure of precision for linear regression coefficient estimates. A 100(1–α)% confidence interval gives the range that the corresponding regression coefficient will be in with 100(1–α)% confidence.


1 Answers

Not sure when it was added, but now confint() is implemented in lme4. For example the following example works:

library(lme4) m = lmer(Reaction ~ Days + (Days | Subject), sleepstudy) confint(m) 
like image 101
jciloa Avatar answered Sep 28 '22 03:09

jciloa