Your data
Paste data or load the example.
Result
Coefficients (standard errors below)
Anderson-Rubin test of each coefficient value
AR statistic critical value: values below it form the AR set 2SLS Wald interval
First stage
| Endogenous | R² | Partial R² | Shea partial R² | F | p | Effective F |
|---|
| Endogenous | Instrument | Coefficient | SE | p |
|---|
Tests
| Test | Null hypothesis | Statistic | Distribution | p |
|---|
Method and citation
Write the model as y = Xβ + e, with X the constant, the exogenous controls W and the endogenous regressors, and Z the constant, W and the excluded instruments. Every estimator here is a k-class estimator, β(k) = [(1−k)X′X + kX′PZX]−1[(1−k)X′y + kX′PZy]: k = 0 is OLS, k = 1 is two-stage least squares (Theil 1953), k = the smallest root of det(V′MWV − k V′MZV) = 0 for V = [y, endogenous] is LIML (Anderson & Rubin 1949), and that root minus a/(n − L) is Fuller's estimator (1977), a = 1 here.
Standard errors are A−1·meat·A−1 with A the matrix inverted above and the meat built from the first-stage fitted regressors PZX times the structural residuals: summed unit by unit (robust; White 1980), summed within clusters first (clustered), or σ²A (unadjusted). No small-sample factor is applied unless you ask for one in the command line (--debiased).
First stage: the regression of each endogenous regressor on Z, its R², the partial R² of the instruments after partialling out W, Shea's (1997) partial R², and the F test of the instruments under the chosen errors (the Wald statistic over the number of instruments when errors are robust or clustered). The effective F of Montiel Olea & Pflueger (2013) replaces the F when errors are not homoskedastic; F below 10 is flagged (Staiger & Stock 1997). Overidentification: Sargan's (1958) n(1 − e′MZe/e′e) and Hansen's (1982) J from two-step GMM with the robust or clustered weight. Endogeneity: Durbin (1954) and Wu-Hausman (Hausman 1978), both homoskedastic, and the control-function test, which adds the first-stage residuals to OLS and tests them with the chosen errors.
The Anderson-Rubin set (one endogenous regressor) is every b for which the instruments do not predict y − bx given W. With unadjusted errors it solves a quadratic inequality exactly; otherwise the robust or clustered Wald test is inverted on a grid of 4,001 points over the 2SLS estimate ± 40 standard errors plus geometric tails out to about 1010 times that, each edge refined by bisection; a tail is called infinite only if the statistic's limit as |b| grows is under the critical value, and otherwise the set is marked as truncated.
Verified by tests in the source against linearmodels 7.1's IV2SLS, IVLIML and IVGMM (run only as an external program to record reference numbers): on three specifications of the example data (overidentified, just identified, two endogenous regressors) and all six choices of errors, every coefficient, standard error, first-stage statistic and test agrees within 1e-11, and the Anderson-Rubin endpoints agree with an independent check (linearmodels' OLS and scipy's root finder) within 1e-12. On 1,000 simulated samples from the example's design the clustered intervals were checked for coverage; the README has the table.
Limits
- Exclusion and independence cannot be tested. That the instrument reaches the outcome only through the regressor, and is unrelated to the outcome's other unobserved causes once the controls are in, is an argument you make, not something these statistics show. The overidentification tests only ask whether several instruments agree.
- Effects differ by person. With heterogeneous effects, IV estimates the effect for the people the instrument moves (a local average treatment effect; Imbens & Angrist 1994), not for everyone, and different instruments can legitimately disagree.
- The robust Anderson-Rubin set is not exact. Its coverage does not depend on instrument strength, but with clustered errors it rests on an estimated cluster covariance: in this tool's simulation with 150 clusters it covered 92% to 94% of the time, not 95%.
- Few clusters. Clustered errors are unreliable with fewer than about 30 to 50 clusters; the page warns below 30.
- Linear model, one equation. No GMM point estimates, no panel fixed effects (add indicators as columns), no weights, no HAC errors; the Anderson-Rubin set is for one endogenous regressor.
BibTeX
@techreport{theil1953repeated,
author = {Theil, Henri}, title = {Repeated Least Squares Applied to Complete Equation Systems},
institution = {Central Planning Bureau}, address = {The Hague}, year = {1953}
}
@article{anderson1949estimation,
author = {Anderson, T. W. and Rubin, Herman},
title = {Estimation of the Parameters of a Single Equation in a Complete System of Stochastic Equations},
journal = {Annals of Mathematical Statistics}, volume = {20}, number = {1}, pages = {46--63}, year = {1949},
doi = {10.1214/aoms/1177730090}
}
@article{fuller1977some,
author = {Fuller, Wayne A.}, title = {Some Properties of a Modification of the Limited Information Estimator},
journal = {Econometrica}, volume = {45}, number = {4}, pages = {939--953}, year = {1977}, doi = {10.2307/1912683}
}
@article{white1980heteroskedasticity,
author = {White, Halbert},
title = {A Heteroskedasticity-Consistent Covariance Matrix Estimator and a Direct Test for Heteroskedasticity},
journal = {Econometrica}, volume = {48}, number = {4}, pages = {817--838}, year = {1980}, doi = {10.2307/1912934}
}
@article{staiger1997instrumental,
author = {Staiger, Douglas and Stock, James H.}, title = {Instrumental Variables Regression with Weak Instruments},
journal = {Econometrica}, volume = {65}, number = {3}, pages = {557--586}, year = {1997}, doi = {10.2307/2171753}
}
@article{olea2013robust,
author = {Montiel Olea, Jos{\'e} Luis and Pflueger, Carolin}, title = {A Robust Test for Weak Instruments},
journal = {Journal of Business \& Economic Statistics}, volume = {31}, number = {3}, pages = {358--369}, year = {2013},
doi = {10.1080/00401706.2013.806694}
}
@article{lee2022valid,
author = {Lee, David S. and McCrary, Justin and Moreira, Marcelo J. and Porter, Jack},
title = {Valid t-Ratio Inference for {IV}}, journal = {American Economic Review},
volume = {112}, number = {10}, pages = {3260--3290}, year = {2022}, doi = {10.1257/aer.20211063}
}
@article{shea1997instrument,
author = {Shea, John}, title = {Instrument Relevance in Multivariate Linear Models: A Simple Measure},
journal = {Review of Economics and Statistics}, volume = {79}, number = {2}, pages = {348--352}, year = {1997},
doi = {10.1162/rest.1997.79.2.348}
}
@article{sargan1958estimation,
author = {Sargan, J. D.}, title = {The Estimation of Economic Relationships using Instrumental Variables},
journal = {Econometrica}, volume = {26}, number = {3}, pages = {393--415}, year = {1958}, doi = {10.2307/1907619}
}
@article{hansen1982large,
author = {Hansen, Lars Peter}, title = {Large Sample Properties of Generalized Method of Moments Estimators},
journal = {Econometrica}, volume = {50}, number = {4}, pages = {1029--1054}, year = {1982}, doi = {10.2307/1912775}
}
@article{durbin1954errors,
author = {Durbin, J.}, title = {Errors in Variables}, journal = {Revue de l'Institut International de Statistique},
volume = {22}, number = {1/3}, pages = {23--32}, year = {1954}, doi = {10.2307/1401917}
}
@article{hausman1978specification,
author = {Hausman, Jerry A.}, title = {Specification Tests in Econometrics},
journal = {Econometrica}, volume = {46}, number = {6}, pages = {1251--1271}, year = {1978}, doi = {10.2307/1913827}
}
Questions
What is an instrumental variable?
A variable that changes the regressor you care about but has no other route to the outcome. Distance to a college changes how much schooling people get; if it affects wages only through schooling, comparing people who lived nearer and farther identifies the return to schooling even though schooling itself was chosen. Three conditions must hold: relevance (the instrument moves the regressor, which the data can check), exclusion (it reaches the outcome only through the regressor) and independence (given the controls, it is unrelated to the outcome's other unobserved causes; living near a college must not also mean richer families or better local jobs). The data cannot check the last two.
When should I use instrumental variables instead of OLS?
When the regressor is correlated with the error: an omitted variable drives both (ability raises schooling and wages), the outcome feeds back into the regressor (price and quantity), or the regressor is measured with error. OLS is then biased and more data does not fix it. IV trades that bias for a wider interval, and it is only as good as the instrument.
How strong does the first stage need to be?
The usual rule of thumb is a first-stage F above 10 (Staiger and Stock 1997). Below that, 2SLS is biased towards OLS and its confidence interval is too narrow. With one instrument and one endogenous regressor, Lee, McCrary, Moreira and Porter (2022) show the usual 5% t-test keeps its 5% size only when the F exceeds 104.7. With heteroskedastic or clustered errors use the effective F of Montiel Olea and Pflueger (2013), which the page shows. When the first stage is not clearly strong, report the Anderson-Rubin set.
What is the Anderson-Rubin confidence set?
The set of coefficient values b for which the instruments do not predict y minus b times x. Its coverage does not depend on how strong the instruments are. When they are strong it is close to the 2SLS interval; when they are weak it widens, and it can be two rays or the whole line, which is the honest answer: the data cannot pin the effect down. The page computes it for one endogenous regressor, with the same robust or clustered errors as the rest of the output.
What do the Sargan and Hansen J tests tell me?
With more instruments than endogenous regressors, whether the instruments agree with each other about the coefficient. A rejection means at least one is invalid or the effect differs by instrument. Sargan assumes homoskedastic, independent errors; Hansen J is robust to heteroskedasticity or clustering. In the example, Sargan rejects valid instruments (p = 0.029) because the errors are clustered by county, and the clustered Hansen J does not (p = 0.14). Passing either test cannot show that the instruments are valid: if they share the same flaw, they agree.
Should I report 2SLS or LIML?
With a strong first stage they agree and 2SLS is the convention. With many or weak instruments, LIML is median-unbiased where 2SLS is biased towards OLS, but LIML has no finite moments and can be erratic; Fuller's estimator with a = 1 (Fuller 1977) is a compromise with finite moments. The page prints all three with OLS so you can see whether the choice matters.
Does it match Stata, R or Python?
On three specifications of the example data and every standard error choice, the OLS, 2SLS, LIML and Fuller coefficients and standard errors, the first-stage statistics, Sargan, Hansen J, Durbin, Wu-Hausman and the control-function test agree with linearmodels 7.1 within 1e-11, and the Anderson-Rubin set endpoints with an independent root-finding check within 1e-12.
Is my data uploaded anywhere?
No. The file is read and analysed by JavaScript in this browser tab. There are no accounts, cookies or analytics vendors.