*! version 1.0.2 21sept2020

Title

overid -- Postestimation tests of overidentification

overid computes tests of overidentifying restrictions for a regression
estimated via instrumental variables in which the number of instruments exceeds the number of regressors:
that is, for an overidentified equation.
These are tests of the joint null hypothesis that the excluded instruments are valid instruments,
i.e., uncorrelated with the error term and correctly excluded from the estimated equation.
A rejection casts doubt on the validity of the instruments.

Supported estimators:
ivregress, ivreg2, xtivreg, xtivreg2, xthtaylor, xtabond2, xtdpdgmm,
ivprobit, ivtobit, reg3, ivreg29, xtreg.

overid requires the Stata module ranktest, version 02.0.03 or higher;
click here to install
or type "ssc install ranktest" from inside Stata.

Note: overid was substantially rewritten starting with version 3.
It is now essentially a wrapper for the programs
underid (used for most linear IV estimators),
overid9 (used for nonlinear IV estimators and reg3),
and xtoverid (used for testing fixed vs random effects after xtreg).
Full descriptions of the tests implemented by overid
are available in the help files for these programs (click on the links).
The version of Stata required for overid is Stata 13 or higher.
The previous version of overid is now called overid9.
xtoverid also continues to be available.
Both overid9 and xtoverid are included in the overid package.
To run either program, either use overid with version control (version 12: overid ... ),
or call overid9 or xtoverid directly.

Syntax overview

Syntax and usage after linear IV estimation

(ivregress, ivreg2, xtivreg, xtivreg2, xthtaylor, xtabond2, xtdpdgmm)

overid
[, jgmm2s LIMLresid jcue j2l j2lr kp wald lr center vceopt(VCE options) rkopt(ranktest options) noisily noreport]

For a summary description of the above options, see below.
For examples illustrating the use of these options, see below.
For a full description of the methods and framework used, see the help file for underid.

Syntax and usage after nonlinear IV estimation

(ivprobit, ivtobit)

overid

Note: estimation using ivprobit or ivtobit must use the twostep option.

ivprobit and ivtobit with the twostep option report Newey's (1987) minimum-chi-squared estimators.
Lee (1992) shows that the chi-squared statistic from these estimators provides a test of overidentifying restrictions.
For examples illustrating the use of overid after estimation by instrumental variables probit or tobit,
see below.

Syntax and usage after panel data estimation using xtreg (fixed vs random effects)

overid
[, robust cluster(varname)]

A test of fixed vs. random effects can also be seen as a test of overidentifying restrictions.
The test is implemented by xtoverid using the artificial regression approach described by Arellano (1993),
in which a random effects equation is reestimated augmented
with additional variables consisting of the original regressors transformed into deviations-from-mean form.
For examples illustrating the use of these options, see below.
For a full description of the methods and framework used, see the help file for xtoverid.

Syntax and usage after reg3 and under version control

(reg3, ivregress, ivreg2, ivreg29, xtivreg, xtivreg2, xthtaylor, ivprobit, ivtobit)

overid

version ver : overid
[, chi2 dfr f all]

where ver is a Stata version number between 9 and 12 inclusive.

For a summary description of the above options, see below.
For examples illustrating the use of these options, see below.
For a full description of the methods and framework used, see the help file for overid9.

Options detail - linear IV estimators

overid
[, jcue jgmm2s j2l j2lr kp sw wald lr center vceopt(VCE options) rkopt(ranktest options) noisily noreport
usemeans repstata maineq(estimator)]

Tests

jgmm2s J statistic from 2-step GMM (robust default) or 2SLS (iid default)

LIMLresid use LIML residuals instead of 2SLS residuals (iid only) (equivalent to Anderson canonical correlations test

jcue Cragg-Donald test, J statistic from GMM CUE (robust only)

j2l J2L statistic (robust only)

j2lr J2LR statistic (robust only)

kp Kleibergen-Paap test (robust only)

Main options

wald report Wald-type instead of default LM-type test

lr report LR instead of default LM-type test (Anderson test only)

center specifies that the moments in the robust VCE are centered so that they have mean zero

VCE options

(default) take VCE options from IV estimation

vceopt(VCE options): override IV VCE specification with user-specified option list selected from the following:

iid report tests using unrobust (standard) VCE that assumes iid

robust report tests that are robust to arbitrary heteroskedasticity

cluster(varlist) report tets that are robust to heteroskedasticity and within-cluster correlation; 2-way clustering is supported

bw(#) report tests that are autocorrelation-consistent (AC)
or (with the robust option) heteroskedasticity- and autocorrelation-consistent (HAC),
with bandwidth equal to #

kernel(string) specifies the kernel to be used for AC and HAC covariance estimation (default=Bartlett a.k.a. Newey-West)

For more details on available VCE options, see help avar or ivreg2.

Rarely-used options

rkopt(options) additional options to pass to ranktest, e.g., optimization settings; see ranktest

noisily report output of internal call to ranktest

noreport suppress detailed output relating to xtabond2

nopartial }keep the exogenous regressors X in the list of both endogenous regressors Y and instruments Z

usemeans (after xtivreg or xthtaylor only) use means instead of demeaned exogenous regressors as IVs

repstata (after xtivreg or xthtaylor only) use Stata method for exogenous regressors in random effects models

maineq(estimator) (requires ivreg2) re-estimate and report main equation; estimator may be iv, gmm2s or cue

NB: the default for overid is jgmm2s,
whereas the default for underid is to use LIML residuals in the iid case
(equivalent to Anderson's canonical correlations test)
and CUE GMM J in the non-iid case.
Calling overid with the limlresid option will replicate the default behavior of underid.
See the examples below and help underid for details.

overid as used above requires the Stata module ranktest, version 02.0.03 or higher;
click here to install
or type "ssc install ranktest" from inside Stata.

Additional robust covariance options accepted by avar may be included as options to underid.
See help avar, ivreg2 or ranktest for details.

Options detail - panel data estimation using xtreg (fixed vs random effects)

overid
[, robust cluster(varname)]

robust report a heteroskedasticity-robust overidentification test

cluster(varname) report a cluster-robust overidentification test

Options detail - after reg3 and under version control

overid

version ver : overid
[, chi2 dfr f all]

where ver is a Stata version number between 9 and 12 inclusive.

chi2 report Sargan's and Basmann's chi-squared statistics

dfr equivalent to chi2 but incorporating an (N-K) small-sample correction to the Sargan statistic

f report the pseudo-F test versions of the Sargan ((N-K)/(L-K)) and Basmann ((N-L)/(L-K)) statistics

all report all 5 statistics

Overidentification examples - linear IV estimators

Instrumental variables. Examples follow Hayashi 2000, p. 255.

. use http://fmwww.bc.edu/ec-p/data/hayashi/griliches76.dta, clear

2SLS with Sargan J statistic (iid case).

. ivreg2 lw s expr tenure rns smsa i.year (iq=med kww age mrt)

. di e(j)

Replicate Sargan J statistic: iid case, 2SLS residuals.

. overid

. di r(j_oid)

Sargan J statistic, iid case using LIML residuals.

. overid, limlresid

2SLS with heteroskedastic-robust Sargan-Hansen J statistic (equivalent to J from 2-step GMM).

. ivreg2 lw s expr tenure rns smsa i.year (iq=med kww age mrt), rob

. di e(j)

Reproduce ivreg2 Hansen J overid statistic.

. overid

. di r(j_oid)

CUE GMM J statistic.

. overid, jcue

Reproduce J and coefficient estimates for CUE.
Note the nopartial option is required in order to reproduce both the CUE estimates
of the coefficients on the exogenous regressors and the Hansen J statistic.
Coefficient estimates differ slightly because of different methods of numerical optimization.

. ivreg2 lw s expr tenure rns smsa i.year (iq=med kww age mrt), rob cue

. underid, overid nopartial rkopt(noevorder)

. mat list r(b_oid)

Dynamic panel data using xtabond2.
Note that the xtabond2 option svmat is required,
and that this option in turn requires the Mata option matafavor to be set for speed.

. use http://www.stata-press.com/data/r7/abdata.dta, clear

Two-step estimator, no level equation.
xtabond2 uses the default h(2) option,
and internally overid uses the nopartial option in order to reproduce the results.

. xtabond2 n L.n L(0/1).(w k) yr1979-yr1984, gmm(L.(w k n), lag(1 1)) iv(yr1979-yr1984) robust twostep noleveleq svmat

Reproduce xtabond2 Hansen J overid statistic.

. di e(hansen)

. overid

CUE GMM J statistic.
Use noreport option to suppress report of variable transformations.
Use noisily option to display underlying ranktest output.

. overid, jcue noreport noi

Examine CUE coefficients and VCE for endogenous regressors.

. mat list r(b_oid)

. mat list r(V_oid)

Reproduce xtdpdgmm Hansen J overid statistic.

. xtdpdgmm L(0/1).n w k, gmmiv(L.n, l(1 4) c m(d)) iv(w k, d m(d)) twostep vce(robust)

. estat overid

. overid

CUE GMM J statistic.
Also examine CUE coefficients and VCE for endogenous regressors.

. overid, jcue

. mat list r(b_oid)

. mat list r(V_oid)

Static panel data. Examples based on Stata command help files.

. webuse nlswork, clear

. tsset idcode year

. gen age2=age^2

. gen black=(race==2)

Fixed effects.

. xtivreg ln_wage age (tenure = union south), fe

LIML-based tests for the iid case.

. overid, limlresid

Cluster-robust test.

. overid, vceopt(cluster(idcode))

G2SLS; note overid degrees of freedom: 2 (union, south) - 1 (tenure) = 1.

. xtivreg ln_wage age (tenure = union south), re

. overid

EC2SLS; dof = 6 (mean and mean-deviation of union, south, age) - 2 (GLS transform of tenure, age) = 4.

. xtivreg ln_wage age (tenure = union south), ec2sls

. overid

EC2SLS; changing the number of included exogenous variables changes the dof of the overid stat.
4 (mean and mean-deviation of union, south) - 1 (GLS transform of tenure) = 3.

. xtivreg ln_wage (tenure = union south), ec2sls

. overid

Hausman-Taylor estimation; 2-step GMM J stats.
Note that underlying estimation differs from original; Stata's
xthtaylor treats GLS-transformed exogenous regressors as endogenous.
dof = 2 (exogenous time-varying age, age2) - 1 (endogenous time-invariant grade) = 1.

. xthtaylor ln_wage age age2 tenure hours black birth_yr grade, endog(tenure hours grade)

. overid

. mat list e(b)

. mat list r(b0_oid)

As above but use repstata option; confirm underlying estimation now matches original.

. xthtaylor ln_wage age age2 tenure hours black birth_yr grade, endog(tenure hours grade)

. overid, repstata

. mat list e(b)

. mat list r(b0_oid)

Overidentification examples - nonlinear IV estimators

Examples are overidentified versions of the examples in the Stata help files for ivprobit and ivtobit.
Note that the twostep is required for both estimators.

Load data and create an additional instrument.

. webuse laborsup, clear

. gen male_educ_sq = male_educ^2

IV probit:

. ivprobit fem_work fem_educ kids (other_inc = male_educ male_educ_sq), twostep

. overid

IV tobit:

. ivtobit fem_inc fem_educ kids (other_inc = male_educ male_educ_sq), ll twostep

. overid

Overidentification examples - panel data estimation using xtreg (fixed vs random effects)

. webuse abdata, clear

Artificial regression overid test of fixed vs random effects.
Estimate using random effects, then test.

. xtreg n w k, re

. overid

Cluster-robust version.

. overid, cluster(id)

In the homoskedastic balanced panel case,
a Hausman test using sigma from FE estimation is numerically equal to the artificial regression overid statistic.
First estimate using random effects and report overid test result.

. xtreg n w k if year>=1978 & year<=1982, re

. overid

. di r(j)

Hausman test of fixed vs random effects.

. est store re

. xtreg n w k if year>=1978 & year<=1982, fe

. est store fe

Test statistic is identical.

. hausman fe re, sigmaless

. di r(chi2)

Overidentification examples - estimation using reg3 and version control

Overidentification tests after estimation by reg3.

. webuse klein, clear

. constraint define 1 [consump]wagepriv = [consump]wagegovt

. constraint define 2 [consump]govt = [wagepriv]govt

. reg3 (consump wagepriv wagegovt govt invest) (wagepriv consump govt capital1 taxnetx)

. overid

. reg3 (consump wagepriv wagegovt govt invest) (wagepriv consump govt capital1 taxnetx), c(1 2)

. overid

Version control examples.
Using version 12 or earlier causes overid to branch to overid version 2.0.08, also available as overid9.

. use http://fmwww.bc.edu/ec-p/data/hayashi/griliches76.dta, clear

. ivreg2 lw s expr tenure rns smsa (iq=med kww age mrt)

. version 12: overid, all

. overid9, all

Replicate Sargan chi-sq statistic using current version of overid.

. overid, jgmm2s

Replicate Basmann chi-sq statistic using current version of overid.

. overid, jgmm2s wald small

Stored results

For stored results after linear IV estimation, see the help file for underid.

Citation and references

Citation

overid is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Baum, C.F., Schaffer, M.E., Stillman, S., Wiggins, V., Windmeijer, F. 2020.
overid: Stata module to calculate tests of overidentifying restrictions.
https://ideas.repec.org/c/boc/bocode/s396802.html

References

Arellano, M. 1993.
On the testing of correlated effects with panel data.
Journal of Econometrics, Vol. 59, Nos. 1-2, pp. 87-97.

Lee, L. 1992.
Amemiya's Generalized Least Squares and Tests of Overidenfication in Simultaneous Equation Models with Qualitative or Limited Dependent Variables.
Econometric Reviews, Vol. 11, No. 3, pp. 319-328.

Newey, W.K. 1987.
Efficient Estimation of Limited Dependent Variable Models with Endogeneous Explanatory Variables.
Journal of Econometrics, Vol. 36, pp. 231-250.

Authors

Christopher F Baum, Boston College, USA
baum@bc.edu

Mark E Schaffer, Heriot-Watt University, UK
m.e.schaffer@hw.ac.uk

Steven Stillman, University of Bolzano, Italy
steven.stillman@unibz.it

Vince Wiggins, Stata Corporation, USA
vwiggins@stata.com

Frank Windmeijer, Oxford University, UK
frank.windmeijer@stats.ox.ac.uk