pp_average.brmsfit {brms} | R Documentation |
Posterior predictive draws averaged across models
Description
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.
Usage
## S3 method for class 'brmsfit'
pp_average(
x,
...,
weights = "stacking",
method = "posterior_predict",
ndraws = NULL,
nsamples = NULL,
summary = TRUE,
probs = c(0.025, 0.975),
robust = FALSE,
model_names = NULL,
control = list(),
seed = NULL
)
pp_average(x, ...)
Arguments
x |
A |
... |
More |
weights |
Name of the criterion to compute weights from. Should be one
of |
method |
Method used to obtain predictions to average over. Should be
one of |
ndraws |
Total number of posterior draws to use. |
nsamples |
Deprecated alias of |
summary |
Should summary statistics
(i.e. means, sds, and 95% intervals) be returned
instead of the raw values? Default is |
probs |
The percentiles to be computed by the |
robust |
If |
model_names |
If |
control |
Optional |
seed |
A single numeric value passed to |
Details
Weights are computed with the model_weights
method.
Value
Same as the output of the method specified
in argument method
.
See Also
model_weights
, posterior_average
Examples
## 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)
# 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)
## End(Not run)