nauf_stan_glm: Fit a Bayesian fixed effects regression with 'nauf'...

Description Usage Arguments Details Value See Also Examples

View source: R/nauf_stan_regs.R

Description

The Bayesian fixed effects regression functions nauf_stan_lm, nauf_stan_glm.nb, and nauf_stan_glm fit linear, negative binomial, and other generalized linear models, respectively, impelementing nauf_contrasts.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
nauf_stan_glm(formula, family = gaussian(), data = NULL, weights, subset,
  na.action = na.pass, offset = NULL, model = TRUE, x = TRUE,
  y = TRUE, contrasts = NULL, ncs_scale = attr(formula,
  "standardized.scale"), ..., prior = rstanarm::normal(),
  prior_intercept = rstanarm::normal(), prior_aux = rstanarm::cauchy(0, 5),
  prior_PD = FALSE, algorithm = "sampling", adapt_delta = NULL,
  QR = FALSE, sparse = FALSE)

nauf_stan_lm(formula, data = NULL, subset, weights, na.action = na.pass,
  model = TRUE, x = TRUE, y = TRUE, singular.ok = TRUE,
  contrasts = NULL, offset, ncs_scale = attr(formula, "standardized.scale"),
  ..., prior = rstanarm::R2(stop("'location' must be specified")),
  prior_intercept = NULL, prior_PD = FALSE, algorithm = "sampling",
  adapt_delta = NULL)

nauf_stan_glm.nb(formula, data = NULL, weights, subset, na.action = na.pass,
  offset = NULL, model = TRUE, x = TRUE, y = TRUE, contrasts = NULL,
  link = "log", ncs_scale = attr(formula, "standardized.scale"), ...,
  prior = rstanarm::normal(), prior_intercept = rstanarm::normal(),
  prior_aux = rstanarm::cauchy(0, 5), prior_PD = FALSE,
  algorithm = "sampling", adapt_delta = NULL, QR = FALSE)

Arguments

formula, data, family, subset, weights, na.action, offset, contrasts, model, x, y, ncs_scale

See nauf_model.frame.

...

Further arguments to be passed to sampling. See stan_glmer for details.

algorithm

Changes from the default "sampling" result in an error. Only MCMC is currently supported.

singular.ok

See stan_lm.

link, prior, prior_intercept, prior_aux, prior_PD, adapt_delta, QR, sparse

See stan_glm and stan_lm.

Details

nauf_stan_lm, nauf_stan_glm, and nauf_stan_glm.nb are based on the rstanarm functions stan_lm, stan_glm, and stan_glm.nb, respectively, but implement nauf_contrasts. The nauf functions have all the same arguments as the functions they are based on, but additionally ncs_scale, which is passed to nauf_model.frame. Other than ncs_scale, the arguments have the same functions as they do in the functions they are based on. The default values for na.action, contrasts, model, x, and y cannot be changed. For na.action and contrasts, see nauf_model.frame. Forcing model, x, and y to be TRUE ensures that the fitted model retains the model frame, model matrix, and response, respectively. This is necessary for some generic functions applied to the fitted model to work properly. The default priors for the nauf Bayesian fixed effects regression functions are the defaults from rstanarm version 2.15.3; if you have a later version of the rstanarm package, then the default priors for the nauf regression fitting functions may be different from the rstanarm defaults.

Value

A nauf.stanreg object.

See Also

nauf_contrasts for a description of the treatment of NA values, stan_glm for a description of the priors, and the documentation for Stan and the rstan and rstanarm packages for algorithmic details.

Examples

1
2
3
4
5
6
7
## Not run: 
dat <- fricatives
dat$uvoi[!(dat$lang == "Catalan" & dat$wordpos == "Medial")] <- NA
sobj <- standardize(dur ~ lang * wordpos + uvoi, dat)
mod <- nauf_stan_lm(sobj$formula, sobj$data, prior = R2(location = 0.5))

## End(Not run)

CDEager/nauf documentation built on May 6, 2019, 9:24 a.m.