R/model-averaging.R
ensemble_inference.RdComputes prior probabilities, posterior probabilities, and inclusion Bayes factors based either on (1) a list of models, vector of parameters, and a list of indicators the models represent the null or alternative hypothesis for each parameter, (2) on prior model odds, marginal likelihoods, and indicator whether the models represent the null or alternative hypothesis, or (3) list of models for each model.
compute_inference(
prior_weights,
margliks,
is_null = NULL,
conditional = FALSE,
on_failure = c("error", "drop", "zero")
)
ensemble_inference(
model_list,
parameters,
is_null_list,
conditional = FALSE,
on_failure = c("error", "drop", "zero")
)
models_inference(model_list, on_failure = c("error", "drop", "zero"))vector of prior model odds
vector of natural-log marginal likelihoods
logical vector of indicators specifying whether the model corresponds
to the null or alternative hypothesis (or an integer vector indexing models
corresponding to the null hypothesis; use 0 or integer(0)
when no models are null)
whether prior and posterior model probabilities should
be returned only for the non-null models. Defaults to FALSE.
Inclusion Bayes factors stay the unconditional inclusion odds; after
conditioning, posterior inclusion is 1, so recomputing the Bayes factor
from the renormalized probabilities would be Inf.
policy for missing (NA) marginal likelihoods in
models with positive prior probability. "error" aborts (the default),
"drop" removes failed models from the prior model space and
renormalizes, and "zero" explicitly assigns the failed models zero
evidence. Non-default policies emit a warning and return audit metadata.
Only NA is treated as a computation failure under this policy.
In model lists, store a failed computation as
bridgesampling_object(NA), a result flagged as failed whose
marginal likelihood is read as NA.
A finite failure must be reported as NA; by contrast,
-Inf is an intentional zero-evidence shortcut (for example via
bridgesampling_object()) and quietly receives posterior
model probability zero without consulting on_failure.
list of models, each of which contains marginal
likelihood estimated with bridge sampling marglik and prior model
odds prior_weights
vector of parameters names for which inference should be drawn
list with entries for each parameter carrying either
logical vector of indicators specifying whether the model corresponds
to the null or alternative hypothesis (or an integer vector indexing models
corresponding to the null hypothesis; use 0 or integer(0)
when no models are null)
Exact matching unique list names bind by parameter name; other ensemble
lists retain positional order. Marginal inference requires unnamed lists or
unique complete names matching its requested parameters.
compute_inference returns a named list of prior probabilities,
posterior probabilities, and Bayes factors. ensemble_inference gives a list of named lists of
inferences for each parameter, and models_inference returns a list of
models, each expanded by the inference list.
Dropping every positive-prior-probability model stops because no
finite marginal likelihood is available; it does not renormalize an empty
model space.
Original positive model odds retain their logarithmic declaration even when
the visible probability rounds to zero. Evidence is centered before model
probabilities and inclusion Bayes factors are evaluated. Finite evidence
differences outside the logarithmic range stop with
BayesTools_numerical_condition. The returned numeric fields remain
ordinary probabilities; passing a visible zero to inclusion_BF() retains
that function's exact supplied-zero meaning.