get_prior: Overview on Priors for 'brms' Models

Description Usage Arguments Value See Also Examples

View source: R/priors.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
get_prior(
  formula,
  data,
  family = gaussian(),
  autocor = NULL,
  data2 = NULL,
  knots = NULL,
  sparse = NULL,
  ...
)

Arguments

formula

An object of class formula, brmsformula, or mvbrmsformula (or one that can be coerced to that classes): A symbolic description of the model to be fitted. The details of model specification are explained in brmsformula.

data

An object of class data.frame (or one that can be coerced to that class) containing data of all variables used in the model.

family

A description of the response distribution and link function to be used in the model. This can be a family function, a call to a family function or a character string naming the family. Every family function has a link argument allowing to specify the link function to be applied on the response variable. If not specified, default links are used. For details of supported families see brmsfamily. By default, a linear gaussian model is applied. In multivariate models, family might also be a list of families.

autocor

(Deprecated) An optional cor_brms object describing the correlation structure within the response variable (i.e., the 'autocorrelation'). See the documentation of cor_brms for a description of the available correlation structures. Defaults to NULL, corresponding to no correlations. In multivariate models, autocor might also be a list of autocorrelation structures. It is now recommend to specify autocorrelation terms directly within formula. See brmsformula for more details.

data2

A named list of objects containing data, which cannot be passed via argument data. Required for some objects used in autocorrelation structures to specify dependency structures as well as for within-group covariance matrices.

knots

Optional list containing user specified knot values to be used for basis construction of smoothing terms. See gamm for more details.

sparse

(Deprecated) Logical; indicates whether the population-level design matrices should be treated as sparse (defaults to FALSE). For design matrices with many zeros, this can considerably reduce required memory. Sampling speed is currently not improved or even slightly decreased. It is now recommended to use the sparse argument of brmsformula and related functions.

...

Other arguments for internal usage only.

Value

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

See Also

set_prior

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## get all parameters and parameters classes to define priors on
(prior <- get_prior(count ~ zAge + zBase * Trt + (1|patient) + (1|obs),
                    data = epilepsy, family = poisson()))   
         
## define a prior on all population-level effects a once
prior$prior[1] <- "normal(0,10)"

## define a specific prior on the population-level effect of Trt
prior$prior[5] <- "student_t(10, 0, 5)"       

## verify that the priors indeed found their way into Stan's model code
make_stancode(count ~ zAge + zBase * Trt + (1|patient) + (1|obs),
              data = epilepsy, family = poisson(), 
              prior = prior)

brms documentation built on Aug. 23, 2021, 5:08 p.m.