Tutorials › Propensity Score Matching and Instrumental Variables › Generalized Residuals For Nonlinear First Stages

Binary and Nonlinear Outcome IV Methods · Tutorial 562 of 699

Generalized Residuals For Nonlinear First Stages

Learn how to derive and diagnose generalized residuals for binary and count first stages, and why their choice matters when included in a nonlinear outcome model.

Advanced 12 min read

What You'll Learn

  • Derive the probit generalized residual from a latent-normal treatment model.
  • Distinguish a likelihood-score residual from a raw treatment residual and a latent-error conditional expectation.
  • Derive generalized residuals for Poisson and negative-binomial count first stages.
  • Compare nonlinear second-stage predictions using different residual choices.
  • Identify assumptions, diagnostics, and limitations of generalized-residual control functions.

Why the First-Stage Residual Needs Care

In a linear first stage, the ordinary residual is a natural measure of how far an observed treatment differs from its fitted value. With binary or count treatments, however, a residual’s meaning depends on the first-stage probability model. A binary treatment residual \(D-\hat p\) is bounded, while an appropriate probit control function can take much larger positive or negative values when the fitted probability is near zero or one. For a count model, the score residual may coincide with the raw residual under one model and differ from it under another.

These distinctions matter when a residual is included in a nonlinear outcome model. A nonlinear link does not generally make different residuals interchangeable: holding the outcome-model coefficients fixed, changing the residual changes the fitted index and therefore the fitted mean or probability. The residual must be justified by the first-stage model and the control-function assumptions, not selected just because it is easy to calculate.

Definition: A generalized residual is a residual-like quantity derived from a specified nonlinear first-stage model. A common definition is the individual score contribution with respect to the first-stage linear predictor. In models with a latent-error interpretation, a generalized residual may instead be an appropriate conditional expectation of that latent error. These definitions can coincide, but they are not interchangeable in every model.

Binary Treatment: The Probit Generalized Residual

Let \(D_i\) be a binary treatment, \(X_i\) observed covariates, and \(Z_i\) an excluded instrument. A probit first stage specifies \(D_i=1[\eta_i+u_i>0]\), where \(\eta_i=X_i^\top\gamma_X+Z_i^\top\gamma_Z\) and \(u_i\mid X_i,Z_i\sim N(0,1)\). Thus \(p_i=P(D_i=1\mid X_i,Z_i)=\Phi(\eta_i)\). This specification fixes the latent-error scale at one.

Under that model, the conditional expectation of the latent error is a natural control-function quantity. For a treated observation, \(u_i>-\eta_i\); for an untreated observation, \(u_i\leq-\eta_i\). The truncated-normal expectations give:

$$ E(u_i\mid D_i,X_i,Z_i) = \begin{cases} \displaystyle \frac{\phi(\eta_i)}{\Phi(\eta_i)},&D_i=1,\\[6pt] \displaystyle -\frac{\phi(\eta_i)}{1-\Phi(\eta_i)},&D_i=0. \end{cases} $$

Writing \(p_i=\Phi(\eta_i)\), this can also be written as \(r_{gi}=\phi(\eta_i)(D_i-p_i)/\{p_i(1-p_i)\}\). This is also the Bernoulli probit log-likelihood score with respect to \(\eta_i\). It is not simply \(D_i-p_i\): the denominator rescales the raw discrepancy according to the fitted probability.

Worked Example: Probit Residuals and a Logit Outcome Model

Suppose a hypothetical probit first stage gives \(\eta=0.5244\), with \(p=\Phi(0.5244)\approx0.7000\) and \(\phi(0.5244)\approx0.3477\). Compare generalized and raw residuals for one treated and one untreated person. Then use each residual in the illustrative second-stage logit index \(\eta_Y=-1+0.6r\). The outcome-model coefficients are held fixed only to show how the residual choice changes predictions.

For the treated person, \(D=1\), so the generalized residual is \(r_g=0.3477/0.7000\approx0.4967\). The raw residual is \(D-p=1-0.7000=0.3000\). The generalized-residual index is \(-1+(0.6)(0.4967)\approx-0.7020\), giving fitted probability \(1/\{1+\exp(0.7020)\}\approx0.3314\). With the raw residual, the index is \(-1+(0.6)(0.3000)=-0.8200\), giving probability \(1/\{1+\exp(0.8200)\}\approx0.3058\).

For the untreated person, \(D=0\), so \(r_g=-0.3477/(1-0.7000)\approx-1.159\), whereas the raw residual is \(0-0.7000=-0.7000\). The generalized-residual index is \(-1+(0.6)(-1.159)\approx-1.6954\), with fitted probability \(1/\{1+\exp(1.6954)\}\approx0.1551\). The raw-residual index is \(-1+(0.6)(-0.7000)=-1.420\), with fitted probability \(1/\{1+\exp(1.420)\}\approx0.1947\). These are conditional predictions under the illustrative outcome model, not estimates of causal effects by themselves.

Score Residuals for Binary and Count First Stages

The score definition gives a useful way to derive residuals systematically. For a Bernoulli first stage with fitted probability \(p_i\), the contribution to the log likelihood is \(D_i\log(p_i)+(1-D_i)\log(1-p_i)\). Differentiating with respect to the linear predictor \(\eta_i\) gives:

$$ \frac{\partial \ell_i}{\partial\eta_i} = \frac{D_i-p_i}{p_i(1-p_i)} \frac{\partial p_i}{\partial\eta_i}. $$

For probit, \(\partial p_i/\partial\eta_i=\phi(\eta_i)\), producing the generalized residual above. For logit, \(p_i=1/\{1+\exp(-\eta_i)\}\) and \(\partial p_i/\partial\eta_i=p_i(1-p_i)\); cancellation leaves \(D_i-p_i\). Thus the logit likelihood-score residual equals the raw binary residual, while the probit score generally does not. This equality does not establish that the logit residual is a conditional expectation of a latent error; that interpretation requires a specified latent-error model.

For a Poisson count first stage with a log link, \(Y_i\mid X_i,Z_i\sim\operatorname{Poisson}(\mu_i)\), where \(\log(\mu_i)=\eta_i\). Differentiating the log likelihood \(Y_i\eta_i-\exp(\eta_i)-\log(Y_i!)\) with respect to \(\eta_i\) gives \(Y_i-\mu_i\). Here the score residual is the raw response residual.

The equality need not hold for another count distribution. Under the negative-binomial NB2 parameterization, \(E(Y_i\mid X_i,Z_i)=\mu_i\) and \(\operatorname{Var}(Y_i\mid X_i,Z_i)=\mu_i+\alpha\mu_i^2\), with \(\alpha>0\). For a log link, the score with respect to \(\eta_i=\log\mu_i\) is:

$$ r_{gi}=\frac{Y_i-\mu_i}{1+\alpha\mu_i}. $$

The denominator reflects the overdispersed likelihood. This score residual is not generally the raw residual \(Y_i-\mu_i\), nor is it automatically the conditional expectation of an unobserved treatment disturbance. Its usefulness as a control function depends on the triangular model and the assumptions connecting first-stage unobservables to outcome unobservables.

Worked Example: Negative-Binomial Treatment Count

Consider a hypothetical count treatment with NB2 first-stage index \(\eta=0.7\), dispersion \(\alpha=0.5\), and observed count \(Y=4\). Its fitted mean is \(\mu=\exp(0.7)\approx2.0138\). Compare the raw and score residuals, then put each into the illustrative logit outcome index \(\eta_Y=-0.4+0.25r\).

The raw residual is \(Y-\mu=4-2.0138=1.9862\). The negative-binomial score residual is \(r_g=(4-2.0138)/\{1+(0.5)(2.0138)\}=1.9862/2.0069\approx0.9897\).

Using the score residual gives \(\eta_Y=-0.4+(0.25)(0.9897)\approx-0.1526\), so the fitted probability is \(1/\{1+\exp(0.1526)\}\approx0.4619\). Using the raw residual gives \(\eta_Y=-0.4+(0.25)(1.9862)\approx0.0966\), and fitted probability \(1/\{1+\exp(-0.0966)\}\approx0.5241\). The difference demonstrates sensitivity to residual construction with the coefficients held fixed; an actual analysis would estimate the second-stage coefficients using its chosen control function.

Worked Example: A Logit First-Stage Score

Suppose a hypothetical logit first stage gives \(p=0.80\) for an observation with \(D=1\). The logit score residual is \(D-p=1-0.80=0.20\), exactly the raw residual. For an observation with the same fitted probability but \(D=0\), both quantities are \(0-0.80=-0.80\). This equality follows from the logit link derivative cancelling the Bernoulli likelihood denominator. It does not imply that either value equals the conditional expectation of a logistic latent disturbance; the score and a latent-error expectation are different objects unless a model establishes their equivalence.

When Residual Inclusion Has a Control-Function Interpretation

A generalized residual is not a stand-alone correction for endogeneity. A control-function analysis needs a defensible first-stage model and a structural outcome specification. In broad terms, the instrument must be relevant for treatment, excluded from the outcome equation conditional on covariates, and conditionally exogenous. The first-stage distribution and link must adequately describe treatment given the covariates and instruments. The outcome model must also allow the relevant dependence between treatment and outcome unobservables to be represented by the included control function.

For a binary probit treatment with the latent-normal specification above, the conditional expectation of \(u_i\) has a direct derivation and interpretation. A nonlinear second stage may include \(D_i\), \(X_i\), and \(r_{gi}\) in its index, with a link appropriate to the outcome. For count treatments, a likelihood score can be a useful residual-like control, but it does not, by itself, prove that the score captures all dependence between the treatment and outcome disturbances. That claim requires additional structure. A correct first-stage likelihood alone does not guarantee a correct causal model.

The second-stage coefficient on treatment is conditional on the specified control-function model and link. In a nonlinear outcome model it is generally not a marginal risk difference or another population-average effect. Marginal interpretation requires an additional calculation under the fitted model; the residual’s inclusion does not make the index coefficient a marginal effect.

Diagnostics, Alternatives, and Limitations

Check the first stage before interpreting any second-stage result. Inspect whether fitted probabilities or means are plausible, whether the model represents the observed treatment distribution, and whether a few extreme fitted values dominate the residuals. For binary probit models, probabilities very near zero or one can produce large inverse-Mills-type terms; investigate their source rather than automatically truncating them. For counts, assess overdispersion and excess zeros where relevant, and compare plausible count distributions. A residual fitted from a misspecified likelihood can transmit that misspecification directly into the outcome model.

Also check whether the second-stage specification is sensitive to reasonable control-function choices, such as alternative first-stage links or distributions when substantively defensible. Such sensitivity is a warning about model dependence, not a way to select whichever result is preferred. Instrument relevance and exclusion require substantive and statistical assessment; residual plots cannot establish instrument validity. Because the first-stage residual is estimated, standard errors should account for that estimation, for example through a suitable joint sandwich calculation or a bootstrap that refits both stages.

ApproachWhat it usesMain caution
Raw residual inclusionObserved treatment minus its fitted valueMay not match the score or latent-error quantity implied by the first-stage model
Generalized-residual inclusionA model-based score or, under a specified latent model, a conditional latent-error expectationInterpretation depends on the chosen first-stage distribution and control-function assumptions
Predictor substitutionA fitted treatment predictor substituted into an outcome modelNonlinear substitution does not generally reproduce the needed conditional dependence adjustment
Joint likelihoodA specified joint model for treatment and outcomeCan be efficient if correct, but depends on its joint distributional assumptions

A frequent mistake is to assume that any first-stage residual will remove endogeneity because it measures “unexplained treatment.” That reasoning is incomplete: residuals from different links and distributions encode different information. Use the residual derived for the model and control-function argument being made, state what it represents, and acknowledge when it is only a score-based device rather than a derived latent-error conditional expectation.

Key takeaway: Derive the generalized residual from the first-stage likelihood or latent-error model. Probit, logit, Poisson, and negative-binomial models do not all produce the same residual. In a nonlinear second stage, that choice can change fitted outcomes and is part of the model specification.

Check Your Understanding

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

  1. For a probit first stage with \(p=0.25\) and \(\phi(\eta)=0.30\), calculate the generalized residual for an untreated observation.
  2. Why does the logit likelihood-score residual equal \(D-p\)?
  3. A Poisson first stage has observed count \(Y=5\) and fitted mean \(\mu=3\). Find its score residual. How does it compare with the raw residual?
  4. For an NB2 first stage with \(Y=5\), \(\mu=3\), and \(\alpha=0.5\), calculate the score residual.
  5. Does a fitted first-stage score residual by itself establish that an instrument is valid or that endogeneity has been removed? Explain.

Solutions. (1) For \(D=0\), \(r_g=-\phi(\eta)/(1-p)=-0.30/0.75=-0.4000\). (2) The Bernoulli score is \(\{(D-p)/[p(1-p)]\}(\partial p/\partial\eta)\); for logit, \(\partial p/\partial\eta=p(1-p)\), so the factors cancel and the score is \(D-p\). (3) The Poisson score residual is \(Y-\mu=5-3=2\), equal to the raw residual. (4) The NB2 score residual is \((5-3)/\{1+(0.5)(3)\}=2/2.5=0.8000\), not the raw residual of 2. (5) No. Instrument relevance, conditional exogeneity and exclusion, correct first-stage specification, and a valid control-function relationship with the outcome are separate requirements; a residual calculation cannot establish them on its own.

Clinical Biostats