derive_shk: Derive per-individual contribution to eta shrinkage

View source: R/utils.R

derive_shkR Documentation

Derive per-individual contribution to eta shrinkage

Description

Computes, for each selected eta, a diagnostic column highlighting each individual's contribution to shrinkage: \log((\eta_i - \bar\eta)^2), ie the log of the squared deviation from the population mean eta. Since shrinkage itself is 100 * (1 - SD(eta)/omega) (see recalc_shk()), and SD(eta)^2 is the mean of these per-individual squared deviations, this highlights which individuals are pulling shrinkage down. The log spreads out values close to 0, ie individuals contributing the least (the most heavily shrunk).

derive_shk() returns the augmented data as a plain data frame, like xpose::get_data()'s output. backfill_shk() joins the new column(s) back into xpdb and tags them with the shk variable type. This has to be backfilled rather than parsed, since it isn't something NONMEM (or any other supported software) reports directly.

Usage

derive_shk(xpdb, ..., .problem = NULL, quiet)

backfill_shk(xpdb, ..., .problem = NULL, quiet)

Arguments

xpdb

<xpose_dataxpose::xpose_data> or xp_xtras object

...

<tidyselect> Which eta column(s) to derive a shrinkage contribution for. Defaults to every eta column for .problem.

.problem

<numeric> Problem number to use. Uses the xpose default if not provided.

quiet

<logical> Silence extra debugging output

Value

For derive_shk(), a data frame with one new column per selected eta, named ⁠<eta>_SHK⁠. For backfill_shk(), the updated xp_xtras object, with those columns joined in and typed shk.

Examples

derive_shk(xpdb_x) %>%
  dplyr::select(ID, dplyr::ends_with("_SHK")) %>%
  head()

xpdb_x %>%
  backfill_shk() %>%
  list_vars()


xpose.xtras documentation built on Sept. 1, 2026, 5:08 p.m.