Skip to content

Instrumental variables and endogeneity

Instrumental variables address a different problem from ordinary covariate adjustment.

Suppose treatment D and outcome Y share an unobserved cause U:

[ U \rightarrow D, \qquad U \rightarrow Y. ]

Even after conditioning on observed covariates, an OLS treatment coefficient can remain biased because D is endogenous.

A valid instrument Z creates treatment variation that is independent of that latent outcome process.

Baseline IV data-generating process

The repository uses an encouragement-style binary instrument.

Treatment is generated from a latent score:

[ S_i(0) = \beta_X X_i + \beta_U U_i + \nu_i, ]

and under encouragement,

[ S_i(1) = S_i(0) + \pi. ]

Potential treatment states are

[ D_i(0) = 1{S_i(0)>0}, \qquad D_i(1) = 1{S_i(1)>0}. ]

The observed treatment is D_i(Z_i).

For a non-negative encouragement shift,

[ D_i(1) \geq D_i(0) ]

for every unit. Monotonicity therefore holds by construction and there are no defiers.

The outcome model is

[ Y_i = \tau D_i + \gamma X_i + \delta U_i + \theta Z_i + \varepsilon_i. ]

In the valid baseline:

  • the encouragement shift is positive, giving instrument relevance;
  • Z is generated independently of U;
  • the direct instrument coefficient is zero, satisfying exclusion.

The treatment effect is constant in the baseline experiment. As a result, the complier LATE equals the population treatment effect. This is a convenience of the simulation, not a general property of IV.

Why naive OLS is biased

The analyst observes X but not U.

Because U affects both treatment and outcome, adjustment for X alone does not satisfy conditional exchangeability.

The repository therefore fits an observed-covariate-adjusted OLS benchmark before IV. In the default simulation its treatment coefficient is materially biased away from the known structural effect.

That comparison makes the reason for IV visible: it is not merely a different regression API.

Two-stage least squares

With one endogenous treatment and one instrument, 2SLS can be viewed as two linked regressions.

First stage

[ D_i = \alpha + \pi Z_i + X_i'\beta + v_i. ]

The first stage isolates the component of treatment variation associated with the instrument after conditioning on exogenous controls.

Second stage

The outcome is then related to the instrument-induced treatment variation.

In matrix form, 2SLS uses the projection of the endogenous regressor onto the instrument and exogenous-covariate space.

The implementation uses linearmodels.iv.IV2SLS and returns a small typed summary rather than exposing downstream code to library-specific result objects.

Identification assumptions

Relevance

The instrument must change treatment:

[ P(D=1\mid Z=1,X) \neq P(D=1\mid Z=0,X). ]

The simulation exposes the exact complier share and the fitted first-stage instrument coefficient.

Independence

The instrument must be independent of latent causes of the outcome, conditional on any stated controls.

The repository can deliberately violate this by making instrument assignment depend on the latent confounder.

A strong first stage does not rescue an instrument that violates independence.

Exclusion restriction

The instrument must affect the outcome only through treatment.

The DGP parameter instrument_direct_effect creates a direct Z-to-Y path. When it is non-zero, 2SLS becomes biased even though the first stage can remain extremely strong.

This demonstrates why instrument strength and instrument validity are different questions.

Monotonicity

For a binary instrument, the standard LATE interpretation additionally assumes

[ D_i(1) \geq D_i(0). ]

Under the additive non-negative encouragement shift used here, defiers cannot occur. The truth table records both potential treatment states so this can be verified directly in simulation.

In real observational data, monotonicity is a substantive assumption rather than something the analyst can inspect unit by unit.

First-stage diagnostics

fit_2sls reports:

  • instrument coefficient;
  • its standard error;
  • partial R-squared;
  • first-stage test statistic;
  • p-value;
  • reported test distribution.

The below_reference_threshold property flags a statistic below 10.

The familiar F greater than 10 rule is only a rough historical heuristic. In robust or heteroskedastic settings the reported first-stage statistic may be a robust Wald statistic rather than the exact classical homoskedastic F statistic. Weak-instrument-robust inference requires more care than a single cutoff.

Weak instruments

Weak instruments produce little exogenous treatment variation.

Consequences can include:

  • unstable 2SLS estimates;
  • large finite-sample bias;
  • wide or misleading conventional confidence intervals;
  • sensitivity to small data perturbations.

The weak-instrument test case keeps the instrument valid but makes the encouragement shift small. This separates weak relevance from violations of exclusion or independence.

Invalid-instrument experiments

Two invalid scenarios are included deliberately.

Exclusion violation

Setting a positive direct instrument effect creates a Z-to-Y path in addition to the Z-to-D-to-Y path.

The instrument can remain highly predictive of treatment while the IV estimate is badly biased.

Independence violation

Setting instrument_confounding above zero makes instrument assignment depend on the latent confounder.

Again, the first stage can look excellent while the causal interpretation fails.

Causal graph

graph LR
    X[Observed covariate X] --> D[Treatment D]
    X --> Y[Outcome Y]
    U[Latent confounder U] --> D
    U --> Y
    Z[Instrument Z] --> D
    D --> Y

For a valid instrument there is no direct Z-to-Y arrow and no U-to-Z arrow.

The invalid simulation modes add exactly those paths so their consequences can be examined against known truth.

Interpretation

The main lesson of this module is deliberately simple:

  • OLS can fail because treatment is endogenous.
  • IV can solve that problem only when the instrument is valid and relevant.
  • A large first-stage statistic is evidence about relevance, not about exclusion or independence.
  • With heterogeneous treatment effects, IV generally targets a local effect, not automatically the population ATE.