Tutorials › Multiple Imputation by Chained Equations (MICE) › Passive Imputation of Spline Basis Terms

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

Passive Imputation of Spline Basis Terms

Learn to construct fixed spline basis terms and update them passively whenever their incomplete predictor is imputed.

Advanced 10 min read

What You'll Learn

  • Define spline basis columns as deterministic functions of a predictor and fixed knot locations.
  • Calculate restricted cubic spline terms from a concrete set of knots.
  • Recompute every basis column after each imputed value of the underlying predictor.
  • Distinguish algebraic consistency from compatibility between the imputation and analysis models.
  • Identify stale columns, changing knots, and unsupported extrapolation as potential failure modes.
  • Compare passive spline terms with linear, categorical, and independently imputed alternatives.

Why spline terms must follow the predictor

A regression model may need to represent a curved association between an incomplete continuous predictor and an outcome. A spline does this by representing the predictor through several basis columns. Those columns are not additional measurements: they are calculated from the predictor and specified knot locations. Consequently, when an imputed value of the predictor changes, every spline column calculated from it must change as well.

This is the spline-specific application of passive imputation. Passive calculation preserves the exact relationship between the imputed predictor and its derived columns. It does not, by itself, guarantee that the imputation models are compatible with the substantive analysis model. The earlier material on compatibility and passive imputation provides the broader context; here the focus is constructing and updating spline basis terms.

Definition: A spline basis for a predictor \(X\) is a specified collection of functions \(B_1(X),\ldots,B_q(X)\), defined using a chosen spline form and fixed knot locations. Each basis column is a deterministic function of \(X\). Passive imputation of spline terms means calculating these columns from the current value of \(X\), rather than drawing their values independently.

The spline form, knot locations, and boundary knots define the functions. They should be held fixed across completed data sets when the aim is to use the same analysis representation in each one. The predictor itself may differ across imputations; its basis values should then differ accordingly. For a model with outcome \(Y\) and fully observed covariates \(Z\), an illustrative analysis model is

$$ E(Y_i\mid X_i,Z_i) = \beta_0+\beta_X X_i+\sum_{j=1}^{q}\beta_j B_j(X_i)+\gamma^\mathsf{T}Z_i. $$

The basis columns describe the chosen nonlinear effect; their regression coefficients are estimated in the analysis. The knot locations are part of the specification, not new parameters independently estimated for each imputed data set.

A restricted cubic spline basis

One useful example is the restricted cubic spline basis, which is linear beyond its outer boundary knots. Let the distinct ordered knots be \(k_1<\cdots<k_K\). Define the positive-part function by \((u)_+=\max(u,0)\). For \(j=1,\ldots,K-2\), define

$$ d_j(x) = (x-k_j)_+^3 -\frac{k_K-k_j}{k_K-k_{K-1}}(x-k_{K-1})_+^3 +\frac{k_{K-1}-k_j}{k_K-k_{K-1}}(x-k_K)_+^3. $$

A restricted cubic spline can be represented using \(x\) and these \(K-2\) nonlinear columns, along with an intercept if the regression model includes one. Other software may use a different but equivalent basis for the same spline function space. Whichever representation is chosen, the exact same specified transformation must be applied to the predictor values in every completed data set.

Key condition: The knots and the basis definition must be fixed while the imputation procedure and analyses are carried out. For every case and every imputation, calculate each spline column from that case’s current predictor value using that same definition. If \(X\) is imputed, do not retain a basis value calculated from an earlier value of \(X\).

Why the restricted cubic basis is linear in the tails

The word “restricted” refers to the linear tails outside the boundary knots. This property follows directly from the basis formula. For \(x>k_K\), all three positive-part terms in \(d_j(x)\) are active. Write

$$ a=\frac{k_K-k_j}{k_K-k_{K-1}}, \qquad b=\frac{k_{K-1}-k_j}{k_K-k_{K-1}}. $$

The third derivative of \(d_j(x)\) in this region is \(6(1-a+b)\). Since \(a-b=1\), this derivative is zero. The second derivative also vanishes: its coefficient of \(x\) is \(1-a+b=0\), and its constant term is \(-k_j+a k_{K-1}-b k_K=0\). Therefore \(d_j(x)\) is linear for \(x>k_K\). For \(x<k_1\), all positive-part terms are zero, so \(d_j(x)=0\) there. This verifies the tail behavior from the formula rather than assuming it from the spline’s name.

Worked Example: Calculating a Restricted Cubic Spline Term

Suppose a hypothetical clinical data set uses \(X\), measured in years, with knots \(k_1=0\), \(k_2=5\), and \(k_3=10\). There is one nonlinear basis column because \(K-2=1\). Substituting the knots into the definition gives

$$ d_1(x)=(x-0)_+^3-2(x-5)_+^3+(x-10)_+^3. $$

For a case with \(x=7\) years, the positive parts are \(7\), \(2\), and \(0\). Thus

$$ d_1(7)=7^3-2(2^3)+0^3=343-16=327\ \text{years}^3. $$

For a case with \(x=12\) years, all three terms are positive:

$$ d_1(12)=12^3-2(7^3)+2^3=1728-686+8=1050\ \text{years}^3. $$

The analysis model uses both the linear predictor \(x\), in years, and the nonlinear basis value \(d_1(x)\), in years cubed, with coefficients on their corresponding scales. These calculations are determined by the predictor and the fixed knots; neither basis value is separately imputed.

Updating the columns during chained equations

Suppose \(X\) has missing values and the analysis will include its spline basis. In each completed data set, observed \(X\) values remain as observed and missing \(X\) values receive imputed draws. After a draw changes \(X_i\), recalculate every spline column \(B_j(X_i)\) for that case before any subsequent conditional model or analysis uses those columns. Recalculating the columns for all cases from the current \(X\) vector is also a simple way to ensure that the data remain synchronized.

1
Specify the basis.
Choose the spline form, the knot locations, and any boundary knots. Record the specification so the same functions are used throughout.
2
Draw missing predictor values.
Use the designated conditional imputation model to update missing values of \(X\), conditional on the information included in that model.
3
Recalculate all derived columns.
Evaluate each \(B_j(X_i)\) using the current \(X_i\) and the fixed basis definition, including for cases whose imputed \(X_i\) just changed.
4
Continue the chain and analyze.
Any later step that uses the spline columns sees values derived from the current predictor. Fit the same substantive spline specification in each completed data set.

The conditional model used to impute \(X\) still requires statistical judgment. It should include relevant observed information, and the outcome is commonly important when imputing a predictor used in an outcome analysis. Passive recalculation enforces the algebraic relation between \(X\) and its basis terms; it does not make an inadequate conditional imputation model adequate, or ensure substantive-model compatibility.

Worked Example: Recomputing Terms Across Two Imputations

Consider a hypothetical case with missing \(X\), measured in years, and the same knots \(0,5,10\). Two completed data sets produce draws of \(X=7\) and \(X=12\) years. With the basis \(d_1(x)=(x-0)_+^3-2(x-5)_+^3+(x-10)_+^3\), the derived values are

$$ d_1(7)=343-2(8)+0=327\ \text{years}^3, \qquad d_1(12)=1728-2(343)+8=1050\ \text{years}^3. $$

Thus the first completed data set contains \((X,d_1(X))=(7,327)\), and the second contains \((12,1050)\), in the stated units. The same case can have different predictor and basis values across imputations because the imputed predictor draw differs. The knot locations and the function do not differ.

If the case also has a linear \(X\) column, that column must contain 7 in the first data set and 12 in the second. Keeping \(d_1(X)=327\) alongside \(X=12\) would combine values from different predictor states and would not represent the specified spline in either data set.

Diagnostics, alternatives, and limits

A direct diagnostic is to verify, for every completed data set, that each stored basis column equals the basis function evaluated at the current \(X\). For the example above, a case with \(X=12\) must have \(d_1(X)=1050\) under the stated knots and formula. A mismatch indicates a stale or incorrectly calculated column. It is useful to check several cases: below the first knot, between knots, and beyond the last knot. Also inspect the imputed \(X\) values for implausible values or excessive extrapolation; recalculating a spline correctly cannot repair an implausible draw.

Keep the same specification across imputations. Re-estimating knots separately in each completed data set changes the functions being represented, so a column with a given index may no longer have the same meaning from one analysis to the next. The fitted analysis coefficients would then refer to changing basis definitions. A fixed specification makes the analyses comparable, though it does not account for uncertainty in knot selection.

ApproachWhat it doesImportant limitation
Linear term onlyUses \(X\) without nonlinear basis columns.May not represent a curved association.
Fixed spline basis, passively recalculatedUses a prespecified flexible function of \(X\) and maintains exact derived values.Does not, on its own, ensure that the imputation model preserves the substantive model.
Categorize \(X\)Replaces the continuous predictor with category indicators.Loses within-category information and makes the result depend on cut points.
Impute spline columns separatelyDraws values for transformed columns as if they were separate incomplete variables.Can produce combinations that are not the basis of any single \(X\) value.

The practical choice of spline form and knot locations is an analysis decision. A fixed spline can represent nonlinear patterns, but its shape is constrained by its basis and knots. Sparse data in parts of the predictor range can make estimates there unstable, and extreme imputed predictor draws can place cases in regions with little observed information. Passive updating guarantees a deterministic relationship, not a well-supported model or a reliable analysis. If the substantive model and predictor imputation model have important structural conflicts, passive columns alone do not resolve them; methods designed to address substantive-model compatibility are a distinct consideration.

Worked Example: Finding a Stale Basis Value

A hypothetical record initially has \(X=4\) years. With knots \(0,5,10\), its nonlinear term is

$$ d_1(4)=4^3-2(0)_+^3+(0)_+^3=64\ \text{years}^3. $$

Suppose a later imputation updates the record to \(X=7\) years. The correct value is

$$ d_1(7)=7^3-2(2^3)+0=343-16=327\ \text{years}^3. $$

If the stored column remains 64, the discrepancy is \(327-64=263\ \text{years}^3\). The value 64 is not a second plausible imputation of the spline term: it is the basis value for the obsolete predictor value 4. The correction is to recalculate the entire basis row from the updated \(X=7\), yielding \(d_1(X)=327\).

Common mistakes

  • Imputing basis columns independently. This can break their deterministic relationship to \(X\). Draw the incomplete predictor and calculate its spline terms from the resulting value.
  • Updating \(X\) but leaving old columns in place. The analysis then receives inconsistent values. Recalculate every dependent column after the predictor update.
  • Changing knots from one imputation to another. This changes the basis definition and makes the analyses use different representations. Use the same fixed specification.
  • Assuming passive calculation solves compatibility. It guarantees algebraic consistency only. The conditional imputation model and substantive analysis model still require appropriate specification.
  • Assuming a spline makes extreme imputations harmless. A correctly calculated basis can still be based on an implausible or weakly supported predictor draw. Inspect the draws and their range.
Key takeaway: A spline basis column is a deterministic function of its predictor and fixed knots. After every imputed update to the predictor, recalculate every basis column from the current value before those columns are used again.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. With knots \(0,5,10\), calculate \(d_1(3)\) using the restricted cubic basis defined above.
  2. A case has \(X=7\) in one completed data set and \(X=12\) in another. Must its spline basis value be the same in both? Explain.
  3. After \(X\) changes from 4 to 7, a stored basis value remains 64. What is the correct value, and what caused the mismatch?
  4. Why should knot locations be held fixed across completed data sets?
  5. Does passive recalculation alone guarantee compatibility between the imputation and substantive analysis models? Explain.

Solutions. (1) Since 3 is below 5, only the first positive-part term is nonzero: \(d_1(3)=3^3=27\ \text{years}^3\). (2) No. The predictor draws differ, so the function values differ: \(d_1(7)=327\ \text{years}^3\) and \(d_1(12)=1050\ \text{years}^3\). (3) The correct value is \(d_1(7)=327\ \text{years}^3\); 64 was calculated from the earlier value \(X=4\) and was not recalculated. (4) Fixed knots preserve the same basis definition and interpretation across imputations, making the analyses comparable. (5) No. Passive recalculation preserves the deterministic relation between \(X\) and its basis columns, but it does not by itself ensure adequate imputation-model specification or substantive-model compatibility.

Clinical Biostats