1
$\begingroup$

Is there a way to get the proportion of variance explained by individual fixed effects in a mixed effects model?

I thought that the partR2 package could do this, but it doesn't seem to work for fixed effects with random slopes. See below:

library(lme4)
library(partR2)
mod <- lmer(Sepal.Length ~ Sepal.Width + Petal.Length + (1 + Sepal.Width|Species), data = iris)
R2 <- partR2(mod, partvars = "Sepal.Width", data = iris,
             R2_type = "marginal", nboot = 10)


Error in .f(.x[[i]], ...) : partR2 can't calculate part R2
                 for fixed effects involved in random slopes

Is there another way to get the amount of variance explained by individual fixed effects in a mixed effects model?

$\endgroup$
3
  • 1
    $\begingroup$ Do you have an orthogonal design? Else, I don't think this can be done. $\endgroup$ Jan 14 at 20:11
  • $\begingroup$ Yep, my actual data has two orthogonal predictors. $\endgroup$
    – Dave
    Jan 14 at 20:16
  • $\begingroup$ you can use this "glmm.hp"package in R cran cran.r-project.org/web/packages/glmm.hp/index.html glmm.hp(output of lme4 or nlmm) $\endgroup$ Apr 3 at 3:00

1 Answer 1

1
$\begingroup$

The answers at Proportion of explained variance in a mixed-effects model cite many sources which should give you abundant technical information on this question. I’ll add a few points for context.

First, many have struggled with this question. Commonly cited sources such as the textbooks by Singer & Willett and by Fitzmaurice, Laird & Ware emphasize that with mixed models (aka random coefficient models, hierarchical linear models, multilevel models, etc.) there is no neat analog to the R-squared (RSQ) of ordinary-least-squares regression. There are ways to approximate explained variance -- to estimate pseudo-RSQ -- but you may find these methods unsatisfactory. Each may produce results on a different scale, such that for a single model you may obtain figures as divergent as .05, .15, and .75 depending on the method. Moreover, these approaches have not been met with any widespread endorsement.

That said, if you compare a given method’s results across models, rather than comparing a given model’s results across methods, you may find these statistics useful. Three of them are

• McFadden’s pseudo-RSQ: McFadden's Pseudo-$R^2$ Interpretation

• The generic pseudo-RSQ computed by squaring the correlation between predicted and observed values. Alternatively, one may track the extent to which a given model reduces (1 - pseudo-RSQ) from a prior model.

• The fraction of level-2 variance (e.g., between-person as opposed to within-person variance) explained by the level-2 predictors.

$\endgroup$
2
  • $\begingroup$ Thank you! However, am I correct that these methods would give me R2 for all of my fixed effects? I'm interested in calculating it for each predictor individually. $\endgroup$
    – Dave
    Jan 20 at 18:56
  • $\begingroup$ Suppose you added one new predictor with each new model. $\endgroup$
    – rolando2
    Jan 20 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.