model_weights.brmsfit: Model Weighting Methods

Description Usage Arguments Value Examples

View source: R/model_weights.R

Description

Compute model weights in various ways, for instance, via stacking of posterior predictive distributions, Akaike weights, or marginal likelihoods.

Usage

1
2
3
4
## S3 method for class 'brmsfit'
model_weights(x, ..., weights = "stacking", model_names = NULL)

model_weights(x, ...)

Arguments

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.

weights

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.

model_names

If NULL (the default) will use model names derived from deparsing the call. Otherwise will use the passed values as model names.

Value

A numeric vector of weights for the models.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## 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")

## End(Not run)

brms documentation built on Aug. 23, 2021, 5:08 p.m.