Tutorials › Statistical Genetics › Control-Function Estimation for Nonlinear MR

Robust Mendelian Randomization · Tutorial 866 of 989

Control-Function Estimation for Nonlinear MR

Construct and interpret a residual-inclusion model for nonlinear MR, while checking the assumptions that make its causal interpretation credible.

Advanced 13 min read

What You'll Learn

  • Calculate first-stage residuals from an instrument–exposure model
  • Specify a nonlinear second-stage model that includes both observed exposure and its residual
  • Interpret residual inclusion in a binary-outcome logistic model
  • Distinguish adjustment by a control function from ordinary exposure stratification
  • Assess instrument, first-stage, and outcome-model assumptions
  • Recognize why residual inclusion does not automatically identify a causal dose–response curve

Why Use a Control Function?

Mendelian randomization (MR) often asks whether changing an exposure changes an outcome. If the exposure–outcome relationship is nonlinear, one target may be a dose–response curve rather than a single constant effect. The difficulty is that an observed exposure can be associated with unmeasured causes of the outcome. A flexible curve fitted directly to observed exposure and outcome does not, by itself, remove this endogeneity.

A control-function approach uses the instrument to model the exposure first, then carries information about the part of exposure not explained by the instrument into the outcome model. In the standard residual-inclusion construction, the second-stage model contains both the observed exposure and its first-stage residual. This is not the same as replacing exposure with its fitted value, nor is it simply a comparison of outcome rates within exposure strata.

Definition: A residual-inclusion control function is a term calculated from a first-stage model for the exposure, commonly the residual \(R=X-\hat{X}\). It is included alongside the observed exposure in a second-stage outcome model. Under suitable assumptions, \(R\) acts as a proxy for unmeasured determinants of exposure that also relate to the outcome.

Model and Identification Assumptions

Let \(Z\) denote a genetic instrument or genetic score, \(X\) a potentially endogenous exposure, \(Y\) an outcome, and \(C\) measured covariates such as ancestry variables and other prespecified confounders. A basic first-stage model for a continuous exposure is

$$ X_i=m(Z_i,C_i)+U_i, \qquad R_i=X_i-\widehat{m}(Z_i,C_i). $$

Here \(U_i\) represents the part of exposure not captured by the first-stage prediction. In a linear first stage, \(m(Z,C)\) is typically modeled using \(Z\) and \(C\), and \(R_i\) is the usual regression residual. The fitted residual is an estimate of \(U_i\), not a directly observed confounder.

For a binary outcome, one possible second-stage model is

$$ \operatorname{logit}\{P(Y_i=1\mid X_i,R_i,C_i)\} = \beta_0+f(X_i;\boldsymbol{\theta})+\lambda R_i+\boldsymbol{\gamma}^{T}C_i. $$

The function \(f\) can be nonlinear, for example a polynomial or a spline. The residual term may also need a more flexible form than a linear \(\lambda R_i\); its form should be chosen to represent the relevant dependence between the latent exposure component and the outcome. A linear residual term is an assumption, not a universal correction.

A causal interpretation requires more than fitting these two regressions. The genetic instrument must be relevant to exposure, independent of causes of the outcome conditional on \(C\), and have no path to the outcome except through the exposure. The exposure and outcome must be well-defined, with appropriate consistency and positivity conditions. The first-stage model must represent the instrument–exposure relationship adequately, and the residual must capture the relevant latent component. Finally, the second-stage functional form, including the exposure curve and residual adjustment, must be adequate. Control-function adjustment does not repair a violation of the instrument’s exclusion restriction.

One way to see the role of the residual is to consider an idealized setting where \(X=m(Z,C)+U\), so that the true residual is \(U\). Suppose that, after conditioning on \(U\) and \(C\), the outcome model has no additional dependence on \(Z\), and that the residual component is sufficient to account for the exposure–outcome dependence due to unmeasured causes. Then conditioning on \(U\) can make the exposure relationship estimable from the variation induced by \(Z\). In practice \(U\) is replaced by an estimated residual, so this argument also depends on adequate first-stage estimation and appropriate inference for a generated regressor.

Constructing and Interpreting the Residual

The residual is calculated from the exposure model, not from the outcome model. The outcome model then uses the observed exposure \(X\) and the residual \(R\) as separate predictors. The residual records whether an individual’s exposure is above or below the value predicted from the instrument and covariates. It does not label the individual as “treated” or “untreated,” and it is not itself a genetic effect estimate.

Worked Example: Calculating First-Stage Residuals

Suppose a hypothetical study fits the first-stage model \(\widehat{X}=1.0+0.5Z+0.2C\), where \(Z\) is a genetic instrument coded 0 or 1 and \(C\) is a covariate. The displayed coefficients are estimated using a larger study; the four rows below illustrate residual calculation.

Participant\(Z\)\(C\)Observed \(X\)Fitted \(\widehat{X}\)\(R=X-\widehat{X}\)
A001.21.00.2
B101.41.5-0.1
C011.11.2-0.1
D111.81.70.1

For participant B, the fitted exposure is \(1.0+0.5(1)+0.2(0)=1.5\), so \(R=1.4-1.5=-0.1\). For participant D, it is \(1.0+0.5(1)+0.2(1)=1.7\), so \(R=1.8-1.7=0.1\). Thus B’s observed exposure is 0.1 exposure units below its fitted value, while D’s is 0.1 units above. In an actual analysis, the first-stage model is fitted to the study data and the resulting residual is included for every participant in the outcome model.

A Binary-Outcome Example

With a binary outcome, logistic regression is a common second-stage choice. The coefficient of the residual describes its conditional association with the log odds of the outcome under the specified model. The nonlinear exposure term describes the fitted shape of the conditional log-odds curve, holding the residual and covariates fixed. Neither description alone guarantees that the fitted curve is causal; that interpretation depends on the assumptions above.

Worked Example: Residual Inclusion in a Logistic Model

Consider a hypothetical fitted model for a binary outcome. At a fixed reference value of \(C\), suppose

$$ \operatorname{logit}\{P(Y=1\mid X,R,C)\} = -2.0+0.50X+0.10X^2+0.80R. $$

For an individual with exposure \(X=2\) units and residual \(R=-0.7625\) exposure units, the fitted linear predictor is

$$ \eta=-2.0+0.50(2)+0.10(2^2)+0.80(-0.7625) =-2.0+1.0+0.4-0.61=-1.21. $$

The fitted probability is therefore

$$ \widehat{P}(Y=1\mid X=2,R=-0.7625,C) = \frac{1}{1+\exp(-\eta)} = \frac{1}{1+\exp(1.21)} = 0.2297. $$

This is a fitted conditional probability of about 22.97% at the stated exposure, residual, and covariate values. To see why the residual term matters to this particular prediction, setting \(R=0\) while keeping the other terms fixed gives \(\eta=-0.60\), and hence \(1/\{1+\exp(0.60)\}=0.3543\), or 35.43%. This comparison illustrates the model’s conditional adjustment; it is not a causal effect of changing the residual, and the \(R=0\) prediction is not automatically a population-average risk.

Why This Is Not Ordinary Stratification

Stratification-based nonlinear MR and residual inclusion address related concerns about nonlinear exposure effects, but they are not interchangeable procedures. Ordinary stratification groups people by observed exposure and compares outcomes across those groups. Because exposure may be affected by both the instrument and unmeasured causes of the outcome, conditioning on exposure can create or preserve differences in those causes between the groups. An exposure-stratum contrast is therefore not made causal merely by being calculated within a narrow range of exposure.

Residual inclusion instead models the instrument-related exposure process and carries a measure of the remaining exposure variation into the outcome model. It keeps observed \(X\) as the exposure whose response curve is modeled, while \(R\) serves as the control function. This distinction does not mean residual inclusion is assumption-free or universally preferable. Its validity relies on the first-stage and control-function assumptions, whereas stratification methods have their own identification requirements.

Worked Example: A Crude Exposure-Stratum Contrast

Suppose a hypothetical dataset has 40 people in a lower observed-exposure stratum, of whom 8 have the binary outcome, and 40 people in a higher stratum, of whom 18 have the outcome. The observed proportions are

$$ \hat{p}_{\text{low}}=\frac{8}{40}=0.20, \qquad \hat{p}_{\text{high}}=\frac{18}{40}=0.45. $$

The crude difference is \(0.45-0.20=0.25\), or 25 percentage points. This is a descriptive difference between the observed strata, not by itself an estimate of the causal effect of increasing exposure. If unmeasured causes of the outcome also influence exposure, people in the two strata can differ in those causes. A control-function analysis would additionally model exposure using \(Z\) and \(C\), calculate \(R\), and include \(R\) with \(X\) in an outcome model. It would still require the instrument, first-stage, and outcome-model assumptions to justify a causal interpretation.

Justification and Interpretation of the Two-Stage Construction

The logic can be stated as a short derivation. Assume, for illustration, that the first stage is correctly specified as \(X=m(Z,C)+U\). If \(m\) were known, then

$$ U=X-m(Z,C). $$

Suppose the outcome model is correctly specified conditional on the exposure, this latent component, and covariates, and has no direct dependence on the instrument once these are held fixed:

$$ P(Y=1\mid X,U,Z,C)=P(Y=1\mid X,U,C). $$

Then \(U\) is a sufficient control for the dependence between the exposure and outcome represented in this model: the outcome model can include \(X\) and \(U\) without adding a direct \(Z\) term. In observed data \(U\) is unavailable, so the fitted first-stage residual \(R=X-\widehat{m}(Z,C)\) is substituted. If the first stage is adequate and the control-function specification captures the relevant dependence, the second-stage exposure curve can be interpreted under the instrumental-variable assumptions. If these conditions fail, merely adding a residual does not establish the causal claim.

The derivation also clarifies why residual inclusion is not “two-stage least squares with a nonlinear link.” In ordinary residual inclusion, the second stage contains observed \(X\) and \(R\); it does not substitute \(\widehat{X}\) for \(X\). For nonlinear outcome models, the choice between residual inclusion and other IV estimators matters, and linear-model equivalences should not be assumed to carry over automatically.

Assumptions, Uncertainty, and Common Pitfalls

A credible analysis should check the construction and interpretation at each stage. First, \(Z\) must predict \(X\) conditional on \(C\); residual inclusion cannot create instrument relevance. Second, the first-stage form should represent the exposure distribution adequately. If exposure depends nonlinearly on the instrument or covariates, a simple linear fit can leave structure in \(R\). Third, the relationship of the latent exposure component to the outcome must be represented adequately by the residual term or its chosen flexible form. Finally, the exclusion restriction and independence assumptions remain essential.

Because \(R\) is estimated, treating it as if it were measured without error can understate uncertainty. Inference should account for first-stage estimation, for example by using a bootstrap that repeats both stages within each resample, or a suitable joint estimating-equation method. The bootstrap should resample independent study units and refit the first-stage model each time. The procedure’s validity still depends on the sampling design and model assumptions.

In logistic models, coefficients and probabilities are conditional on included covariates and the residual. The model’s conditional odds ratios should not automatically be read as population-average risk effects. Logistic probabilities are nonlinear in the predictors, so marginal risks generally require averaging predictions over a specified covariate and residual distribution. In particular, setting the residual to zero for everyone is not generally equivalent to averaging over the population.

  • Wrong: “The residual is just a nuisance, so the fitted exposure can replace observed exposure in the second stage.” Correction: Residual inclusion uses both observed \(X\) and the first-stage residual; replacing \(X\) changes the estimator and its interpretation.
  • Wrong: “The residual term corrects any genetic pleiotropy.” Correction: Residual inclusion does not remove a direct path from the genetic instrument to the outcome or otherwise repair a failed exclusion restriction.
  • Wrong: “A significant residual coefficient proves endogeneity has been completely corrected.” Correction: It indicates conditional residual association under the fitted model; it does not verify the first stage, residual functional form, or instrument assumptions.
  • Wrong: “The higher-exposure stratum’s larger outcome proportion is the causal dose response.” Correction: It is a descriptive contrast unless the method’s identification assumptions justify a causal interpretation.
Key takeaway: For nonlinear MR by residual inclusion, model exposure from the instrument and covariates, calculate the first-stage residual, then include that residual alongside observed exposure in the outcome model. The residual is a control function only under substantive and statistical assumptions; it is not a substitute for instrument validity or careful model checking.

Check Your Understanding

Use the model structure and assumptions in this tutorial to answer the following questions.

  1. For a first-stage fitted exposure of 3.4 units and an observed exposure of 3.1 units, what is the residual, and what does its sign mean?
  2. In a logistic residual-inclusion model, why are both observed exposure and the first-stage residual included?
  3. Name the three core instrumental-variable assumptions that remain necessary when using a control function.
  4. Why is a crude comparison of outcome proportions across observed-exposure strata not automatically a causal dose–response estimate?
  5. Why is setting the residual to zero not generally a population-average probability in a logistic model?
Clinical Biostats