How to get the proportion variance explained by each predictor in an lmer() model? 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?

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.
