Compute fraction of variance attributable to each variable in regression model. Also interpretable as the intra-class correlation after correcting for all other variables in the model.
Usage
varpart(
fit,
...,
distr.method = c("trigamma", "lognormal"),
lambda.method = c("parametric", "mean")
)
# S4 method for class 'fastlmm'
varpart(
fit,
...,
distr.method = c("trigamma", "lognormal"),
lambda.method = c("parametric", "mean")
)
# S4 method for class 'fastglmm'
varpart(
fit,
...,
distr.method = c("trigamma", "lognormal"),
lambda.method = c("parametric", "mean")
)
# S4 method for class 'glm'
varpart(
fit,
...,
distr.method = c("trigamma", "lognormal"),
lambda.method = c("parametric", "mean")
)
# S4 method for class 'negbin'
varpart(
fit,
...,
distr.method = c("trigamma", "lognormal"),
lambda.method = c("parametric", "mean")
)
# S4 method for class 'lm'
varpart(
fit,
...,
distr.method = c("trigamma", "lognormal"),
lambda.method = c("parametric", "mean")
)
# S4 method for class 'merMod'
varpart(
fit,
...,
distr.method = c("trigamma", "lognormal"),
lambda.method = c("parametric", "mean")
)Details
The coefficient of determination (i.e. R^2) is 1 - [Residuals fraction]. This matches performance::r2_nakagawa() and performance::r2_mckelvey(), except these use the "lognormal" method.
For count models, the distributional variance is a function of the mean count rate. Following Eqn 5.8 of Nakagawa, et al. 2017, this can be estimated using parameters of a model including only intercept and random effect terms. But this requires refitting the model dropping the rest of the fixed effects. Instead, computing the mean of the observed counts is a fast approximation.
References
Nakagawa, Johnson, Schielzeth. 2017. The coefficient of determination R2 and intra-class correlation coefficient from generalized linear mixed-effects models revisited and expanded. J. R. Soc. Interface 14: 20170213. doi:10.1098/rsif.2017.0213
Nakagawa, and Schielzeth. "A general and simple method for obtaining R2 from generalized linear mixed‐effects models." Methods in ecology and evolution 4, no. 2 (2013): 133-142. doi:10.1111/j.2041-210x.2012.00261.x