-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
73 lines (50 loc) · 1.79 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE, eval = TRUE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(tidyverse)
library(dplyr)
library(VarDecomp)
```
# VarDecomp
<!-- badges: start -->
[![R-CMD-check](https://github.com/gabewinter/VarDecomp/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/gabewinter/VarDecomp/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/gabewinter/VarDecomp/branch/main/graph/badge.svg)](https://app.codecov.io/gh/gabewinter/VarDecomp?branch=main)
<!-- badges: end -->
VarDecomp can be used for variance decomposition, model fit checks and output visualizations of brms models.
## Installation
You can install the development version of VarDecomp like so:
```{r eval = FALSE}
devtools::install_github("gabewinter/VarDecomp")
```
## Documentation
Full documentation website on: https://gabewinter.github.io/VarDecomp
## Example
```{r example, eval = TRUE}
library(tidyverse)
md = tibble(
sex = sample(rep(c(-0.5, 0.5), each = 500)),
species = sample(rep(c("species1","species2","species3","species4","species5"), each = 200))) %>%
## Create a variables
dplyr::mutate(height = rnorm(1000, mean = 170, sd = 10),
mass = 5 + 0.5 * height + rnorm(1000, mean = 0, sd = 5)) %>%
dplyr::mutate(height = height - mean(height),
mass = log(mass))
mod = brms_model(Chainset = 2,
Response = "mass",
FixedEffect = c("sex","height"),
Family = "gaussian",
Data = md)
model_fit(mod, Group = "sex")
model_summary(mod)
plot_intervals(mod)
PS = var_decomp(mod)
plot_R2(PS)
```