IV_REGRESSION
Estimate a single-equation instrumental-variables model with two-stage least squares (2SLS).
Syntax
IV_REGRESSION(Y, X, LIST(Z1, Z2, ...))
IV_REGRESSION(LIST(Y, X1, X2, ...), LIST(Z1, Z2, ...))
| Argument | Description |
|---|---|
Y |
The dependent or outcome series. |
X, X1... |
One or more regressors treated as endogenous. |
LIST(Z1,Z2,...) |
The excluded instruments. At least as many instruments as endogenous regressors are required. |
RainbowStats aligns the outcome, endogenous regressors, and instruments to their common date range before estimation.
Model
For one endogenous regressor, the two stages are:
The 2SLS estimator is calculated as:
The instrument projection matrix is PZ = Z(Z′Z)−1Z′. A constant is included.
Example pattern
Data=SAME_DATE_RANGE(LIST(Y,X,Z1,Z2))
IV=IV_REGRESSION(Y,X,LIST(Z1,Z2))
SLIDESHOW(IV)
Beta=EXTRACT(IV,"beta")
SE=EXTRACT(IV,"se")
TStat=EXTRACT(IV,"tstat")
FirstStageF=EXTRACT(IV,"first_stage_f")
Replace Y, X, and the instruments with series appropriate to the research design.
This is a syntax pattern, not an endorsement of any particular instrument.
Multiple endogenous regressors
IV=IV_REGRESSION(LIST(Y,X1,X2),LIST(Z1,Z2,Z3))
SLIDESHOW(IV)
BetaX1=EXTRACT(IV,"beta:1")
BetaX2=EXTRACT(IV,"beta:2")
FX1=EXTRACT(IV,"first_stage_f:1")
FX2=EXTRACT(IV,"first_stage_f:2")
Coefficient index 0 is the intercept. Coefficients 1 onward correspond to the
endogenous regressors in their listed order. First-stage numbering begins at 1.
Available extracts
| Extract | Returns |
|---|---|
firststage | The first-stage regression for the first endogenous regressor. |
firststage:n | First-stage regression number n, using 1-based numbering. |
secondstage | The displayed second-stage regression using fitted endogenous values. |
beta | The IV coefficient for the first endogenous regressor. |
beta:n | Coefficient n; beta:0 is the intercept. |
se or se:n | Conventional homoskedastic 2SLS standard error. |
tstat or tstat:n | IV coefficient divided by its reported standard error. |
first_stage_f | Excluded-instrument F statistic for the first endogenous regressor. |
first_stage_f:n | Excluded-instrument F statistic for endogenous regressor n. |
slideshow | First-stage panels followed by the second-stage presentation. |
Required analytical checks
- Explain endogeneity. State why ordinary regression may be biased.
- Defend relevance. Show why each instrument predicts the endogenous regressor.
- Defend exclusion. Explain why each instrument has no direct path to the outcome.
- Inspect every first stage. Report the excluded-instrument F statistic and the sample used.
- Disclose instrument selection. Report candidates tried, not only those retained.
- Check sensitivity. Compare credible specifications and investigate unstable signs or magnitudes.
- Interpret the estimand carefully. IV may identify a local effect for observations affected by the instrument, not a universal average effect.
What the command does not establish
- It does not prove that an instrument is exogenous.
- It does not prove the exclusion restriction.
- It does not make a weak instrument strong.
- It does not protect against instrument searching or specification mining.
- It does not currently report weak-instrument-robust confidence sets or an overidentification test.
Best use
Use IV_REGRESSION when the instrument comes from a clearly articulated design—such as a
defensible policy rule, institutional assignment mechanism, natural experiment, or other source of
plausibly exogenous variation—and when that design is explained before the regression results are examined.
Related commands
REGRESSION— ordinary least-squares regression.THREE_STAGE_REGRESSION— instrumental-variables estimation for simultaneous equation systems.EXTRACT— retrieve coefficients, diagnostics, regressions, and slides.INSTRUMENT_HACKING— demonstrate the false discoveries produced by selecting instruments after examining results.