Compute posterior predictive draws averaged across models. Weighting can be done in various ways, for instance using Akaike weights based on information criteria or marginal likelihoods.
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.
Method used to obtain predictions to average over. Should be
one of "posterior_predict"
(default), "posterior_epred"
,
"posterior_linpred"
or "predictive_error"
.
Total number of posterior draws to use.
Deprecated alias of ndraws
.
Should summary statistics
(i.e. means, sds, and 95% intervals) be returned
instead of the raw values? Default is TRUE
.
The percentiles to be computed by the quantile
function. Only used if summary
is TRUE
.
If FALSE
(the default) the mean is used as
the measure of central tendency and the standard deviation as
the measure of variability. If TRUE
, the median and the
median absolute deviation (MAD) are applied instead.
Only used if summary
is TRUE
.
If NULL
(the default) will use model names
derived from deparsing the call. Otherwise will use the passed
values as model names.
Optional list
of further arguments
passed to the function specified in weights
.
A single numeric value passed to set.seed
to make results reproducible.
Same as the output of the method specified
in argument method
.
Weights are computed with the model_weights
method.
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)
# compute model-averaged predicted values
(df <- unique(inhaler[, c("treat", "period", "carry")]))
pp_average(fit1, fit2, newdata = df)
# compute model-averaged fitted values
pp_average(fit1, fit2, method = "fitted", newdata = df)
}