BookmarkSubscribeRSS Feed
bennett
Calcite | Level 5

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!

5 REPLIES 5
SteveDenham
Jade | Level 19

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

bennett
Calcite | Level 5

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: 

Johnson 2014:  http://onlinelibrary.wiley.com/doi/10.1111/2041-210X.12225/epdf

Johnson 2014 R code:  http://onlinelibrary.wiley.com/store/10.1111/2041-210X.12225/asset/supinfo/mee312225-sup-0001-RScrip...

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...

SteveDenham
Jade | Level 19

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

Emiliefranck1
Calcite | Level 5

Dear Steve,

 

I have read this post as I am also interested in creating this R2 measure. I want to use the PROC GLIMMIX option so I can use two weight variables at each level of my model (students nested within schools).

The goal would be to create a conditional R2. The Varcorrs are the paramters in the Covparm table (intercept) as I only will run a random intercept model. The residual error variance can also be found in that table if i am not mistaken. 

I am just unsure how to compute the VarF as mentioned in your post. Could you elaborate on this?

Many thanks in advance,

 

Kind regards,


Emilie Franck

Emiliefranck1
Calcite | Level 5

Dear all,

 

Does anyone knows or is able to elaborate on my previous question. 

I am rather new to SAS and I do not seem to find it.

 

Many thanks in advance,

 

Kind regards,

 

Emilie Franck

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 3185 views
  • 0 likes
  • 3 in conversation