stanova_brm: Estimate ANOVA-type models with brms

Description Usage Arguments Examples

View source: R/stanova_brm.R

Description

Estimate ANOVA-type models with brms

Usage

1
stanova_brm(formula, data, model_fun, ..., check_contrasts = "contr.bayes")

Arguments

formula

a formula describing the statistical model to be estimated. Passed to the rstanarm::stan_ function specified in model_fun.

data

data.frame containing the data.

model_fun

character string identifying the rstanarm function that should be used for fitting (omitting the stan_ prefix) such as "glm" or "glmer".

...

further arguments passed to the rstanarm function used for fitting. Typical arguments are prior, prior_intercept, chain, iter, or core.

check_contrasts

character string (of length 1) denoting a contrast function or a contrast function which should be assigned to all character and factor variables in the model (as long as the specified contrast is not the global default). Default is contr.bayes. Set to NULL to disable the check.

Examples

 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
## Not run: 
fit_warp_brms <- stanova_brm(breaks ~ wool * tension, data = warpbreaks,
                             chains = 2, iter = 1000)
summary(fit_warp_brms)

## End(Not run)

## Not run: 
### binomial GLMM

data("stroop", package = "afex")
## for frequentist analysis see:
### https://cran.r-project.org/package=afex/vignettes/afex_analysing_accuracy_data.html
library("tidyverse")
stroop_e1 <- stroop %>%
  filter(!is.na(acc)) %>%
  filter(study == "1") %>%
  droplevels() %>%
  group_by(condition, congruency, pno) %>%
  summarise(
    succ = sum(acc),
    acc = mean(acc),
    n = n())

bglmm_stroop <- stanova_brm(
  succ | trials(n) ~ congruency*condition + (congruency*condition|pno),
  data = stroop_e1, family = binomial,
  chains = 2, iter = 1000
)
summary(bglmm_stroop)

## End(Not run)

bayesstuff/stanova documentation built on June 9, 2021, 6:18 p.m.