-
Notifications
You must be signed in to change notification settings - Fork 0
/
gr.Rmd
49 lines (38 loc) · 1.37 KB
/
gr.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
---
title: "``brms::gr``"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(brms)
```
`` gr`` Set up basic grouping terms in brms
#### Description
Function used to set up a basic grouping term in brms. The function does not evaluate its arguments
– it exists purely to help set up a model with grouping terms. gr is called implicitly inside the package and there is usually no need to call it directly.
#### Usage
<pre><code>
gr(..., by = NULL, dist = "gaussian")
</code></pre>
#### Arguments
* `` ...`` : One or more terms containing grouping factors.
* `` by`` : An optional factor variable, specifying sub-populations of the groups. For each level of the by variable, a separate variance-covariance matrix will be fitted. Levels of the grouping factor must be nested in levels of the by variable.
* `` dist`` : Name of the distribution of the group-level effects. Currently "gaussian" is the only option.
#### Examples
```{r}
# model using basic lme4-style formula
fit1 <- brm(count ~ Trt + (1|patient), data = epilepsy)
summary(fit1)
```
```{r}
# equivalent model using 'gr' which is called anyway internally
fit2 <- brm(count ~ Trt + (1|gr(patient)), data = epilepsy)
summary(fit2)
```
```{r}
# include Trt as a by variable
fit3 <- brm(count ~ Trt + (1|gr(patient, by = Trt)), data = epilepsy)
summary(fit3)
```
#### See Also
brmsformula