Creates a model-averages posterior distributions on a single model that allows mimicking the mix_posteriors functionality. This function is useful when the model-averaged ensemble is based on prior_spike_and_slab or prior_mixture priors - the model-averaging is done within the model.

as_mixed_posteriors(
  model,
  parameters,
  conditional = NULL,
  conditional_rule = "AND",
  force_plots = FALSE,
  transform_scaled = FALSE,
  n_prior_samples = 10000
)

Arguments

model

model fit via the JAGS_fit function with this version of BayesTools. Fits without its parameter map and fit contract (such as fits created by BayesTools 0.3.0) must be refitted: they stop with an error of class BayesTools_refit_required (see JAGS_validate_fit_contract()).

parameters

vector of parameters names for which inference should be drawn

conditional

a character vector of parameters to be conditioned on

conditional_rule

a character string specifying the rule for conditioning. Either "AND" or "OR". Defaults to "AND".

force_plots

temporal argument allowing to generate conditional posterior samples suitable for prior and posterior plots. Only available when conditioning on a single parameter.

transform_scaled

whether to transform samples from standardized (scaled) to original (unscaled) scale. When TRUE, posterior samples are transformed, and the result can be directly passed to plot_posterior which will automatically detect the transformation and use transformed deterministic prior densities. Requires a model fitted with formula_scale_list. Defaults to FALSE. The transformed prior densities are computed for the requested parameters only and are kept for the fitted object, so repeated calls with the same fit, priors, conditioning, and n_prior_samples reuse them. The prior density of a random-effect SD is that of the SD on the original scale: the fitted law rescaled when the original-scale SD is a rescaling of one fitted SD, and otherwise (an SD that combines several fitted SDs, such as the intercept SD of a block with a non-centered scaled slope) unavailable, which hypothesis_BF(), marginal_posterior() with prior_samples = TRUE and plot_posterior() with prior = TRUE report with an error of class BayesTools_formula_measure_unavailable (see posterior_measure_check()).

n_prior_samples

controls the numerical grid used for transformed prior densities when transform_scaled = TRUE. Defaults to 10000.

Value

as_mix_posteriors returns a named list of mixed posterior distributions (either a vector of matrix).

See also