Learn R Programming

brms (version 0.5.0)

get_prior: Overview on Priors for brms Models

Description

Get information on all parameters (and parameter classes) for which priors may be specified including default priors.

Usage

get_prior(formula, data = NULL, family = "gaussian", addition = NULL,
  autocor = NULL, partial = NULL, threshold = c("flexible",
  "equidistant"), internal = FALSE)

Arguments

formula
An object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specification are given under 'Details'.
data
An optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the e
family
A vector of one or two character strings. The first string indicates the distribution of the dependent variable (the 'family'). Currently, the following families are supported: "gaussian", "student", "cauchy",
addition
A named list of one sided formulas each containing additional information on the response variable. The following names are allowed: se for specifying standard errors for meta-analysis, weights to fit weighted regression models,
autocor
An optional cor_brms object describing the correlation structure within the response variable (i.e. the 'autocorrelation'). See the documentation of cor_brms
partial
A one sided formula of the form ~expression specifying the predictors with category specific effects in non-cumulative ordinal models (i.e. in families "cratio", "sratio", or "acat").
threshold
A character string indicating the type of thresholds (i.e. intercepts) used in an ordinal model. "flexible" provides the standard unstructured thresholds and "equidistant" restricts the distance between consecutive thresholds to
internal
A flag indicating if the names of additional internal parameters should be displayed. Setting priors on these parameters is not recommended

Value

  • A data.frame with columns prior, class, coef, and group and several rows, each providing information on a paramter (or parameter class) on which priors can be specified. The prior column is empty except for internal default priors.

See Also

set_prior

Examples

Run this code
## get all parameters and parameters classes to define priors on
(prior <- get_prior(count ~ log_Age_c + log_Base4_c * Trt_c
                    + (1|patient) + (1|visit),
                    data = epilepsy, family = "poisson"))

## define a prior on all fixed effects a once
prior$prior[1] <- "normal(0,10)"

## define a specific prior on the fixed effect of Trt_c
prior$prior[5] <- "uniform(-5,5)"

## fit a model using the priors above
fit <- brm(count ~ log_Age_c + log_Base4_c * Trt_c
           + (1|patient) + (1|visit),
           data = epilepsy, family = "poisson", prior = prior)

## check that priors indeed found their way into Stan's model code
fit$model

Run the code above in your browser using DataLab