Why Residualize Both Outcome and Treatment?
A conditional treatment-effect learner aims to estimate how the effect of treatment varies with covariates. The challenge is that an observed outcome reflects both treatment and the prognostic differences among people with different covariates. The R-learner separates these components by subtracting covariate-specific expectations from both the outcome and the treatment indicator. Its loss then compares the residual outcome with the residual treatment multiplied by a candidate effect function.
Let \(W\in\{0,1\}\) denote treatment, let \(X\) denote covariates, and let \(Y\) be the observed outcome. Write \(Y(1)\) and \(Y(0)\) for the potential outcomes under treatment and control. The target is the conditional average treatment effect, or CATE, \(\tau(x)=E[Y(1)-Y(0)\mid X=x]\). The R-learner is a way to fit this target using observed data; its causal interpretation depends on identification assumptions, not on the loss alone.
The word “residual” means a value minus its conditional expectation given \(X\). Thus \(Y-m(X)\) is the outcome residual and \(W-e(X)\) is the treatment residual. The outcome regression \(m\) is not the untreated outcome regression: it averages outcomes over the treatment assignment pattern at each covariate value.
Deriving the Residualized Equation
For the CATE to have a causal interpretation from observed data, assume consistency, conditional exchangeability, and positivity. Consistency means the observed outcome is \(Y=Y(W)\). Conditional exchangeability means \((Y(1),Y(0))\) is independent of \(W\) given \(X\). Positivity means \(0<e(X)<1\) on the covariate values in the target population. These assumptions identify the conditional effect as the treatment-control contrast in conditional outcome means.
Let \(\mu_w(x)=E[Y\mid W=w,X=x]\). Under these conditions, \(\tau(x)=\mu_1(x)-\mu_0(x)\). Because \(W\) is binary, conditioning on \(X=x\) gives
The conditional mean of \(Y\) given \(W\) and \(X=x\) is \(\mu_0(x)+W\tau(x)\). Subtracting \(m(x)\) therefore yields
This identity motivates the R-loss: after removing the covariate-specific mean from the outcome, the remaining conditional mean is the treatment residual multiplied by the conditional effect. The loss fits that relationship. It does not require directly fitting separate treated and control outcome models at every covariate value.
Worked Example: Checking the Residual Equation at One Covariate Value
Suppose at a particular covariate value \(x\), the conditional control mean is 10 outcome units, the conditional treated mean is 14 outcome units, and the treatment probability is 0.25. Then \(\tau(x)=14-10=4\), and
For a treated observation, the treatment residual is \(1-0.25=0.75\), so its conditional mean outcome residual is \(14-11=3\). The right side of the residual equation is \(0.75(4)=3\), as required. For a control observation, the treatment residual is \(0-0.25=-0.25\), and the conditional mean outcome residual is \(10-11=-1\). The right side is \((-0.25)(4)=-1\). Both treatment groups satisfy the identity.
These are conditional means, not claims that every individual outcome equals its conditional mean. Individual outcomes can also contain noise.
The R-Learner Objective and Its Target
With data \((Y_i,W_i,X_i)\), estimate \(m\) and \(e\), and denote their fitted values by \(\hat m(X_i)\) and \(\hat e(X_i)\). The empirical R-loss is
Minimize this loss over a specified function class, possibly with a regularization penalty. Regularization constrains or penalizes complexity; it does not change the residualization identity. The fitted function is shaped by the candidate class and the data, so it need not equal the true CATE when that class cannot represent it.
The population loss also shows exactly how treatment overlap matters. Write \(U=Y-E[Y\mid W,X]\), which has conditional mean zero given \(W,X\). Then \(Y-m(X)=(W-e(X))\tau(X)+U\). For a candidate \(g\), expand the squared residual and take conditional expectation:
The cross term vanishes because \(E[U\mid W,X]=0\). For binary treatment, \(E[(W-e(X))^2\mid X]=e(X)\{1-e(X)\}\). Thus the loss targets the true CATE wherever it is represented, but gives greater weight to covariate values with more treatment variation. Where treatment is nearly deterministic, the treatment residual is usually small and the data provide less information about the effect.
Worked Example: Fitting Effects in Two Covariate Strata
Consider the following hypothetical observations. Let \(X=0\) or \(X=1\), with two controls and two treated participants in each stratum. Outcomes are measured in arbitrary units.
| Covariate stratum | Treatment \(W\) | Observed outcomes \(Y\) |
|---|---|---|
| \(X=0\) | 0 | 2, 4 |
| \(X=0\) | 1 | 5, 7 |
| \(X=1\) | 0 | 5, 7 |
| \(X=1\) | 1 | 7, 9 |
Within each stratum, the fitted propensity is \(\hat e(x)=2/4=0.5\). The outcome means are \(\hat m(0)=(2+4+5+7)/4=4.5\) and \(\hat m(1)=(5+7+7+9)/4=7\). Fit a separate constant effect in each stratum by minimizing the squared R-residuals there. For a constant \(g\), differentiating the sum of squared residuals and setting the derivative to zero gives
At \(X=0\), the outcome residuals are \(-2.5,-0.5,0.5,2.5\), and the treatment residuals are \(-0.5,-0.5,0.5,0.5\), in the order listed. The numerator is \(1.25+0.25+0.25+1.25=3\), and the denominator is \(4(0.25)=1\). Thus \(\hat g(0)=3/1=3\) outcome units.
At \(X=1\), the outcome residuals are \(-2,0,0,2\), with the same treatment residuals. The numerator is \(1+0+0+1=2\), and the denominator is again 1. Thus \(\hat g(1)=2/1=2\) outcome units. These fitted stratum effects match the differences in the displayed treated and control means: \(6-3=3\) at \(X=0\), and \(8-6=2\) at \(X=1\). This small, balanced example illustrates the calculation; it does not establish uncertainty or generalize the estimates to a population.
Orthogonality: What It Protects Against
In applications, \(m\) and \(e\) are usually estimated rather than known. The R-learner’s orthogonalized estimating equation reduces the first-order effect of errors in those nuisance estimates. Define the score for a candidate \(\tau\) as
At the true functions, its conditional expectation is zero when \(\tau\) is the CATE. Orthogonality means that small perturbations of \(m\) or \(e\) do not change the expectation of this score to first order at the truth. To verify this, perturb \(m\) by \(r h(X)\), where \(h\) is any fixed function and \(r\) is a scalar. The derivative of the conditional expected score at \(r=0\) is
because \(E[W-e(X)\mid X]=0\). For a perturbation of \(e\) by \(r k(X)\), differentiating the score at \(r=0\) gives the conditional expectation of \(-k(X)\{Y-m(X)-2(W-e(X))\tau(X)\}\). At the true functions, both \(E[Y-m(X)\mid X]=0\) and \(E[W-e(X)\mid X]=0\), so this derivative is also zero.
This is a local robustness property of the estimating equation, not a guarantee that nuisance estimates can be arbitrary. Poor overlap, severe model misspecification, excessive overfitting, or violations of causal identification assumptions can still undermine an analysis. In practice, nuisance estimates should be learned carefully, and flexible nuisance fitting is commonly paired with sample splitting or cross-fitting to limit overfitting effects. Orthogonality reduces sensitivity to small nuisance errors; it does not remove the need to estimate them adequately.
Worked Example: A Constant Fit Can Emphasize Overlap
Suppose a population has two equally common covariate strata. Their true effects are 4 and 1 outcome units, while their treatment probabilities are 0.5 and 0.1, respectively. If the fitted effect is constrained to be a single constant \(c\), the population R-loss is minimized by minimizing the effect-dependent part
The weights are \(0.125\) and \(0.045\). Setting the derivative with respect to \(c\) to zero gives the weighted mean
outcome units. The equally weighted average of the two stratum effects is \(2.5\) units, not \(3.206\). The constant R-loss fit is instead weighted by stratum frequency times \(e(x)\{1-e(x)\}\); the stratum with treatment probability 0.5 carries more information about the contrast than the stratum with treatment probability 0.1. The result is a projection chosen by the loss and function class, not automatically the population average treatment effect.
Common Mistakes and Practical Interpretation
- Using the wrong outcome regression. The R-learner residualizes \(Y\) using \(m(x)=E[Y\mid X=x]\), not just the control mean. Its identity relies on the corresponding treatment residual \(W-e(X)\).
- Assuming residualization creates causal identification. Subtracting fitted values does not fix unmeasured confounding. Consistency, conditional exchangeability, and positivity remain necessary for a causal CATE interpretation.
- Ignoring the treatment-residual scale. When \(e(X)\) is near zero or one, \(W-e(X)\) has little conditional variation. Effects in such regions are weakly informed and can be unstable.
- Calling every fitted constant an average treatment effect. A constant R-loss fit is weighted by treatment variation and the covariate distribution. It equals a particular projection under the chosen loss, and need not equal an equally weighted or population-average causal effect.
- Interpreting orthogonality as immunity to nuisance error. First-order insensitivity is not exact finite-sample protection. Large nuisance errors or poor overlap can still cause substantial problems.
Check Your Understanding
Use the definitions and calculations in this tutorial to answer the following.
- In one sentence, distinguish the outcome regression \(m(x)\) from the propensity score \(e(x)\).
- If \(e(x)=0.4\) and \(\tau(x)=5\), what conditional mean does the residual equation predict for \(Y-m(X)\) among treated observations? What about controls?
- Why does the R-loss give less weight to effect errors at covariate values where \(e(x)\) is near zero or one?
- For a constant-effect fit over several covariate strata, what determines each stratum’s contribution to the effect-dependent part of the population loss?
- What does orthogonality say about small nuisance-estimation errors, and what important causal assumption does it not replace?