stanova_lm: Estimate ANOVA-type models with rstanarm

Description Usage Arguments Note Examples

View source: R/stanova_lm.R

Description

Estimate ANOVA-type models with rstanarm

Usage

1
2
3
4
5
stanova_lm(formula, data, check_contrasts = "contr.bayes", ...)

stanova_aov(formula, data, check_contrasts = "contr.bayes", ...)

stanova_glm(formula, data, family, check_contrasts = "contr.bayes", ...)

Arguments

formula

a formula describing the model to be fitted. Passed to rstanarm::stan_glm.

data

data.frame containing the data.

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.

...

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

family

family argument passed to stan_glm (set to "gaussian" for stanova_lm and stanova_aov).

Note

stanova_aov is a copy of stanova_lm. All functions discussed here are only wrappers around stanova setting model_fun to "glm" (and family = "gaussian" for stanova_lm).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
fit_warp <- stanova_lm(breaks ~ wool * tension, data = warpbreaks,
                    prior = rstanarm::student_t(3, 0, 20, autoscale = FALSE),
                    chains = 2, iter = 500)
summary(fit_warp)

### from: ?predict.glm
## example from Venables and Ripley (2002, pp. 190-2.)
dfbin <- data.frame(
  ldose = rep(0:5, 2),
  numdead = c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16),
  sex = factor(rep(c("M", "F"), c(6, 6)))
)
budworm.lg <- stanova_glm(cbind(numdead, numalive = 20-numdead) ~ sex*ldose,
                          data = dfbin,
                          family = binomial,
                          chains = 2, iter = 500)
## note: only sex is categorical, ldose is continuous
summary(budworm.lg)

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