Skip to contents

This extends brms::prior() by

  1. allowing just taking a numeric value rather than constant(<value>) to specify a constant prior

  2. if brms::brmsprior is given, it checks that it has the specified arguments

This is used in building BayesPharma models to allow user specified priors but make sure they are for the right parameters to make sure the model is well specified.

Usage

prepare_prior(prior, ...)

Arguments

prior

brms::brmsprior or numeric.

...

additional arguments to brms::prior_string(). If prior is a brms::brmsprior then this will check that the slots have the given values. If prior is numeric, then these arguments are passed to brms::prior_string()

Examples

if (FALSE) { # \dontrun{
  # user should specify a prior for hill, but they misspell it:
  user_hill_prior <- brms::prior(
    prior = normal(1, 1),
    nlpar = "hilll",
    ub = 0)

  # in a script where we want to validate the user_hill_prior
  hill_prior <- BayesPharma:::prepare_prior(
    prior = user_hill_prior,
    nlpar = "hill")

  # gives an assert error that nlpar is not set correctly

} # }