Tutorials › Multiple Imputation by Chained Equations (MICE) › Recode and Threshold-Derived Variables

Passive Imputation and Substantive-Model-Compatible Methods · Tutorial 309 of 497

Recode and Threshold-Derived Variables

Learn to keep threshold-based indicators and categories consistent with their incomplete numeric source throughout chained-equation imputation.

Advanced 11 min read

What You'll Learn

  • Define binary indicators and category labels as deterministic functions of a numeric source.
  • Specify fixed thresholds and category boundaries so every eligible value maps to exactly one label.
  • Recompute derived variables whenever the numeric source is updated in an imputation.
  • Check completed data for boundary, coding, and source–derived-variable inconsistencies.
  • Distinguish passive recoding from separately imputing a variable that is deterministically defined by the source.
  • Recognize how threshold choices and imputation-model limitations affect derived-variable analyses.

Why Threshold-Derived Variables Need Special Treatment

A numeric measurement is often used both in its original form and as a threshold-based indicator or category. For example, an analysis may use a laboratory measurement in its original units and also distinguish values above a clinical cut point. If the numeric source has missing values, its derived indicator or category is missing as well. In multiple imputation by chained equations (MICE), the derived variable should remain an exact recoding of the source in every completed data set.

The key distinction is between imputing an unknown measurement and computing a known function of that measurement. When a numeric source is missing, MICE generates a plausible value for it under the specified imputation model. The threshold rule then determines the indicator or category. Imputing the derived variable separately can produce combinations that cannot arise from the rule, such as a value below the cut point paired with an indicator for being above it.

Definition: Let \(X_i\) be a numeric source for unit \(i\), and let \(f\) be a fixed, specified recoding rule. The derived variable is \(D_i=f(X_i)\). If \(X_i\) is missing, \(D_i\) is not separately observed; after imputing \(X_i\), calculate \(D_i\) by applying the same rule \(f\). This is passive derivation of a threshold-based variable.

Specify the Rule Before Recode

A binary indicator needs a threshold and an explicit boundary convention. For a cut point \(c\), one common rule defines the indicator as one when the source is at least \(c\), and zero otherwise. The choice between “at least” and “greater than” matters for values exactly equal to the cut point; it must reflect the intended definition, not a coding convenience.

$$ B_i = I(X_i \geq c) = \begin{cases} 1, & X_i \geq c,\\ 0, & X_i < c. \end{cases} $$

For a categorical variable, specify non-overlapping intervals. With ordered cut points \(c_1<c_2<\cdots<c_{K-1}\), one possible convention is to include the lower endpoint and exclude the upper endpoint in each middle category. The first and last categories must also cover the intended range. If the source can lie outside the cut points, define explicit end categories or state that such values are invalid for the intended measurement; do not leave their recoding ambiguous.

$$ C_i = \begin{cases} 1, & X_i < c_1,\\ k, & c_{k-1} \leq X_i < c_k,\quad k=2,\ldots,K-1,\\ K, & X_i \geq c_{K-1}. \end{cases} $$

These rules presume that the source is measured on the scale and in the units used to set the cut points, that the thresholds are fixed for the analysis, and that the rule gives exactly one value for every allowable source value. In an imputation setting, the numeric source must have an imputation model appropriate to its type and role in the planned analysis. Passive recoding does not repair a poor source imputation model, change the meaning of a cut point, or account automatically for uncertainty in thresholds estimated from data.

Worked Example: A Binary Indicator at a Fixed Cut Point

Suppose a hypothetical study records a continuous measurement \(X\) in units per litre. Define \(B=1\) for \(X\geq 50\) and \(B=0\) for \(X<50\). A participant has an observed value of 47, while another participant’s value is missing. After imputing the second participant’s numeric source, the two completed data sets contain values 52 and 49, respectively.

For the observed value, the rule gives \(B=I(47\geq50)=0\). In the first completed data set, it gives \(B=I(52\geq50)=1\). In the second, it gives \(B=I(49\geq50)=0\). The arithmetic is simply a comparison with the fixed threshold; no separate random draw for \(B\) is made.

The value 50 itself is included in the indicator group because the rule uses \(\geq\). If the definition had instead been \(X>50\), a value of exactly 50 would receive zero. The rule must therefore be stated in a way that settles boundary values as well as values far from the threshold.

Passive Recalculation in Completed Data

When MICE updates an incomplete numeric source, calculate its derived indicator or category from the current value. Apply this to observed as well as imputed source values. In a completed data set, the derived column should be an exact deterministic function of the source column for every unit. Across multiple imputations, the same cut points and boundary conventions are used in every data set.

1
Declare the source and rule.
Record the source variable, units, thresholds, category labels, endpoint conventions, and any allowable range.
2
Impute the incomplete numeric source.
Use the specified MICE conditional model to generate the missing source values. This is the stochastic imputation step.
3
Recalculate the derived variable.
Apply the declared deterministic rule to the current source values in each completed data set, including after source values are updated.
4
Verify the mapping.
Check that every source value maps to the required indicator or label and that no derived value remains inconsistent with its source.

The justification is direct. Given a completed source value \(X_i\), the derived value is fixed: \(D_i=f(X_i)\). For a binary threshold indicator, its conditional probability given information \(Z_i\) used to describe the source is therefore determined by the probability that the source falls on the threshold side:

$$ P(B_i=1\mid Z_i)=P(X_i\geq c\mid Z_i). $$

This follows because the event \(B_i=1\) is exactly the event \(X_i\geq c\), by definition. In particular, if \(X_i\) has already been imputed to a specific value \(x_i\), then \(P(B_i=1\mid X_i=x_i)\) is one when \(x_i\geq c\) and zero otherwise. A separate stochastic draw for \(B_i\) given that fixed \(x_i\) would not preserve the deterministic definition.

Worked Example: Creating Three Categories With Explicit Boundaries

In a hypothetical data set, a numeric score is recorded in points. Define three categories: “low” for scores below 20, “middle” for scores from 20 up to but not including 35, and “high” for scores of at least 35. In numeric form, the rule is \(C=1\) if \(X<20\), \(C=2\) if \(20\leq X<35\), and \(C=3\) if \(X\geq35\).

For an imputed score of 18, \(18<20\), so the category is low. For a score of 27, \(20\leq27<35\), so it is middle. For a score of 35, \(35\geq35\), so it is high. The boundary value 20 is middle, and 35 is high. The intervals do not overlap and cover every real-valued score, so each allowable value receives exactly one category.

If a participant’s missing score is imputed as 33 in one completed data set and 36 in another, the corresponding labels are middle and high. This variation across completed data sets is appropriate: it reflects variation in the imputed source value, while the recoding rule itself remains fixed.

Consistency Checks and Failure Modes

A reliable check is to recalculate the derived variable from the completed numeric source and compare the result with the stored derived column. For a binary variable, every row should satisfy the indicator equation. For a category variable, every row should fall in exactly one specified interval and carry its corresponding label. Checks should be run on all completed data sets, not only on the original data or one selected imputation.

  • Check endpoints explicitly. Test values just below, exactly at, and just above each cut point. This exposes accidental changes from “at least” to “greater than,” or from an inclusive to exclusive interval endpoint.
  • Check units and transformations. A threshold expressed in one unit cannot be applied to a source stored in another unit without conversion. Confirm that any unit conversion occurs consistently before recoding.
  • Check the missingness pattern. Before completion, a derived value based solely on a missing source should also be missing. After completion, it should be present and consistent with the imputed source.
  • Check values near thresholds. Review the number of imputed values falling on either side of each cut point. A sudden concentration or implausible tail near a threshold can flag a problem in the source model, although a check alone cannot establish that the model is appropriate.
  • Check precision before recoding. Rounding a value before comparing it with a cut point can change its category. Apply the declared rule to the intended measurement precision rather than introducing unplanned rounding.

Worked Example: Finding and Correcting an Inconsistent Indicator

Consider a hypothetical binary rule \(B=I(X\geq10)\). In one completed data set, a row has \(X=9.8\) and stored \(B=1\). Applying the formula gives \(I(9.8\geq10)=I(\text{false})=0\). Thus, the row violates the rule; the correct derived value is zero.

Suppose another row has \(X=10.0\) and \(B=1\). The comparison \(10.0\geq10\) is true, so that row is consistent. The distinction illustrates why boundary tests are useful: 10.0 belongs to the indicator group under this convention, while 9.8 does not. Recalculation from the source corrects the inconsistency without introducing another imputation draw.

Why Separate Imputation Is Usually Wrong for a Deterministic Recode

If a binary or categorical variable is exactly defined by an observed numeric source, independently imputing both variables can break their algebraic relationship. The issue is not that binary or categorical imputation is inherently inappropriate. It is that a separate draw is not a valid substitute for applying a known deterministic rule to the corresponding source value.

For example, a separate binary draw might assign \(B=1\) when the same completed record has \(X<c\). Such a pair has zero probability under the stated deterministic definition. Passive recalculation prevents this contradiction. It also preserves the intended meaning of analyses that use the source and its threshold-derived version together.

Directly imputing a categorical variable can be a reasonable approach when the category is itself the recorded variable and no underlying numeric source is available or intended. That is a different data structure: the categories are not being claimed to be a deterministic recoding of another variable. The choice should follow the measurement definition, not just which coding is easiest to fit.

Limitations and Common Mistakes

Thresholding discards information: two source values in the same category become indistinguishable in that derived variable. It also makes the derived result sensitive to values near a cut point. If the source model is inaccurate in that region, or if it gives implausible values, passive recoding will faithfully translate those problems rather than solve them. A good-looking distribution of the categories is not, by itself, evidence that the numeric imputation model is adequate.

A further limitation arises when cut points are estimated from the data rather than fixed by the scientific definition. Treating an estimated threshold as fixed may ignore its uncertainty. How to represent such uncertainty depends on the analysis and design; it should not be hidden by describing an estimated cut point as a fixed clinical or operational rule.

Common mistake: “The binary indicator is missing, so I will impute it using a binary model, then impute the numeric source separately.” If the indicator is defined by that source and the fixed threshold, this can create incompatible values. The correction is to impute the numeric source and deterministically recalculate the indicator using the same rule in every completed data set. Separately imputing the indicator is not the right operation for enforcing a known recoding definition.

Key takeaway: For a threshold-derived variable, define the cut points and boundary rules precisely, impute the incomplete numeric source, and recalculate the indicator or category from that source in every completed data set. Then verify the deterministic mapping row by row.

Check Your Understanding

For each question, decide how the recoding rule applies. Solutions follow the questions.

  1. A rule defines \(B=1\) when \(X\geq12\), and \(B=0\) otherwise. What are the derived values for \(X=11.9\), \(X=12\), and \(X=14\)?
  2. Define categories as low for \(X<5\), middle for \(5\leq X<9\), and high for \(X\geq9\). What category does each of \(X=4.7\), \(X=5\), and \(X=9\) receive?
  3. A completed record has an imputed source value \(X=42\), a fixed binary cut point of 40, and a stored indicator \(B=0\). Is the record consistent? What should be done?
  4. Why can a separately imputed binary indicator conflict with its numeric source when the indicator is defined by a fixed threshold?

Solutions. (1) The values are \(0,1,1\), respectively: 11.9 is below 12, while 12 and 14 are at least 12. (2) The categories are low, middle, and high, respectively; 5 is included in the middle interval and 9 in the high interval. (3) It is inconsistent because \(42\geq40\), so the rule requires \(B=1\). Recalculate the indicator from the source. (4) A separate stochastic draw can assign a value contrary to the deterministic rule—for example, \(B=1\) while \(X\) is below the cut point. Recompute the indicator from the completed source rather than drawing it independently.

Clinical Biostats