Tutorials › Econometrics (Graduate) › Inference With Estimated Control Functions

Endogeneity and Control Functions · Tutorial 236 of 952

Inference With Estimated Control Functions

Learn how first-stage estimation enters control-function variance and how to obtain inference that accounts for it.

Advanced 12 min read

What You'll Learn

  • State the two-step linear control-function model and its identification and regularity conditions.
  • Derive the first-stage contribution to the control-function estimator’s influence function.
  • Construct a sandwich covariance from the stacked first- and second-stage estimating equations.
  • Explain why a second-stage standard error that treats residuals as fixed can miss uncertainty.
  • Use a bootstrap that re-estimates the first stage and residuals in every resample.
  • Interpret confidence intervals and tests using the resulting standard errors.

Why Estimated Residuals Affect Inference

In a linear control-function analysis, the first stage produces residuals that are then included in an outcome regression. Those residuals are not directly observed: they depend on estimated first-stage coefficients. The outcome regression therefore uses generated regressors. Its coefficient estimates can be consistent under suitable assumptions, but uncertainty from estimating the residuals also belongs in the variance calculation.

This tutorial considers a single endogenous regressor in a linear outcome equation. The central inference question is not whether to include a control function, but how to calculate uncertainty after estimating it. In particular, a second-stage regression calculation that holds the generated residuals fixed need not describe the sampling variation of the complete two-step estimator.

Model and assumptions: Let \(y_i\) be an outcome, \(d_i\) an endogenous regressor, \(x_i\) a vector of included exogenous regressors, and \(z_i\) a vector of excluded instruments. Write \(w_i=(x_i',z_i')'\). The first stage is \(d_i=w_i'\pi+v_i\), and the outcome equation is \(y_i=x_i'\beta_x+\beta_d d_i+\rho v_i+u_i\). The first-stage conditional mean is correctly specified; the control-function outcome restriction is valid; the instruments and included exogenous variables identify the first stage; and the relevant moment matrices are nonsingular. For the formulas below, observations are independent and identically distributed with finite second moments. For clustered data, the independent sampling units and covariance calculation must instead be defined at the cluster level.

Here \(v_i\) is the population first-stage disturbance and \(\hat v_i=d_i-w_i'\hat\pi\) is its estimated counterpart. The second-stage regression uses \(\hat v_i\), not \(v_i\). The coefficient \(\rho\) captures the part of the outcome disturbance represented by the control function under the stated model. The coefficient of primary interest is often \(\beta_d\), interpreted as a conditional linear effect only under the model’s substantive assumptions; a control-function regression does not by itself establish causality.

Where the Additional Variance Enters

Let \(q_i(\pi)=(x_i',d_i,d_i-w_i'\pi)'\) be the second-stage regressor vector, and let \(\gamma=(\beta_x',\beta_d,\rho)'\). At the true first-stage parameter, the second-stage error is \(u_i=y_i-q_i(\pi)'\gamma\). The two stages can be written together as estimating equations: the outcome equation sets the sample average of \(q_i(\pi)u_i\) to zero, while the first stage sets the sample average of \(w_i(d_i-w_i'\pi)\) to zero.

$$ \frac{1}{n}\sum_{i=1}^n \begin{pmatrix} q_i(\pi)\{y_i-q_i(\pi)'\gamma\}\\ w_i(d_i-w_i'\pi) \end{pmatrix} = \begin{pmatrix} 0\\ 0 \end{pmatrix}. $$

The first equation depends on \(\pi\) through the estimated residual. To see the consequence, let \(e_r\) be a vector with a one in the control-function coordinate of \(q_i\) and zeros elsewhere. Then \(\partial q_i/\partial\pi'=-e_r w_i'\). Differentiating the outcome moment \(q_i u_i\) with respect to \(\pi\) gives

$$ D_i = \frac{\partial(q_i u_i)}{\partial\pi'} = -e_r w_i' u_i+\rho q_i w_i'. $$

The first term reflects the change in the residual regressor itself; the second reflects the resulting change in the fitted outcome error. Thus, uncertainty in \(\hat\pi\) affects the second-stage moments even when the outcome regression is otherwise correctly specified.

A First-Order Variance Derivation

The derivation makes the correction explicit. Define \(Q=E[q_iq_i']\), \(R=E[w_iw_i']\), and \(D=E[D_i]\), evaluated at the true parameters. Assume \(Q\) and \(R\) are invertible. A first-order expansion of both sample moment equations around \((\gamma,\pi)\) gives the following influence function for the second-stage coefficient vector:

$$ \operatorname{IF}_{\gamma,i} = Q^{-1}\left[ q_i u_i+D R^{-1}w_i v_i \right]. $$

To verify the expression, the first-stage equation yields \(\operatorname{IF}_{\pi,i}=R^{-1}w_i v_i\). The outcome equation has derivative \(-Q\) with respect to \(\gamma\), and derivative \(D\) with respect to \(\pi\). Its first-order expansion is therefore \(0=q_i u_i-Q\,\operatorname{IF}_{\gamma,i}+D\,\operatorname{IF}_{\pi,i}\). Solving for \(\operatorname{IF}_{\gamma,i}\) gives the displayed formula. The variance of the estimator is approximately the variance of this influence function divided by \(n\). This derivation identifies precisely the first-stage contribution: it is not an arbitrary penalty, but the effect of first-stage estimation on the outcome moments.

Sandwich result: Estimate the covariance using the stacked first- and second-stage estimating equations, including their cross-covariance. If \(m_i\) denotes the stacked moment vector and \(\hat A\) its sample derivative matrix, a general sandwich estimate is \(n^{-1}\hat A^{-1}\hat B(\hat A^{-1})'\), where \(\hat B=n^{-1}\sum_i m_i m_i'\). Extract the block for \(\gamma\) to obtain the covariance estimate for the outcome coefficients. The influence-function formula above is the corresponding first-order result for the linear system.

This is a heteroskedasticity-robust form when the moment covariance is estimated from observation-level outer products. Under independent clusters, form cluster-level sums of moments before calculating \(\hat B\). If a homoskedastic model is imposed, a specialized covariance expression may be available, but that assumption must be justified rather than inferred from the use of ordinary least squares. In all cases, the first-stage and second-stage moments must be treated as parts of the same estimator.

Worked Example: Size of a First-Stage Variance Contribution

Suppose a hypothetical sample has \(n=100\) independent observations. After applying the influence-function calculation to the coefficient of \(d_i\), suppose the estimated contribution from the outcome moments has variance \(0.0400\), the first-stage contribution has variance \(0.0100\), and their estimated covariance is zero. These are illustrative variance components on the influence-function scale, not variances of the coefficient estimate itself.

Combine the components. For two uncorrelated contributions, the total influence-function variance is \(0.0400+0.0100=0.0500\). The standard error of the estimated coefficient is therefore \(\sqrt{0.0500/100}=\sqrt{0.000500}=0.02236\).

Compare with the fixed-residual calculation. A calculation that uses only the outcome-moment component would give \(\sqrt{0.0400/100}=\sqrt{0.000400}=0.02000\). It is smaller because it omits the stated first-stage contribution. In a real analysis the components need not be uncorrelated; the full sandwich includes their covariance rather than assuming it is zero.

The arithmetic illustrates why the correction matters, not a universal direction or percentage increase. Depending on the covariance between components, a full variance estimate can differ from a fixed-residual calculation in either direction.

Sandwich Inference in Practice

A practical implementation should retain the dependence between stages rather than treating \(\hat v_i\) as measured data. One route is to evaluate the stacked moments and their derivative matrix directly. Another is to implement the influence-function calculation using estimated quantities. The resulting covariance estimate is then used for standard errors, confidence intervals, and tests.

1
Estimate the first stage.
Regress \(d_i\) on \(w_i\), using the specified first-stage model, and save \(\hat\pi\) and \(\hat v_i=d_i-w_i'\hat\pi\).
2
Estimate the outcome equation.
Regress \(y_i\) on \(x_i\), \(d_i\), and \(\hat v_i\). The coefficient on \(d_i\) estimates \(\beta_d\) under the maintained control-function assumptions.
3
Build the joint covariance.
Evaluate both stages’ moments, their derivatives, and the moment covariance using the appropriate independent unit. Include the first-stage derivative of the outcome moments.
4
Report inference in context.
Use the relevant diagonal element for the coefficient variance, report its standard error and units, and form confidence intervals or tests using the stated asymptotic approximation.

For example, if \(\hat\beta_d=2.40\) outcome units per unit of \(d_i\) and its full-sandwich standard error is \(0.30\), an approximate 95% large-sample confidence interval is \(2.40\pm1.96(0.30)\), or \([1.812,2.988]\) outcome units per unit of \(d_i\). Under the model and regularity conditions, this procedure has approximately 95% coverage across repeated samples. It does not mean there is a 95% probability that the fixed parameter lies in this particular interval.

Bootstrap Inference: Repeat the Whole Procedure

A bootstrap can estimate the sampling variation without relying solely on a plug-in sandwich formula, provided each resample reproduces the estimator that would be applied to new data. For independent observations, draw observations with replacement; in each bootstrap sample, estimate the first stage, construct new residuals, and fit the outcome equation again. For clustered data, resample independent clusters instead. The bootstrap standard error is the sample standard deviation of the bootstrap coefficient estimates.

The essential rule is to re-estimate the first stage in every resample. Resampling only the outcome regression while keeping the original \(\hat v_i\) fixed conditions on the estimated first stage and fails to reproduce the full two-step sampling variation. Bootstrap inference still requires suitable sampling and regularity conditions; it does not repair weak identification, a misspecified control-function model, or an invalid instrument.

Worked Example: Calculating a Bootstrap Standard Error

Suppose five hypothetical bootstrap resamples each repeat both stages and produce estimates of the coefficient on \(d_i\): \(1.12,\ 0.98,\ 1.05,\ 1.09,\ 0.96\). These few resamples are used only to show the arithmetic; an actual analysis would use many more.

The bootstrap mean is \((1.12+0.98+1.05+1.09+0.96)/5=1.04\). The squared deviations from this mean are \(0.0064,\ 0.0036,\ 0.0001,\ 0.0025,\) and \(0.0064\). Their sum is \(0.0190\), so the sample variance is \(0.0190/(5-1)=0.004750\).

The bootstrap standard error is \(\sqrt{0.004750}=0.06892\) outcome units per unit of \(d_i\). This estimate reflects variation in both stages because each resample re-estimated \(\hat\pi\) and reconstructed the residuals. With only five draws it would be too imprecise to rely on for substantive inference.

When the Fixed-Regressor Standard Error Misleads

An ordinary second-stage regression calculation conditions on the residual values supplied to that regression. It can therefore omit the change in the outcome moments caused by a different first-stage estimate. When that omitted component is material, the reported standard error can be too small and confidence intervals too narrow. As the variance decomposition showed, the full correction also includes covariance terms, so it is not a theorem that every fixed-residual standard error must be smaller in every sample or model.

In the linear setting, there is an important connection to instrumental-variables estimation: with the same included exogenous regressors and first-stage projection, the coefficient on \(d_i\) in the residual-inclusion regression equals the corresponding just-identified projected-regressor coefficient. That algebraic equivalence does not justify using an arbitrary second-stage OLS covariance. Inference must still use a covariance estimator appropriate to the full estimator and its assumptions.

Worked Example: Choosing the Reported Standard Error

A hypothetical analysis estimates a coefficient of \(1.60\) outcome units per unit of \(d_i\). The second-stage output, treating residuals as fixed, reports a standard error of \(0.20\). A stacked heteroskedasticity-robust covariance calculation gives \(0.27\), and a bootstrap that re-estimates both stages gives \(0.26\).

The fixed-residual value does not account for the full generated-regressor procedure, so it is not the appropriate default for inference about the two-step estimator. The two full-procedure estimates are similar here, though agreement in one application is not guaranteed. If the robust sandwich is justified by the sampling assumptions, using \(0.27\) gives the approximate 95% interval \(1.60\pm1.96(0.27)=[1.071,2.129]\) outcome units per unit of \(d_i\). The interval’s interpretation is based on repeated-sampling coverage, not a probability statement about the fixed coefficient.

Common Pitfall

  • Wrong reasoning: “The residuals are now columns in my outcome data set, so the usual second-stage standard errors account for them.”
  • Correction: The residual values depend on \(\hat\pi\), which was estimated from the same sample. Use a joint sandwich or a bootstrap that re-estimates the first stage and reconstructs the residuals. State the sampling unit and the assumptions behind the covariance calculation.
Key takeaway: Inference for a linear control-function estimator must account for the fact that its residual regressor was estimated. The stacked sandwich makes the first-stage contribution explicit; a full-procedure bootstrap reproduces it by repeating both stages in every resample.

Check Your Understanding

Use the model, derivation, and examples above to answer the following.

  1. Why does the outcome-moment derivative with respect to \(\pi\) enter the variance of \(\hat\gamma\)?
  2. What is the first-stage influence function under the stated linear first-stage moment condition?
  3. If the first-stage and outcome contributions to an influence function have nonzero covariance, why is it incorrect to add only their variances?
  4. What must be re-estimated in each bootstrap sample for inference on the two-step coefficient?
  5. Does the full sandwich variance have to be larger than the fixed-residual variance? Explain.
Clinical Biostats