Extract random effect variances from lme4 mer model object

后端 未结 6 1410

I have a mer object that has fixed and random effects. How do I extract the variance estimates for the random effects? Here is a simplified version of my question.

6条回答
  •  有刺的猬
    2020-12-24 01:51

    This answer is heavily based on that on @Ben Bolker's, but if people are new to this and want the values themselves, instead of just a printout of the values (as OP seems to have wanted), then you can extract the values as follows:

    Convert the VarCorr object to a data frame.

    re_dat = as.data.frame(VarCorr(study))
    

    Then access each individual value:

    int_vcov = re_dat[1,'vcov']
    resid_vcov = re_dat[2,'vcov']
    

    With this method (specifying rows and columns in the date frame you created) you can access whichever values you'd like.

提交回复
热议问题