# ARCHIVED: In Stata, how do I test overidentification using xtoverid?

In Stata, `xtoverid`

is used on a test of overidentifying
restrictions (orthogonality conditions) for a panel data estimation
after `xtreg`

, `xtivreg`

, `xtivreg2`

,
or `xthtaylor`

.

Essentially, `xtoverid`

can be used in three cases: to
test on excluded instruments in IV estimations, to test on model
specification (FE or RE), and to test on the strong assumption in an
xthtaylor estimation.

## Testing on excluded instruments in IV estimations

In an IV estimation, `xtoverid`

conducts a test on
whether the excluded instruments are valid IVs or not (i.e., whether they
are uncorrelated with the error term and correctly excluded from the
estimated equation).

Rejection implies that some of the IVs are not valid. For example:

. webuse nlswork . tsset idcode year . gen age2=age^2 . gen black=(race==2) . xtivreg ln_wage age (tenure = union south), fe i(idcode) . xtoverid, cluster(idcode)

Supplying this gives you the following result:

Test of overidentifying restrictions: Cross-section time-series model: xtivreg fe robust cluster(idcode) Sargan-Hansen statistic 0.495 Chi-sq(1) P-value = 0.4818

## Testing on model specification (FE or RE)

A test of fixed vs. random effects can also be seen as a test of overidentifying restrictions:

- The fixed effects (FE) estimator uses the orthogonality conditions
that the regressors are uncorrelated with the idiosyncratic error
e
_{it}, i.e., E(X_{it}*e_{it})=0. - The random effects (RE) estimator uses the additional
orthogonality conditions that the regressors are uncorrelated with the
group-specific error u
_{i}(the "random effect"), i.e., E(X_{it}*u_{i})=0.

These additional orthogonality conditions are overidentifying restrictions. The test is implemented by xtoverid using the artificial regression approach described by Arellano (1993) and Wooldridge (2002, pp. 290-91), in which a random effects equation is re-estimated by being augmented with additional variables consisting of the original regressors transformed into deviations-from-mean form. Rejection implies that the fixed effect model is more reasonable or preferred. For example:

. webuse abdata, clear . sum * (Balanced panel) . xtreg n w k if year>=1978 & year<=1982, re *(Artificial regression overid test of fixed-vs-random effects) . xtoverid

Supplying this will give the following result:

Test of overidentifying restrictions: fixed vs random effects Cross-section time-series model: xtreg re Sargan-Hansen statistic 19.845 Chi-sq(2) P-value = 0.0000

**Note:** Under conditional homoskedasticity, this
test statistic is asymptotically equivalent to the usual Hausman
fixed-vs-random effects test. Unlike the Hausman test, the xtoverid
test extends straightforwardly to heteroskedastic- and cluster-robust
versions.

## Testing on the strong assumption in an xthtaylor estimation

For the Hausman-Taylor estimator to be consistent, it is necessary
to argue that all regressors are uncorrelated with the idiosyncratic
errors, e_{it}, and also that a specified subset of the
regressors is uncorrelated with the fixed effect term,
a_{i}. This additional strong assumption can be tested by the
`xtoverid`

command. Rejection implies that some variables
of the subset are not exogenous or correlated with the fixed effect
term. For example:

. webuse psidextract, clear . xthtaylor lwage wks south smsa ms exp exp2 occ ind union fem blk ed, /// endog(exp exp2 wks ms union ed) constant(fem blk ed) . xtoverid

Supplying this will give the following result:

Test of overidentifying restrictions: Cross-section time-series model: xthtaylor htaylor Sargan-Hansen statistic 5.229 Chi-sq(3) P-value = 0.1558

**Note:** In order to perform the xtoverid test, the
statistic must have `ranktest`

(version 01.3.02 or greater)
and `xtoverid`

ado files installed.

For more on xthtaylor regression, see ARCHIVED: In Stata, how do I estimate the coefficients of time-invariant variables in the Panel FE model, using the xthtaylor command?

If you have questions about using statistical and mathematical software at Indiana University, email UITS Research Analytics. Research Analytics is located on the IU Bloomington campus at Woodburn Hall 200, and is open for consultation by appointment Monday-Friday 9am-5pm.

*This is document* bcmq *in the Knowledge Base.*

*Last modified on* 2015-06-22*.*

- Fill out this form to submit your issue to the UITS Support Center.
- Please note that you must be affiliated with Indiana University to receive support.
- All fields are required.

- Fill out this form to submit your comment to the IU Knowledge Base.
- If you are affiliated with Indiana University and need help with a computing problem, please use the
**I need help with a computing problem**section above, or contact your campus Support Center.