Tutorials › Multiple Imputation by Chained Equations (MICE) › Worked Example With a Spline Analysis

Imputation-Model Compatibility With the Analysis Model · Tutorial 282 of 497

Worked Example With a Spline Analysis

Learn how to check whether an imputation model can preserve a restricted cubic spline relationship in the planned outcome regression.

Advanced 12 min read

What You'll Learn

  • Identify the spline terms that define the substantive outcome model.
  • Derive the covariate’s conditional distribution from a normal outcome model.
  • Distinguish compatibility from simply including the outcome as a predictor.
  • Work through numerical spline and conditional-imputation calculations.
  • Audit model assumptions, diagnostics, and practical alternatives.

Why a spline analysis needs a compatibility check

Suppose an outcome regression relates a continuous outcome \(Y\) to a continuous covariate \(X\), but some values of \(X\) are missing. If the planned regression allows a nonlinear relationship using a restricted cubic spline, the imputation model must be capable of preserving that relationship. Including \(Y\) as a predictor of \(X\) is important, but does not by itself ensure compatibility with the analysis model.

The key question is not whether the imputation model contains a variable called \(X\), nor whether it predicts \(X\) well on average. It is whether the imputation procedure can reproduce the joint distribution of \(X\), \(Y\), and the other covariates that is consistent with the planned spline regression. The audit below focuses on a continuous outcome with normally distributed errors. The same general principle applies to other outcome models, although their likelihoods differ.

Definition: An imputation model and an analysis model are compatible when they can be derived from the same joint probability model for the variables they share. For a missing covariate \(X\), compatibility requires that the imputation conditional distribution for \(X\), given the observed outcome \(Y\) and other covariates \(Z\), agrees with the conditional distribution implied by the analysis model together with a model for \(X\) given \(Z\).

Write down the spline analysis model first

A restricted cubic spline represents a smooth relationship that is linear beyond the outer knots. With \(K\) ordered knots \(k_1<k_2<\cdots<k_K\), one common basis contains \(X\) and \(K-2\) nonlinear terms. Define \(a_+=\max(a,0)\) and, 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. $$

The regression can be written using the basis \(x,d_1(x),\ldots,d_{K-2}(x)\). Rescaling or otherwise changing the basis can make coefficients easier to read, without changing the fitted curve when the transformation is full rank. The spline terms are functions of \(X\), not additional observed covariates.

For the main derivation, assume \(Y\) is continuous and that, conditional on \(X\) and \(Z\), the outcome follows a normal linear model with constant variance:

$$ Y\mid X=x,Z=z\sim N\!\left(\eta(x,z),\sigma^2\right), \qquad \eta(x,z)=\beta_0+\sum_{j=1}^{K-1}\beta_j B_j(x)+\gamma^\mathsf{T}z, $$

where \(B_1(x)=x\), the remaining \(B_j(x)\) are the restricted cubic spline terms, and \(Z\) denotes the other predictors in the analysis. This model assumes that the conditional mean has the stated spline form, the residual variance is constant, and the conditional outcome distribution is normal. If any of these assumptions is not appropriate, the implied imputation conditional below also changes.

Worked Example: Calculating Terms in a Restricted Cubic Spline

Consider a hypothetical analysis of systolic blood pressure, measured in mmHg, using age \(X\) in years. Use knots \(20,40,60,80\) years. The basis has the linear term \(x\) and two nonlinear terms, \(d_1(x)\) and \(d_2(x)\). To keep the calculations readable, define scaled terms \(U_1=d_1/10000\) and \(U_2=d_2/10000\).

At age \(x=50\), the positive-part cubic terms are \((50-20)^3=27000\), \((50-40)^3=1000\), and zero for the 60- and 80-year knots. Thus,

$$ d_1(50)=27000,\qquad d_2(50)=1000, \qquad U_1(50)=2.7,\quad U_2(50)=0.1. $$

At age \(x=70\), the corresponding positive-part terms for the 20-, 40-, and 60-year knots are \(125000\), \(27000\), and \(1000\); the 80-year term is zero. Since \(k_4-k_3=20\), the formula gives

$$ \begin{aligned} d_1(70)&=125000-\frac{60}{20}(1000)=122000,\\ d_2(70)&=27000-\frac{40}{20}(1000)=25000,\\ U_1(70)&=12.2,\qquad U_2(70)=2.5. \end{aligned} $$

Suppose a hypothetical fitted mean model is \(\eta(x)=12+0.05x+0.8U_1(x)-0.6U_2(x)\). At 50 years its predicted mean is \(12+0.05(50)+0.8(2.7)-0.6(0.1)=16.60\) mmHg. At 70 years it is \(12+0.05(70)+0.8(12.2)-0.6(2.5)=23.76\) mmHg. These values illustrate how the nonlinear spline terms affect the fitted mean; they are not claims about a real population.

Derive the conditional distribution used for imputation

The analysis model specifies \(Y\) given \(X\) and \(Z\), not \(X\) given \(Y\) and \(Z\). To obtain the latter, also specify a covariate distribution \(f(x\mid z)\). The probability factorization rule gives

$$ f(x\mid y,z)\ \propto\ f(y\mid x,z)\,f(x\mid z). $$

For the normal outcome model above, the outcome likelihood as a function of \(x\) is proportional to the exponential term below. Consequently, the conditional distribution that an exact imputation would need to represent is

$$ f(x\mid y,z)\ \propto\ f(x\mid z)\exp\!\left\{-\frac{[y-\eta(x,z)]^2}{2\sigma^2}\right\}. $$

This result follows directly from the normal density: its factor \(1/\sqrt{2\pi\sigma^2}\) does not depend on \(x\), so it cancels when the conditional density is normalized. The remaining likelihood factor depends on the spline-shaped mean \(\eta(x,z)\), and therefore generally has a nonlinear dependence on \(x\). The covariate distribution \(f(x\mid z)\) also contributes to the conditional shape.

This is why a normal linear imputation regression \(X\) on \(Y\) and \(Z\) is not automatically compatible with a spline outcome model. Even though \(Y\) appears in that imputation regression, the conditional distribution it specifies may not match the distribution implied by the spline likelihood and \(f(x\mid z)\). Compatibility concerns the whole conditional distribution, not merely which predictors appear in a formula.

Worked Example: A Compatibility Audit for Missing Age

In a hypothetical data set, 18% of ages are missing. The planned analysis regresses systolic blood pressure on age using the four-knot spline above, sex, and treatment group. A proposed chained-equations imputation model is a normal linear regression of age on blood pressure, sex, and treatment group.

Step 1: List the analysis relationship to preserve. The outcome mean contains age, \(U_1(\text{age})\), and \(U_2(\text{age})\), as well as sex and treatment group. The target is not just a linear age–blood-pressure association; it is the association represented by all three age basis terms.

Step 2: Check what the proposed model assumes. A normal linear regression for age assumes that the conditional mean of age is linear in blood pressure, sex, and treatment, and that the conditional residual distribution is normal with constant variance. Those assumptions may be reasonable approximations, but they do not establish that its conditional distribution agrees with the one implied by the spline outcome model.

Step 3: Identify what is needed to assess compatibility. The outcome likelihood depends on the age spline through \(\eta(\text{age},z)\). A compatible conditional for age must combine that likelihood with an adequate model for \(f(\text{age}\mid z)\). The ordinary linear imputation regression is not derived from that product, so compatibility has not been demonstrated.

Conclusion. Including blood pressure in the imputation model is preferable to omitting it, but this proposed model should not be called exactly compatible on that basis alone. A substantive-model-compatible approach can draw age using the outcome-model likelihood and an estimated covariate distribution; a carefully designed flexible conditional model may also be considered, with its assumptions made explicit.

A practical compatibility checklist

A useful audit begins with the substantive analysis specification and then checks whether the imputation procedure can represent its implications. For a missing spline covariate, use the following sequence.

1
Record the exact analysis terms.
Write the outcome distribution, the spline basis and knot locations, and all other main effects or interactions. Do not summarize a spline as merely “age included.”
2
State the assumptions.
For the normal derivation, check whether the conditional mean, normal errors, and constant variance are plausible. State what model is used for \(X\mid Z\), and whether its support and shape are suitable.
3
Compare the implied and implemented conditionals.
Ask whether the imputation model represents \(f(x\mid z)\exp\{-[y-\eta(x,z)]^2/(2\sigma^2)\}\), after normalization, or explain why a specified approximation is adequate for the goal.
4
Check estimation and iteration.
Ensure the imputation procedure reflects uncertainty in its parameters, and inspect whether the chained-equations draws and the imputed values behave plausibly across iterations and missingness patterns.
5
Revisit the analysis relationship after imputation.
Fit the planned spline analysis in each completed data set and examine whether the implied age–outcome pattern is plausible, especially across the observed age range and near the knots.

The checklist assumes that the variables required to model missingness and the analysis relationship have been handled appropriately. In particular, the imputation model needs relevant observed predictors of the missing covariate and outcome, and the missingness assumption must be defensible given the variables included. Compatibility cannot repair a poor missingness assumption, an incorrect substantive outcome model, or a covariate model with inadequate information.

Worked Example: Conditional Imputation Weights in a Small Hypothetical Model

To make the likelihood contribution concrete, consider a deliberately simple hypothetical covariate model in which age \(X\) can take only 30, 50, or 70 years, with prior probabilities \(0.30\), \(0.40\), and \(0.30\), respectively. Suppose the spline outcome model gives mean blood pressures of 14, 22, and 18 mmHg at those ages, and the residual standard deviation is 4 mmHg. For a person with observed blood pressure \(y=20\) mmHg, the conditional probability of each age is proportional to its prior probability multiplied by the normal likelihood.

The likelihood factor, omitting constants common to the three ages, is \(\exp\{-(y-\eta(x))^2/(2\sigma^2)\}\). At 30 years, the residual is \(20-14=6\) mmHg, giving a likelihood factor \(\exp(-36/32)=0.3247\). At 50 years, the residual is \(-2\) mmHg, giving \(\exp(-4/32)=0.8825\). At 70 years, the residual is \(2\) mmHg, also giving \(0.8825\).

$$ \begin{aligned} w_{30}&=0.30(0.3247)=0.09741,\\ w_{50}&=0.40(0.8825)=0.3530,\\ w_{70}&=0.30(0.8825)=0.2648,\\ \sum_x w_x&=0.7152. \end{aligned} $$

Normalizing gives \(P(X=30\mid Y=20)=0.09741/0.7152=0.1362\), \(P(X=50\mid Y=20)=0.3530/0.7152=0.4936\), and \(P(X=70\mid Y=20)=0.2648/0.7152=0.3702\). These sum to 1, up to rounding. This finite-support calculation illustrates how the outcome likelihood and covariate distribution jointly determine the imputation conditional; it is not a recommended continuous-age imputation model.

Diagnostics, alternatives, and limitations

Compatibility is a modeling property, not a diagnostic plot that can be checked once and then treated as proven. Still, several checks can reveal serious problems. Compare observed and imputed covariate distributions overall and within important outcome or covariate groups. Examine whether imputations are plausible and remain within defensible ranges. After fitting the planned spline model in completed data sets, inspect the estimated curve and its uncertainty across the observed support, rather than checking only a single linear coefficient. Large changes in the curve across imputation specifications, implausible tails, or poor mixing of chains warrant investigation.

The main approaches have different strengths and assumptions. A conventional conditional regression is relatively straightforward, but a simple linear-normal form may not represent the spline-implied conditional. Adding flexible terms to a conditional imputation model can improve approximation, but does not automatically make the conditional exactly compatible. Substantive-model-compatible fully conditional specification targets the conditional implied by the analysis model together with a covariate model; it is more tailored, but depends on correct specification and stable estimation of those components. Complete-case analysis avoids specifying an imputation model, but discards cases with missing covariates and may be inefficient or biased under relevant missingness mechanisms.

The derivation also has limits. It assumes the stated outcome model and a suitable \(f(x\mid z)\); neither is known with certainty. Sparse data near the tails or knots can make both spline estimation and imputation unstable. A fitted spline curve does not establish that the true relationship is spline-shaped. And no compatibility construction alone addresses missingness that depends on unobserved values after conditioning on observed data. These issues call for substantive judgment and sensitivity analysis, not merely a more elaborate imputation formula.

Common pitfall

Wrong reasoning: “The outcome is included as a predictor of the missing age, so the imputation model preserves the spline.”

Correction: Including the outcome helps retain outcome–covariate association, but it does not establish that the conditional distribution of age matches the one implied by the spline likelihood and the age distribution given other covariates. Write down both models and compare their implied conditionals. If they differ, describe the imputation as an approximation or use a method designed to target the substantive model.

Key takeaway: For a missing covariate in a restricted cubic spline outcome regression, audit the full spline basis and derive the conditional distribution implied by the outcome model and covariate distribution. “Outcome included” is a useful predictor check, not a compatibility proof.

Check Your Understanding

Answer each question, then compare with the brief solutions below.

  1. In a four-knot restricted cubic spline for \(X\), how many nonlinear basis terms accompany the linear term?
  2. Why is an ordinary normal regression of missing \(X\) on \(Y\) and \(Z\) not automatically compatible with a spline outcome model?
  3. For \(Y\mid X,Z\sim N(\eta(X,Z),\sigma^2)\), state the conditional density for imputing \(X\), up to proportionality.
  4. In the finite-support example, why does the 50-year candidate receive more conditional weight than the 30-year candidate, despite having only a modestly larger prior probability?
  5. Name one diagnostic that could reveal a problem with the imputed spline relationship, and one limitation that the diagnostic cannot resolve.

Solutions. (1) There are \(K-2=2\) nonlinear terms. (2) Its conditional shape need not equal the product of the spline outcome likelihood and \(f(x\mid z)\); including \(Y\) alone does not establish equality. (3) \(f(x\mid y,z)\propto f(x\mid z)\exp\{-[y-\eta(x,z)]^2/(2\sigma^2)\}\). (4) The 50-year candidate has a smaller absolute outcome residual and hence a larger likelihood factor: \(0.8825\) versus \(0.3247\), as well as a larger prior probability. (5) One may compare fitted spline curves across completed data sets or inspect imputed values near the support boundaries. Such checks cannot determine whether missingness depends on unobserved values after conditioning on observed data.

Clinical Biostats