-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.Rmd
97 lines (68 loc) · 3.06 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
output: github_document
---
<!-- badges: start -->
[![CRAN total downloads](https://cranlogs.r-pkg.org/badges/grand-total/partR2?color=blue)](https://cran.r-project.org/package=partR2)
[![Monthly downloads badge](https://cranlogs.r-pkg.org/badges/last-month/partR2?color=blue)](https://CRAN.R-project.org/package=partR2)
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#maturing)
[![Codecov test coverage](https://codecov.io/gh/mastoffel/partR2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/mastoffel/partR2?branch=master)
<!-- badges: end -->
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
```{r echo=FALSE, results="hide", message=FALSE}
#library("txtplot")
library("badger")
```
# partR2
The goal of `partR2` is to estimate R^2^ in GLMMs (sensu Nakagawa & Schielzeth 2013) and to partition the R^2^ into the variance explained by the predictors.
The package takes a fitted lme4 model as input and gives you:
* R^2^ (marginal or conditional)
* Part (semi-partial) R^2^, the variance explained uniquely by each predictor and combinations of predictors
* Inclusive R^2^, the variance explained by a predictor independent of all
other predictors
* Structure coefficients, the correlation between a predictor and the fitted response
* Beta weights, standardised model estimates
All estimates can be combined with parametric bootstrapping to get confidence intervals.
## Installation
You can install the stable version of `partR2` from CRAN with:
```{r, eval = FALSE}
install.packages("partR2")
```
Or the development version from GitHub with:
```{r gh-installation, eval = FALSE}
# install.packages("remotes")
remotes::install_github("mastoffel/partR2", build_vignettes = TRUE, dependencies = TRUE)
```
Access the vignette with:
```{r vignette, eval = FALSE}
# check vignette
browseVignettes("partR2")
```
`partR2` is still in an early phase of development and might contain bugs. If you find one, please report a minimal reproducible example in the [issues](https://github.com/mastoffel/partR2/issues).
### Citation
When using `partR2`, please cite our [paper](https://peerj.com/articles/11414/):
Stoffel MA, Nakagawa S, Schielzeth H. 2021. partR2: partitioning R2 in generalized linear mixed models. *PeerJ* **9**:e11414 https://doi.org/10.7717/peerj.11414
## Example
```{r example, results = TRUE, warning=FALSE, message=FALSE}
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))
```
And to plot the results:
```{r plot, results = TRUE, warning=FALSE, fig.width=7, fig.height=4}
forestplot(R2, type = "R2", line_size = 0.7, text_size = 14, point_size = 3)
```