Why Overidentification Creates a Testable Implication
Instrumental variables use instruments to supply information about endogenous regressors. If the number of excluded instruments equals the number of endogenous regressors, the model is exactly identified: the moment conditions can, under regularity conditions, determine the coefficient estimates without leaving extra restrictions to test. If there are more excluded instruments than endogenous regressors, the model is overidentified. The extra moment conditions imply restrictions that can be assessed jointly.
This tutorial develops two tests of those restrictions: the Sargan test, which relies on homoskedastic errors in its standard form, and the Hansen J test, which uses a heteroskedasticity-robust covariance estimate and efficient GMM weighting. Neither test identifies which instrument, if any, is responsible for a rejection.
For clarity, take the included exogenous controls as already partialled out. Let \(y_i\) be the outcome, \(x_i\) the \(k\)-vector of endogenous regressors, and \(z_i\) the \(q\)-vector of excluded instruments for observation \(i\). The structural equation is \(y_i=x_i'\beta+u_i\), and its instrument moment condition is \(E[z_i u_i]=0\). If controls are not partialled out, they must be included in the structural equation and in the instrument set; the count of overidentifying restrictions still concerns the excluded instruments and endogenous regressors.
The test is meaningful under conditions that support the relevant asymptotic approximation: observations are independent (or satisfy suitable dependence conditions), the required moments exist, the moment covariance matrix is well behaved, the coefficient vector is identified, and the instruments are sufficiently informative for standard large-sample inference. In particular, the usual chi-square calibration is not a remedy for weak identification. The Sargan test additionally relies on homoskedasticity; the robust Hansen J test allows heteroskedasticity when its covariance estimate is valid.
Counting the Restrictions
Each excluded instrument contributes one moment condition, while estimating \(k\) endogenous-regressor coefficients uses \(k\) degrees of freedom in fitting those conditions. Thus the joint test has \(q-k\) degrees of freedom. With included exogenous controls, partialling them out gives this same count; equivalently, one can count all instruments and all estimated structural regressors, including the controls, and take their difference.
Worked Example: Finding the Degrees of Freedom
Hypothetical setup. A structural equation has two endogenous regressors and four excluded instruments. Included exogenous controls have been partialled out. Determine whether the model is overidentified and the degrees of freedom for a joint overidentification test.
Here \(k=2\) and \(q=4\). Since \(4>2\), the model is overidentified. The number of restrictions is
The joint test therefore uses a chi-square reference distribution with 2 degrees of freedom under its null and the relevant regularity conditions. This count does not depend on how many controls were partialled out, provided they are handled consistently in the equation and instrument set.
The Hansen J Test From Moment Conditions
Write the sample average of the instrument moments, evaluated at a candidate coefficient vector \(\beta\), as
This is a \(q\)-vector. Under the null, its population counterpart is zero at \(\beta_0\). Generalized method of moments (GMM) estimates \(\beta\) by choosing coefficients that make the sample moments small, measured using a weighting matrix. For the Hansen J test, the efficient weighting matrix is the inverse of the covariance matrix of the moment vector.
A common heteroskedasticity-robust estimate is based on the fitted residuals \(\hat u_i=y_i-x_i'\hat\beta_{\mathrm{GMM}}\):
The squared residuals allow the variability of the moment vector to differ across observations. The GMM estimate and covariance estimate are formed in a two-step procedure: use a consistent preliminary estimate to construct \(\hat S\), then estimate the coefficients using its inverse as the weight. The reported J statistic evaluates the resulting fitted moments using that covariance weighting.
Why the J Statistic Has \(q-k\) Degrees of Freedom
The degrees of freedom follow from the geometry of fitting \(k\) coefficients to \(q\) sample moments. A short derivation also clarifies that the statistic tests the part of the moment vector that coefficient estimation cannot remove.
Let \(D\) be the \(q\)-by-\(k\) derivative matrix of the population moments with respect to \(\beta\), evaluated at \(\beta_0\). Assume \(D\) has rank \(k\). Under the null, a central limit theorem gives \(\sqrt n\,\bar g_n(\beta_0)\) an asymptotic mean-zero normal distribution with covariance \(S\). Efficient GMM adjusts the \(k\) coefficients to remove the component of this random moment vector that can be explained by changes in \(\beta\).
To see the remaining component, define \(v=\sqrt n\,\bar g_n(\beta_0)\) and \(A=S^{-1/2}D\). A first-order expansion of the moments around \(\beta_0\) gives \(\bar g_n(\hat\beta)\approx\bar g_n(\beta_0)+D(\hat\beta-\beta_0)\). In the whitened coordinates \(S^{-1/2}v\), efficient GMM removes the projection onto the column space of \(A\). If \(P_A=A(A'A)^{-1}A'\) denotes that projection matrix, the remaining component is approximately \((I-P_A)S^{-1/2}v\). Therefore the J statistic is asymptotically the squared length of this component:
Under the null, \(S^{-1/2}v\) is asymptotically a \(q\)-dimensional standard normal vector. Since \(A\) has rank \(k\), \(I-P_A\) is a projection of rank \(q-k\). The squared length of the projected standard normal vector consequently has a chi-square distribution with \(q-k\) degrees of freedom. This argument also shows why estimating the structural coefficients matters: the test concerns the moment discrepancies left after fitting, not the raw moments at an arbitrary coefficient value.
Worked Example: Calculating a Robust Hansen J Statistic
Hypothetical output. Suppose there are three excluded instruments and one endogenous regressor, with \(n=200\). After efficient GMM estimation, suppose the sample moment vector is \((0,\ 0.03,\ -0.02)'\), and the estimated moment covariance matrix is the \(3\)-by-\(3\) identity matrix. For this illustrative output, the fitted moment vector is consistent with the GMM first-order condition: the derivative direction is \((1,\ 0,\ 0)'\), so the remaining moments are orthogonal to that direction.
Because \(\hat S^{-1}\) is also the identity matrix, substitute directly into the Hansen statistic:
There are \(q-k=3-1=2\) degrees of freedom. For a chi-square variable with 2 degrees of freedom, the upper-tail probability at 0.26 is approximately \(e^{-0.26/2}=0.878\). Thus, at significance level \(\alpha=0.05\), this hypothetical result does not reject the joint moment restrictions. It is not evidence that the probability the null is true is 0.878; the p-value is the probability, under the null and the reference model, of obtaining a statistic at least as large as 0.26.
The Sargan Test Under Homoskedasticity
Under homoskedastic errors and the standard linear IV setup, the Sargan test provides a familiar auxiliary-regression form. First estimate the equation by 2SLS and obtain its residuals. Then regress those residuals on the full instrument set, including included exogenous controls if they have not already been partialled out. If \(R^2\) is the coefficient of determination from this auxiliary regression, the Sargan statistic is
Under the null, this statistic is asymptotically chi-square with \(q-k\) degrees of freedom. The auxiliary regression asks whether the fitted structural residuals retain systematic association with the instruments after the 2SLS fit. The homoskedasticity assumption is important for the standard Sargan calibration; with heteroskedasticity, use a robust Hansen J procedure rather than treating this \(nR^2\) statistic as generally valid.
Worked Example: Interpreting a Sargan Test
Hypothetical data summary. A 2SLS analysis uses four excluded instruments for two endogenous regressors and \(n=250\) observations. In the auxiliary regression of the 2SLS residuals on the instrument set, the reported \(R^2\) is 0.018. Assume the errors are homoskedastic and the other regularity conditions for the Sargan test are met.
The statistic is
The reference distribution has \(q-k=4-2=2\) degrees of freedom. The upper-tail p-value is approximately \(e^{-4.50/2}=e^{-2.25}=0.1054\). At \(\alpha=0.05\), the result does not reject the joint overidentifying restrictions. The calculation is based on the supplied auxiliary-regression \(R^2\); it does not imply that every instrument has been separately shown to satisfy the moment condition.
What the Test Result Does and Does Not Say
Both tests are joint tests. A small p-value is evidence against the claim that all specified instrument moments are simultaneously compatible with the structural model and its maintained assumptions. It does not reveal which moment is responsible. Possible explanations include an invalid instrument, a misspecified structural equation, or a failure of assumptions used to obtain the reference distribution. The test alone does not distinguish among these explanations.
A large p-value means the test has not detected a discrepancy large enough to reject at the chosen significance level. It is not proof that the instruments are valid, and it is not a test that the instruments are strong. In particular, a non-rejection should not be converted into a statement that the null has been accepted.
Common Mistake
Wrong reasoning: “The J-test p-value is above 0.05, so the instruments are valid.” This overstates what a non-rejection establishes. The test asks whether the observed joint moment discrepancy is sufficiently inconsistent with the null to reject; it does not certify instrument validity or identify every source of bias.
Correction: Report the statistic, its \(q-k\) degrees of freedom, the p-value, and the significance level. State whether the joint restrictions are rejected, and keep that conclusion separate from claims about individual instruments or instrument strength.
Check Your Understanding
Answer these questions using the definitions and procedures above.
- A model has three endogenous regressors and five excluded instruments. How many overidentifying restrictions does the joint test assess?
- State the Hansen J null hypothesis in terms of the instrument-outcome moments.
- Why does the usual Sargan \(nR^2\) test require a homoskedasticity condition in its standard form?
- A Hansen J test has \(J=6.2\) with 3 degrees of freedom. What additional quantity is needed to make a decision at a specified significance level?
- Why does failure to reject an overidentification test not establish that every instrument is valid?