stacking()

Compute stacking weights for model averaging.

Usage

Source

stacking(*results)

Given LOO or WAIC results from multiple models fitted to the same data, finds the optimal combination weights that maximize the combined leave-one-out predictive density of the weighted mixture.

Unlike pairwise loo_compare() or waic_compare(), stacking handles any number of models simultaneously and produces a single set of weights suitable for prediction averaging.

Parameters

*results: LOOResult or WAICResult
Two or more LOO or WAIC results. All must be the same type and computed on the same data (same number of observations).

Returns

StackingResult
Contains the optimal weights, combined ELPD, and a display-friendly summary.

Examples

loo1 = model1.loo()
loo2 = model2.loo()
loo3 = model3.loo()
result = stacking(loo1, loo2, loo3)
print(result.weights)  # e.g., array([0.62, 0.35, 0.03])