Solved – R-squared of mixed model using lmmfit package

mixed modelr

I am fitting my data using nlme package. The syntax is as follow:

 model<-lme(Energy efficiency ~ADF + CP + DE, random =~1|Study, data=phuong).

Can someone tell me how to find the R-squared for this model?.

I've found the lmmfit package of Aleksandra Maj (2011): But there are several functions to estimate R-squared. Could you please tell me which one should I apply.

fm2<-lme(Eeff~ADF+CP+DE+ADF2+DE2, random=~1|Study,data=na.omit(binh))
summary(fm2)
Linear mixed-effects model fit by REML
 Data: na.omit(binh) 
       AIC      BIC    logLik
  888.6144 915.1201 -436.3072

Random effects:
 Formula: ~1 | Study
        (Intercept) Residual
StdDev:    3.304345 1.361858

Fixed effects: Eeff ~ ADF + CP + DE + ADF2 + DE2 
                Value Std.Error  DF   t-value p-value
(Intercept)  -0.66390 18.870908 158 -0.035181  0.9720
ADF           1.16693  0.424561 158  2.748556  0.0067
CP            0.25723  0.097524 158  2.637575  0.0092
DE          -36.09593 12.031791 158 -3.000046  0.0031
ADF2         -0.03708  0.011014 158 -3.366625  0.0010
DE2           4.77918  1.932924 158  2.472513  0.0145
 Correlation: 
     (Intr) ADF    CP     DE     ADF2  
ADF  -0.107                            
CP   -0.032  0.070                     
DE    0.978 -0.291 -0.043              
ADF2  0.058 -0.982 -0.045  0.250       
DE2  -0.978  0.308  0.039 -0.997 -0.265

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-2.28168116 -0.45260885  0.06528363  0.57071734  2.54144168 

Number of Observations: 209
Number of Groups: 46 

Best Answer

Maybe I am stating some obvious but at the following link http://glmm.wikidot.com/faq under the section How do I compute a coefficient of determination (R2), or an analogue, for (G)LMMs? provides a quite good treatment of the issue. Just to quote some of the final lines from there to avoid possible link rot and provide the reference they present:

The bottom line is that there are some simple recipes (and some more complex recipes that may or may not have been coded up by someone), but that '''you have to think carefully about what information you want to get out of the coefficient of determination''', because no recipe will have all of the properties of $R^2$ in the simple linear model case.

A rather helpful reference of the subject seems to be Xu's: Measuring explained variation in linear mixed effects models (2003) where the author computes the residual variance of the full model against the residual variance of a (fixed) intercept-only null model (in R syntax): 1-var(residuals(m))/(var(model.response(model.frame(m)))

Related Question