Skip to contents

Compare two or more mlumr_fit objects by DIC (default), LOO, or WAIC. For LOO/WAIC, loo::loo_compare() is used under the hood; the output is the standard loo_compare table. The pointwise scores are paired observation by observation, so the fits must be of the same data in the same row order; fits whose stored outcomes differ are refused. For DIC the return is a data frame ordered by DIC.

Usage

compare_models(
  ...,
  criterion = c("dic", "loo", "waic"),
  survival_unit = c("observation", "arm", "aggregate")
)

Arguments

...

Two or more mlumr_fit objects. For DIC, mlumr_dic objects are also accepted.

criterion

One of "dic" (default), "loo", or "waic". LOO and WAIC require the optional loo package.

survival_unit

For survival fits compared by "loo"/"waic", the pointwise unit forwarded to calculate_loo() / calculate_waic(): "observation" (default; per reconstructed comparator pseudo-individual, optimistic), "arm", or "aggregate". Choose "arm" or "aggregate" to select on whole-external-arm predictive fit. Ignored for non-survival families and for criterion = "dic".

Value

For "loo" / "waic": a compare.loo table from loo::loo_compare(). For "dic": a data frame (invisibly) with columns Model, DIC, pD, Delta_DIC.

Details

DIC is the default for backward compatibility and because it has no additional package dependencies. For principled Bayesian model comparison, LOO (Vehtari, Gelman, Gabry 2017) is preferred and requires the optional loo package.