[R-sig-ME] Coefficient of determination (R^2) when using lme()

Douglas Bates bates at stat.wisc.edu
Tue Apr 1 18:10:00 CEST 2008


That's going to break in the next version of R (due out later this month).

Use

 lmer.object at y

not

 attr(lmer.object, "y")

Slots in S4 classed objects were initially implemented as attributes
but they are not attributes.

In general, if you want to determine the structure of an object, use
the str() function.  It's even better to use the appropriate extractor
functions as the value of the extractor function should be consistent
across versions of the package but the structure of the object changes
between versions.  The appropriate extractor in this case is

model.response(lmer.object)


On Tue, Apr 1, 2008 at 9:40 AM, Jarrett Byrnes <jebyrnes at ucdavis.edu> wrote:
> This came up with a reviewer when I was using glms as well. I've
>  become fond of using the R^2 of the correlation between the fitted and
>  observed values.  It's easily interpretable by a general audience.
>
>  r2.corr.lmer<-function(lmer.object){
>          summary(lm(attr(lmer.object, "y") ~ fitted (lmer.object)))
>  $r.squared}
>
>
>
>
>  On Apr 1, 2008, at 3:37 AM, MHH Stevens wrote:
>
>  > Hi R.S.,
>  > This quantity is not clearly defined for mixed models --- should it
>  > include that which is "explained" by the random effects? What would
>  > it mean to "explain" a response with a variance? In any event, try
>  > searching R-help lists for Coefficient of determination AND lme.
>  > Cheers,
>  > Hank
>  > On Apr 1, 2008, at 6:17 AM, R.S. Cotter wrote:
>  >> Dear mixed models users,
>  >>
>  >> I have recently started using R, and I have learned to use lme ().
>  >>
>  >> Is it possible to interpret coefficient of determination (R^2) when
>  >> using lme ()?
>  >>
>  >>
>  >> Best Regards
>  >>
>  >> R.S. Cotter
>  >>
>  >> _______________________________________________
>  >> R-sig-mixed-models at r-project.org mailing list
>  >> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>  >
>  > Dr. Hank Stevens, Assistant Professor
>  > 338 Pearson Hall
>  > Botany Department
>  > Miami University
>  > Oxford, OH 45056
>  >
>  > Office: (513) 529-4206
>  > Lab: (513) 529-4262
>  > FAX: (513) 529-4243
>  > http://www.cas.muohio.edu/~stevenmh/
>  > http://www.cas.muohio.edu/ecology
>  > http://www.muohio.edu/botany/
>  >
>  > "If the stars should appear one night in a thousand years, how would
>  > men
>  > believe and adore." -Ralph Waldo Emerson, writer and philosopher
>  > (1803-1882)
>  >
>  > _______________________________________________
>  > R-sig-mixed-models at r-project.org mailing list
>  > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>  _______________________________________________
>  R-sig-mixed-models at r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>




More information about the R-sig-mixed-models mailing list