BIC variants for model selection

Description

The four BIC conventions an automated model search ranks candidates on, as implemented by ferx_core::model_selection::bic() and by pharmpy.modeling.calculate_bic. fit$bic is the classical OFV + p * log(n_obs), which is the "fixed" variant here; Pharmpy’s modelsearch and iivsearch rank on "mixed" and "iiv" instead, because penalising a random-effects structure on the observation count systematically favours the wrong model.

Usage

ferx_bic(fit, type = c("mixed", "fixed", "iiv", "random"))

Arguments

  • fit: A ferx_fit object returned by [ferx_fit](ferx_fit.qmd) or [ferx_load_fit](ferx_load_fit.qmd).
  • type: Which penalty convention to apply: "mixed" (default), "fixed", "iiv" or "random".

Details

The penalty added to the OFV is:

  • mixed: Delattre et al. (2014): n_random * log(n_subjects) + n_fixed * log(n_obs), where a free theta counts as random when it enters an individual parameter carrying an ETA or KAPPA, every free OMEGA / OMEGA_IOV element is random, and SIGMA is fixed-class unless the residual error itself carries an ETA.
  • iiv: n_omega * log(n_subjects) - free BSV OMEGA elements only, for comparing variability structures.
  • random: n_parameters * log(n_subjects).
  • fixed: n_parameters * log(n_obs) - reproduces fit$bic.

The class tally comes from fit$bic_inputs, which the engine fills from the same packed parameter mask it counts n_parameters from, so the variants can be recomputed for a saved fit without the model or data in hand.

Seealso

[check_strictness](check_strictness.qmd) for the eligibility gates a search applies before ranking on one of these. Other diagnostics: [check_diagnostics](check_diagnostics.qmd), [check_strictness](check_strictness.qmd), [ferx_conddist](ferx_conddist.qmd), [ferx_cov_screen](ferx_cov_screen.qmd), [ferx_gam_screen](ferx_gam_screen.qmd), [ferx_get_warnings](ferx_get_warnings.qmd), [ferx_runlog_iters](ferx_runlog_iters.qmd), [ferx_trace](ferx_trace.qmd), [plot.ferx_bootstrap](plot.ferx_bootstrap.qmd), [plot.ferx_fit](plot.ferx_fit.qmd), [summary.ferx_fit](summary.ferx_fit.qmd)

Concept

diagnostics

Value

A single numeric: the BIC under type. NA_real_ when the tally cannot support the penalty - a fit saved before the tally existed, a tally that disagrees with n_parameters, or a zero subject / record count under a convention that needs its logarithm. (ferx-core’s bic() reports NaN in exactly those cases.) A fit with no free parameter returns its OFV under every convention.

Examples

ex  <- ferx_example("warfarin")
fit <- ferx_fit(ex$model, ex$data)
ferx_bic(fit)                  # mixed, the search default
ferx_bic(fit, "fixed")         # == fit$bic