Skip to contents

Obtain the default priors for a Bayesian multilevel measurement model, as well as information for which parameters priors can be specified. Given the model, the data and the formula for the model, this function will return the default priors that would be used to estimate the model. Additionally, it will return all model parameters that have no prior specified (flat priors). This can help to get an idea about which priors need to be specified and also know which priors were used if no user-specified priors were passed to the bmm() function.

The default priors in bmm tend to be more informative than the default priors in brms, as we use domain knowledge to specify the priors.

Each model parameter carries three default priors, listed in the documentation of the model: main for the intercept (or for all levels of a factor when the intercept is suppressed), effects for the remaining regression coefficients, and sd for the standard deviations of its random effects. The sd prior is applied as a blanket prior to every random-effects standard deviation of that parameter (all grouping factors, intercepts and slopes alike) and replaces the student_t(3, 0, 2.5) default of brms. To override it, address the parameter with dpar or nlpar in brms::set_prior(), e.g. set_prior("exponential(2)", class = "sd", nlpar = "kappa").

Correlations among random effects belong to a grouping factor rather than to one parameter, so they get a single default for the whole model: lkj(2) instead of the lkj(1) of brms, set whenever the model estimates a correlation matrix. To override it, use e.g. set_prior("lkj(1)", class = "cor").

Usage

# S3 method for class 'bmmformula'
default_prior(object, data, model, formula = object, ...)

Arguments

object

A bmmformula object

data

An object of class data.frame, containing data of all variables used in the model. The names of the variables must match the variable names passed to the bmmodel object for required argurments.

model

A description of the model to be fitted. This is a call to a bmmodel such as mixture3p() function. Every model function has a number of required arguments which need to be specified within the function call. Call supported_models() to see the list of supported models and their required arguments

formula

An object of class bmmformula. A symbolic description of the model to be fitted.

...

Further arguments passed to brms::default_prior()

Value

A data.frame with columns specifying the prior, the class, the coef and group for each of the priors specified. Separate rows contain the information on the parameters (or parameter classes) for which priors can be specified.

Examples

default_prior(bmf(c ~ 1, kappa ~ 1),
  data = oberauer_lin_2017,
  model = sdm(resp_error = "dev_rad")
)
#>                     prior     class coef group resp  dpar nlpar   lb   ub tag
#>     student_t(5, 2, 0.75) Intercept                     c       <NA> <NA>    
#>  student_t(5, 1.75, 0.75) Intercept                 kappa       <NA> <NA>    
#>               constant(0) Intercept                             <NA> <NA>    
#>  source
#>    user
#>    user
#>    user