View source: R/model_weights.R
pp_average.brmsfit | R Documentation |
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.
## 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, ...)
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 |
Weights are computed with the model_weights
method.
Same as the output of the method specified
in argument method
.
model_weights
, posterior_average
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.