Search code examples
rmixed-modelsvariance

How to infer the variation explained by a mixed model from R output?


I have the following output from a mixed effects model. I want to talk about how much variation is explained by the model. Is the variance under random effects corresponding to residuals (note: here trial is the random effect) the variation explained? i.e. 58.6 % or is there another way to infer this

REML criterion at convergence: 71.9

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-1.82579 -0.59620  0.04897  0.62629  1.54639 

Random effects:
 Groups   Name        Variance Std.Dev.
 trial     (Intercept) 0.06008  0.2451  
 Residual              0.58633  0.7974  
Number of obs: 60, groups:  trial, 30

Fixed effects:
                        Estimate Std. Error      df t value Pr(>|t|)    
(Intercept)               1.5522     0.2684 12.6610  13.233  0.09888 
drugantho                 0.8871     0.1753 14.0000   1.043  0.31601    
interventionadded         0.2513     0.2553 14.0000  -1.276  0.32436 **   
sexmale                   3.0026     0.6466 15.0000   4.066  0.00021  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Solution

  • No, the Residual variance is the exactly the variance of the residual random errors, i.e. the unexplained variance.

    As far as I know, there isn't a single, unanimously accepted way of computing a coefficient of determination for mixed-effects model analogous to (and with all the properties of) the R^2 of the simpler linear model case. The reasons are discussed here, where it is also provided a simple/crude recipe for estimating the fraction of variance explained by the model

    r2.corr.mer <- function(m) {
       lmfit <-  lm(model.response(model.frame(m)) ~ fitted(m))
       summary(lmfit)$r.squared
    }