Compute model weights in various ways, for instance, via stacking of posterior predictive distributions, Akaike weights, or marginal likelihoods.
# S3 method for brmsfit
model_weights(x, ..., weights = "stacking", model_names = NULL)
model_weights(x, ...)
A brmsfit
object.
More brmsfit
objects or further arguments
passed to the underlying post-processing functions.
In particular, see prepare_predictions
for further
supported arguments.
Name of the criterion to compute weights from. Should be one
of "loo"
, "waic"
, "kfold"
, "stacking"
(current
default), or "bma"
, "pseudobma"
, For the former three
options, Akaike weights will be computed based on the information criterion
values returned by the respective methods. For "stacking"
and
"pseudobma"
, method loo_model_weights
will be used to
obtain weights. For "bma"
, method post_prob
will be
used to compute Bayesian model averaging weights based on log marginal
likelihood values (make sure to specify reasonable priors in this case).
For some methods, weights
may also be a numeric vector of
pre-specified weights.
If NULL
(the default) will use model names
derived from deparsing the call. Otherwise will use the passed
values as model names.
A numeric vector of weights for the models.
if (FALSE) {
# model with 'treat' as predictor
fit1 <- brm(rating ~ treat + period + carry, data = inhaler)
summary(fit1)
# model without 'treat' as predictor
fit2 <- brm(rating ~ period + carry, data = inhaler)
summary(fit2)
# obtain Akaike weights based on the WAIC
model_weights(fit1, fit2, weights = "waic")
}