Extract random effect variances from lme4 mer model object

后端 未结 6 1531

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:41

    Try

    attributes(study)
    

    As an example:

    > women
       height weight
    1      58    115
    2      59    117
    3      60    120
    4      61    123
    5      62    126
    6      63    129
    7      64    132
    8      65    135
    9      66    139
    10     67    142
    11     68    146
    12     69    150
    13     70    154
    14     71    159
    15     72    164
    
    > lm1 <- lm(height ~ weight, data=women)
    > attributes(lm1)
    $names
     [1] "coefficients"  "residuals"     "effects"       "rank"         
     [5] "fitted.values" "assign"        "qr"            "df.residual"  
     [9] "xlevels"       "call"          "terms"         "model"        
    
    $class
    [1] "lm"
    
    > lm1$coefficients
    (Intercept)      weight 
     25.7234557   0.2872492 
    
    > lm1$coefficients[[1]]
    
    [1] 25.72346
    
    
    > lm1$coefficients[[2]]
    
    [1] 0.2872492
    

    The end.

提交回复
热议问题