[R-sig-ME] R^2 for lme
Douglas Bates
bates at stat.wisc.edu
Mon Apr 6 20:46:30 CEST 2009
2009/4/6 Balázs Lestár <ebszolocsucsor at freemail.hu>:
> Dear All,
> Can anybody tell me how to get the R^2 and adjusted R^2 for an lme object?
> I found a formula, but when I checked it with an lm function, it didn't return the same result like summary(lm.model)$ r.squared.
> l.B <- logLik (lme.model)
> l.0 <- logLik ( lme ( y~ 1, random= ~1| a / b ) )
> Rsq <- 1 - exp( - ( 2 / length(y ) * (l.B - l.0) ) )
> Is there any packages that can help me?
Well, first you have to define what you mean by R^2.
The simplest way to consider R^2 is as the complement of the residual
sum of squares of the fitted model to the residual sum of squares for
the trivial model.
The residual sum of squares for the trivial model can be evaluated as
deviance(lm(y ~ 1)). See the enclosed script for an example.
More information about the R-sig-mixed-models
mailing list