The goal of partR2
is to estimate R2 in GLMMs (sensu
Nakagawa & Schielzeth 2013) and to partition the R2 into the
variance explained by the predictors.
The package takes a fitted lme4 model as input and gives you:
All estimates can be combined with parametric bootstrapping to get confidence intervals.
partR2
is still in an early phase of development and might contain
bugs.
You can install the development version of partR2
from GitHub with:
# install.packages("remotes")
remotes::install_github("mastoffel/partR2", build_vignettes = TRUE, dependencies = TRUE)
# check vignette
browseVignettes("partR2")
library(partR2)
library(lme4)
?`partR2-package`
# load data
data(biomass)
# fit lme4 model
mod <- lmer(Biomass ~ Year + Temperature + SpeciesDiversity + (1|Population),
data = biomass)
# R2s and partial R2s
(R2 <- partR2(mod, partvars = c("SpeciesDiversity", "Temperature", "Year"),
R2_type = "marginal", nboot = 100, CI = 0.95))
#>
#>
#> R2 (marginal) and 95% CI for the full model:
#> # A tibble: 1 x 5
#> R2 CI_lower CI_upper nboot ndf
#> <dbl> <dbl> <dbl> <int> <dbl>
#> 1 0.513 0.445 0.594 100 4
#>
#> ----------
#>
#> Part (semi-partial) R2:
#> # A tibble: 8 x 6
#> `Predictor(s)` R2 CI_lower CI_upper nboot ndf
#> <chr> <dbl> <dbl> <dbl> <int> <dbl>
#> 1 Model 0.513 0.445 0.594 100 4
#> 2 SpeciesDiversity 0.173 0.0762 0.282 100 3
#> 3 Temperature 0.306 0.221 0.398 100 3
#> 4 Year 0.014 0 0.145 100 3
#> 5 SpeciesDiversity+Temperature 0.492 0.423 0.571 100 2
#> 6 SpeciesDiversity+Year 0.186 0.0905 0.293 100 2
#> 7 Temperature+Year 0.328 0.246 0.417 100 2
#> 8 SpeciesDiversity+Temperature+Year 0.513 0.445 0.594 100 1
And to plot the results:
forestplot(R2, type = "R2", line_size = 0.7, text_size = 14, point_size = 3)
When using partR2
, please cite our
preprint
for now, and look out for the peer-reviewed paper, which will hopefully
come out soon.
Stoffel, MA, Nakagawa, S, & Schielzeth, H (2020). partR2: Partitioning
R2 in generalized linear mixed models. bioRxiv.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.