The weight of every combination of per-level models, and the two readings of that table which answer different questions.

crossed_group_weights(object, pooled = NULL)

Arguments

object

An object of class bayesnecgroupfit.

pooled

Optionally, a fit of the same model set to the whole data set, ignoring the factor, as returned by bnec. Used to answer whether the factor matters at all — see Details.

Value

A list with the per-level weight vectors, the unrestricted best combination and its weight, the diagonal weights over the models common to every level, and — if pooled was given — the grouped-versus-pooled comparison. Its criterion is "waic", with waic_grouped, waic_pooled and n_obs, or "looic", with looic_grouped, looic_pooled, n_groups and group, the grouping left out.

Details

Levels partition the data disjointly and share no parameters, so elpd is additive across them: elpd(m_1, ..., m_G) = sum_g elpd_g(m_g). For pseudo-BMA weights computed without the Bayesian bootstrap, the crossed weight of a combination is therefore exactly proportional to the product of its per-level weights, so the whole table follows from the per-level vectors and never has to be materialised — which matters, because with the 24 equations of the default set and G levels it has 24^G cells.

The default pseudo-BMA weights use the Bayesian bootstrap, which each level applies to its own observations. A combination scored on all levels together would resample them jointly, so for the default weights the product of the per-level weights that crossed_group_weights() returns approximates that combination's weight rather than equalling it.

The identity is specific to pseudo-BMA, and crossed_group_weights() enforces it rather than assuming it: a fit built with any other weighting method is refused, because there is no correct crossed table to return for one. Stacking optimises a different objective whose solution is not generally an outer product; stacked crossed weights would require the full pointwise matrix and are not computed here. The same caveat applies to crossed_weights for hurdle fits, for the same reason.

Two readings, both useful

The unrestricted maximum picks the best model for each level independently, and will typically assign different equations to different levels. That is the direct answer to the question this function exists for: whether the functional form of the response changes across levels.

The diagonal maximum, w_m proportional to prod_g w_gm, is a comparison of common-form models: which single equation best describes every level. bayesnec could not answer that before, and it is often the question a reader of the analysis actually has.

Does the factor matter at all?

Pass pooled — a bnec fit of the same model set to the whole data set, with the factor ignored — and the same additivity gives the third reading. A pooled fit is scored on exactly the same observations as the levels together are, so their information criteria are directly comparable: the grouped WAIC is the sum over levels of the best model's WAIC, and the difference against the pooled fit's is a like-for-like comparison. A negative diff favours the pooled fit, a positive one the grouped fit.

The comparison is on WAIC because that is what bayesnec stores on every fit. A standard error for the difference needs the pointwise values, and those are kept only on a single-model fit. A bayesmanecfit stores its component fits as they were before expand_nec() attached their criteria, so it carries each model's WAIC point estimate in mod_stats and none of the pointwise values.

So se_diff is reported when every level, and the pooled fit, settled on a single model, and is NA whenever any of them is model-averaged — in which case the difference is a point estimate with no uncertainty attached, which is worth remembering before reading much into a small one. Where the values are present the observations are additionally checked to line up before anything is computed.

WAIC is computed for each observation, and under a group-level term whose levels are each observed at a single concentration it barely depends on the shape of the curve (see the loo_controls argument of bnec). Where every level, and the pooled fit, is a model set weighted by leaving out each level of the same grouping, the comparison is made on that score instead, as LOOIC (-2 times the elpd), with the groups paired by name for se_diff. Where only some of them are, the comparison stays on WAIC, with a warning.

Note this compares the best model per level against the best pooled model, not the model-averaged predictions of either. Model averaging is within level by construction, and the averaged predictive density is not the weighted sum of the components'.

Examples

if (FALSE) { # \dontrun{
library(bayesnec)
data(nec_data)
nec_data$site <- rep(c("a", "b"), length.out = nrow(nec_data))
fit <- bnec_group(y ~ crf(x, c("nec3param", "ecx4param")), data = nec_data,
                  group_var = "site")
crossed_group_weights(fit)
} # }