[R] Extract random effect variances from lmer (lme4) model
    GMAIL 
    rosita21 at gmail.com
       
    Mon Dec  8 22:15:57 CET 2014
    
    
  
I have a mer object that has fixed and random effects (lmer). 
How do I extract the variance or standard deviation estimates for the random and fixed effects? Here is a simplified version of my question:
pcrpred <- lmer(PCR ~ (1|TIME) + (1|ID), data = mydataPCRlong)
pcrpred
This gives a long output - not too long in this case. Anyway, how do I explicitly select the variance? I can I extract part of the output? I want the values themselves.
> pcrpred
Linear mixed model fit by REML ['merModLmerTest']
Formula: PCR ~ (1 | TIME) + (1 | ID)
   Data: mydataPCRlong
REML criterion at convergence: 127761.9
Random effects:
 Groups   Name        Std.Dev.
 ID       (Intercept) 22031   
 TIME     (Intercept) 15182   
 Residual             33635   
Number of obs: 5346, groups:  ID, 891; TIME, 6
Fixed Effects:
(Intercept)  
      26791  
I also tried: 
summary(pcrpred)
Linear mixed model fit by REML t-tests use Satterthwaite approximations to degrees of
  freedom [merModLmerTest]
Formula: PCR ~ (1 | TIME) + (1 | ID)
   Data: mydataPCRlong
REML criterion at convergence: 127761.9
Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-2.6822 -0.5974 -0.2283  0.5681  2.8165 
Random effects:
 Groups   Name        Variance  Std.Dev.
 ID       (Intercept) 4.854e+08 22031   
 TIME     (Intercept) 2.305e+08 15182   
 Residual             1.131e+09 33635   
Number of obs: 5346, groups:  ID, 891; TIME, 6
Fixed effects:
             Estimate Std. Error        df t value Pr(>|t|)   
(Intercept) 26790.662   6258.611     5.142   4.281  0.00738 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> print(VarCorr(pcrpred),comp=c("Variance","Std.Dev."))
 Groups   Name        Variance   Std.Dev.
 ID       (Intercept)  485373501 22031   
 TIME     (Intercept)  230483110 15182   
 Residual             1131284840 33635 
When I do:
print(VarCorr(pcrpred),comp=c(“Variance”,”Std.Dev.”))
I get:
 Groups   Name        Variance   Std.Dev.
 ID       (Intercept)  485373501 22031   
 TIME     (Intercept)  230483110 15182   
 Residual             1131284840 33635 
And I searched in forums, but another command I found was: 
summary(pcrpred)@REmat
however I get:
Error: trying to get slot “REmat" from an object (class "summary.merMod") that is not an S4 object 
Can anyone 
I have taken long looks at
str(study)
and there's nothing there! Also checked any extractor functions in the lme4 package to no avail. Please help!
	[[alternative HTML version deleted]]
    
    
More information about the R-help
mailing list