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

前端 未结 6 937
無奈伤痛
無奈伤痛 2020-12-04 10:52

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

m = lm(resp ~ 0 + var1 + var1         


        
6条回答
  •  天命终不由人
    2020-12-04 11:32

    Assuming a normal approximation for the fixed effects (which confint would also have done), we can obtain 95% confidence intervals by

    estimate + 1.96*standard error.

    The following does not apply to the variance components/random effects.

    library("lme4")
    mylm <- lmer(Reaction ~ Days + (Days|Subject),  data =sleepstudy)
    
    # standard error of coefficient
    
    days_se <- sqrt(diag(vcov(mylm)))[2]
    
    # estimated coefficient
    
    days_coef <- fixef(mylm)[2]
    
    upperCI <-  days_coef + 1.96*days_se
    lowerCI <-  days_coef  - 1.96*days_se
    

提交回复
热议问题