
Generic S3 method for configuring the default prior for a bmmodel
Source:R/helpers-prior.R
configure_prior.RdCalled by bmm() to automatically construct the priors for a given
model, data and formula, and combine it with the prior given by the user. The
first method executed is configure_prior.bmmodel, which will build the prior
based on information from the model object such as fixed_parameters,
default_priors, etc. Thus it is important to define these values in the model
object. The function will also recognize if the user has specified that some
parameters should be fixed to a constant and put the appropriate constant
priors. Any additional priors that a developer wants to specify, which are
not based on information in the model object, can be defined in the
configure_prior.* method for the model, as mpt does; the example shows
the form such a method takes.
Examples
if (FALSE) { # identical(Sys.getenv("BMM_EXAMPLES"), "true")
configure_prior.mymodel <- function(model, data, formula, user_prior, ...) {
# a prior that depends on the data, which the model object cannot declare
if (!"condition" %in% names(data)) {
return(NULL)
}
brms::prior_("normal(0, 0.5)", class = "b", dpar = "kappa")
}
}