New Contributor
Posts: 2

# Calculate R2 for mixed models: Nakagawa and Schielzeth method?

Is it possible in any of the mixed model programs to calculate an R2 using the recently published Nakagawa and Schielzeth 2013 (Methods in Ecology and Evolution) formula?  I have a very large mixed model, and I'd rather not calculate it by hand...  Thanks!

Posts: 2,655

## Re: Calculate R2 for mixed models: Nakagawa and Schielzeth method?

Could you provide the formula?  We can probably figure out the correct ODS files to get what is needed, and it is then just a DATA step program.

Steve Denham

New Contributor
Posts: 2

## Re: Calculate R2 for mixed models: Nakagawa and Schielzeth method?

Apologies for my delayed reply!  I replied to the email, but I don't think you received it?  My email is below:

Steve,

Excellent!!  You have made my day!  I can actually do you one better and provide the papers which give the complete formulations (and their derivations).  The Nakagawa and Schielzeth paper is attached as well as the update by Johnson which applies to random slopes as well as random intercept models.  Both papers also provide R code (which I have also attached) if that helps as well.

My ultimate goal is to calculate the variation explained by the some of the fixed effects in my model, and the r2 is the first step.

Thank you!!!

Alison

P.S. I couldn't attach any files so here are the weblinks:

Nakagawa & Schielzeth 2013:  http://onlinelibrary.wiley.com/doi/10.1111/j.2041-210x.2012.00261.x/epdf

Nakagawa & Schielzeth 2013 R code:  http://onlinelibrary.wiley.com/store/10.1111/j.2041-210x.2012.00261.x/asset/supinfo/mee3261-sup-0004...

Posts: 2,655

## Re: Calculate R2 for mixed models: Nakagawa and Schielzeth method?

It looks like what is needed are several runs to get what is needed.  I have tried to match the R objects in the Nakagawa&Schielzeth R code paper to what I think you need from SAS output:

VarF: Residual error from a fixed effects only design

the various VarCorr estimates are obtained as the variance components of the random effects.

Marginal Rsq is then VarF/Sum (VarF + all VarCorrs  + residual error variance)

Conditional Rsq is Sum(VarF + all VarCorrs)/Sum ( VarF + all VarCorrs  + residual error variance)

You can get all of these using ODS output.  The table name is CovParms.in all of the mixed model procedures I am familiar with.

The only drawback I see to this approach is that I would have a hard time extending this beyond a simple variance component approach.  Once structured covariances enter the picture, the various components are not necessarily strictly additive--any correlation type parameters would mean that there is some sort of shrinkage not necessarily correctly accounted for, so that these Rsq values would be inflated.

Steve Denham

Discussion stats
• 3 replies
• 482 views
• 0 likes
• 2 in conversation