View source: R/diagnostics_generic.R
| model_average | R Documentation |
Combine fitted values from several models using native model weights computed
from the pointwise PSIS-LOO (or WAIC) elpd via tulpa_psis() – no loo
package dependency. "loo" / "waic" give stacking weights (the
simplex-optimal predictive combination); "pbma" / "pbma+" give
pseudo-BMA(+) weights. Every model must carry an [n_draws x n_obs] pointwise
log-likelihood (fit$draws$log_lik) over the same observations.
model_average(
...,
weights = c("loo", "waic", "pbma", "pbma+"),
fitted_fn = fitted
)
... |
Named |
weights |
|
fitted_fn |
Function extracting a length- |
A list with averaged (the weighted fitted vector), weights (the
named model weights), and comparison (the compare_models() table).
Yao, Vehtari, Simpson & Gelman (2018). Using stacking to average Bayesian predictive distributions. Bayesian Analysis 13(3):917-1007.
compare_models().
set.seed(1)
df <- data.frame(x = rnorm(120))
df$y <- rpois(120, exp(0.4 + 0.5 * df$x))
f1 <- tulpa(y ~ x, data = df, family = "poisson", mode = "hmc",
control = list(n_iter = 500L, warmup = 250L, seed = 1L))
f2 <- tulpa(y ~ 1, data = df, family = "poisson", mode = "hmc",
control = list(n_iter = 500L, warmup = 250L, seed = 1L))
ma <- model_average(full = f1, null = f2, weights = "waic")
ma$weights
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.