recalc_shk: Recalculate eta shrinkage from individual estimates

View source: R/utils.R

recalc_shkR Documentation

Recalculate eta shrinkage from individual estimates

Description

Unlike get_shk(), which parses the eta shrinkage NONMEM itself reported in the output file, this recalculates shrinkage directly from the individual (empirical Bayes) eta estimates found in the data, using the standard 100 \times (1 - SD(\eta)/\omega) formula, where \omega is the standard deviation implied by the associated diagonal omega estimate.

Usage

recalc_shk(
  xpdb,
  ...,
  .etastype = 1,
  .problem = NULL,
  .subprob = NULL,
  .method = NULL,
  drop_fixed = TRUE,
  quiet
)

Arguments

xpdb

<xpose_dataxpose::xpose_data> or xp_xtras object

...

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

.etastype

<numeric(1)> 1 (the default) excludes, for each eta, individuals whose estimate is a "true zero" (exactly 0, as opposed to merely shrunk near it) from the calculation; 0 keeps them. See Details.

.problem

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

.subprob

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

.method

<character> Method to use. Uses the xpose default if not provided.

drop_fixed

<logical> Drop fixed etas (which have no meaningful shrinkage to recalculate), as in xpose::drop_fixed_cols.

quiet

<logical> Silence extra debugging output

Details

An eta is a "true zero" for an individual when NONMEM never had grounds to move it away from its prior mean of 0, eg an individual with no observations contributing to the objective function. That is different from an eta that is merely shrunk close to 0 through legitimate estimation, and including "true zero" individuals in the shrinkage calculation biases it, since they carry no information about the actual empirical distribution of etas. .etastype = 1 (the default) excludes them from the calculation; .etastype = 0 reproduces the traditional, unadjusted calculation.

Value

A tibble with one row per eta, reporting the omega used, the number of individuals excluded (if any), and the recalculated shrinkage (as a percentage, to stay consistent with get_shk()).

Examples

recalc_shk(xpdb_x)

# Just a subset of etas...
recalc_shk(xpdb_x, ETA1)

# Including "true zero" etas in the calculation
recalc_shk(xpdb_x, .etastype = 0)


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