Last chance! 50% off unlimited learning
Sale ends in
Compute model weights in various ways, for instance via stacking of predictive distributions, Akaike weights, or marginal likelihoods.
# S3 method for brmsfit
model_weights(x, ..., weights = "loo2",
model_names = NULL)model_weights(x, ...)
A fitted model object.
More fitted model objects or further arguments passed to the underlying post-processing functions.
Name of the criterion to compute weights from.
Should be one of "loo"
, "waic"
, "kfold"
,
"loo2"
(current default), or "marglik"
.
For the former three options, Akaike weights will be computed
based on the information criterion values returned by
the respective methods. For "loo2"
, method
loo_model_weights
will be used to obtain weights.
For "marglik"
, method post_prob
will be used to compute weights based on log marginal
likelihood values (make sure to specify reasonable priors in
this case). Alternatively, weights
can 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.
# NOT RUN {
# 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")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab