Tutorials › Propensity Score Matching and Instrumental Variables › The Projection-Matrix Formula for 2SLS

Two-Stage Least Squares · Tutorial 482 of 699

The Projection-Matrix Formula for 2SLS

See how the instrument projection matrix produces fitted endogenous regressors and the matrix formula for the 2SLS coefficient.

Advanced 10 min read

What You'll Learn

  • Define the instrument projection matrix and its dimensions.
  • Derive the projection-matrix formula for 2SLS.
  • Calculate fitted endogenous-regressor values from an instrument.
  • Identify the rank and relevance conditions needed for a unique estimate.
  • Distinguish an algebraically computable coefficient from a causally interpretable one.
  • Recognize why weak or irrelevant instruments make the calculation fail or become unstable.

From an Instrument to a Projection

Two-stage least squares (2SLS) uses the part of an endogenous regressor that can be predicted from the instrument or instruments. The projection-matrix formula expresses that idea compactly: it first projects the regressor into the space spanned by the instruments, then uses that projection in the estimator. This notation is useful because it makes the fitted values, dimensions, and conditions for a unique estimate explicit.

The setup here has one endogenous regressor and no additional exogenous covariates. Let \(y\) be the outcome vector, \(x\) the endogenous-regressor vector, and \(Z\) the matrix whose columns are the instruments. For \(n\) observations and \(L\) instruments, \(y\) and \(x\) are \(n\times 1\), and \(Z\) is \(n\times L\). The structural equation is \(y=x\beta+u\), where \(\beta\) is a scalar and \(u\) is the structural error vector.

Definition: If the columns of \(Z\) are linearly independent, the projection matrix onto their column space is \(P_Z=Z(Z'Z)^{-1}Z'\). It is an \(n\times n\) matrix. For any \(n\times 1\) vector \(v\), \(P_Zv\) is the least-squares projection of \(v\) onto the space spanned by the columns of \(Z\). In particular, \(\hat{x}=P_Zx\) is the fitted endogenous regressor.

Here \(Z'\) is \(L\times n\), \(Z'Z\) is \(L\times L\), and \(Z(Z'Z)^{-1}Z'\) is \(n\times n\), as required to multiply an \(n\times 1\) vector. The projection is determined by the instrument space, not by the outcome. The same matrix projects both \(x\) and \(y\), when a projection of the outcome is useful for describing the estimator.

Two properties follow directly from the formula. First, \(P_Z\) is symmetric: \(P_Z'=P_Z\). Second, it is idempotent: \(P_Z^2=P_Z\). To verify the latter, use \(Z'Z\) as a single matrix product:

$$ P_Z^2 =Z(Z'Z)^{-1}Z'Z(Z'Z)^{-1}Z' =Z(Z'Z)^{-1}Z' =P_Z. $$

Idempotence means that projecting a vector that is already in the instrument space leaves it unchanged. Symmetry and idempotence also ensure that the quadratic expression involving \(P_Z\) below measures the squared length of the projected residual.

Deriving the Projection-Matrix Estimator

The projection-matrix form of 2SLS is

$$ \hat{\beta}_{2SLS} =(x'P_Zx)^{-1}x'P_Zy. $$

For one endogenous regressor, \(x'P_Zx\) is a scalar, so its inverse exists precisely when that scalar is nonzero. More generally, if \(X\) has \(K\) endogenous-regressor columns, the corresponding expression is \((X'P_ZX)^{-1}X'P_Zy\), provided that the \(K\times K\) matrix \(X'P_ZX\) is nonsingular. The examples here keep to one endogenous regressor.

A direct derivation starts by measuring the discrepancy between the observed outcome and the structural prediction after projecting that discrepancy onto the instrument space. Define the criterion \(Q(\beta)=(y-x\beta)'P_Z(y-x\beta)\). Since \(P_Z\) is symmetric, expanding and differentiating this scalar quadratic gives

$$ Q(\beta) =y'P_Zy-2\beta x'P_Zy+\beta^2x'P_Zx, \qquad \frac{dQ(\beta)}{d\beta} =-2x'P_Zy+2\beta x'P_Zx. $$

Setting the derivative equal to zero gives \(x'P_Zx\,\hat{\beta}=x'P_Zy\). If \(x'P_Zx>0\), solving yields the stated estimator. The criterion is then strictly convex in \(\beta\), so this solution is its unique minimum. The condition \(x'P_Zx>0\) says that the instrument-space projection of \(x\) is not the zero vector: the instruments must contain some variation related to the endogenous regressor.

The fitted endogenous regressor is obtained separately from the first-stage projection:

$$ \hat{x}=P_Zx=Z(Z'Z)^{-1}Z'x. $$

This expression has \(n\) fitted values, one for each observation. It is a linear combination of the columns of \(Z\), so every fitted value vector lies in the instrument space. The projection formula does not by itself establish that the resulting coefficient has a causal interpretation. That interpretation requires the instrumental-variable assumptions established in earlier material, including relevance and a valid relationship between the instruments and the structural error. In moment notation, a key exogeneity condition is \(E[Z'u]=0\); a nonzero projection of \(x\) is also needed for identification.

Worked Example: Projecting a Regressor With One Instrument

Suppose three hypothetical observations have \(z=(1,2,3)'\) as the instrument, \(x=(1,2,2)'\) as the endogenous regressor, and \(y=(2,5,4)'\) as the outcome. There is one instrument, so \(Z=z\) is \(3\times1\), and \(P_Z\) is \(3\times3\).

First calculate \(z'z=1^2+2^2+3^2=14\). Thus

$$ P_Z=\frac{1}{14} \begin{bmatrix} 1&2&3\\ 2&4&6\\ 3&6&9 \end{bmatrix}. $$

The fitted regressor is

$$ \hat{x}=P_Zx =z\frac{z'x}{z'z} =z\frac{1+4+6}{14} =\frac{11}{14} \begin{bmatrix}1\\2\\3\end{bmatrix} \approx \begin{bmatrix}0.7857\\1.571\\2.357\end{bmatrix}. $$

The coefficient calculation can use the same projection without writing out every entry of \(P_Z\):

$$ x'P_Zx=\frac{(z'x)^2}{z'z}=\frac{11^2}{14}=\frac{121}{14}, \qquad x'P_Zy=\frac{(z'x)(z'y)}{z'z} =\frac{(11)(24)}{14}=\frac{264}{14}. $$

Therefore \(\hat{\beta}_{2SLS}=(264/14)/(121/14)=264/121=24/11\approx2.182\). In this hypothetical example the estimated outcome change is about 2.182 outcome units per one-unit increase in \(x\), under the stated linear specification. The nonzero value \(z'x=11\) verifies relevance for this finite-sample calculation; it does not verify the other IV assumptions.

Reading Fitted Values and Checking the Conditions

The fitted values are not generally the original values of \(x\). They are the components of \(x\) that lie in the instrument space. With one instrument \(z\), the formula simplifies to

$$ P_zx=z\frac{z'x}{z'z}. $$

Thus every fitted value is the same scalar multiple of the corresponding instrument value. If the instrument vector is rescaled by a nonzero constant, the projection does not change: the span of the instrument is unchanged. This is a useful check against interpreting the numerical size of an instrument's units as a measure of its relevance.

The matrix formula also provides practical diagnostics. Confirm that \(Z\) has full column rank before using \((Z'Z)^{-1}\). Then check that the projected regressor has nonzero variation, equivalently \(x'P_Zx>0\) in the one-regressor case. A value close to zero signals that the data contain little instrument-related variation in \(x\); although an inverse may technically exist, the estimate can be highly sensitive to small changes in the data. The formula alone does not supply an inference procedure or a test of the IV assumptions.

When \(Z\) has linearly dependent columns, \(Z'Z\) is singular and the displayed inverse is undefined. Redundant instrument columns do not add a new direction to the instrument space. One can represent that space using a full-rank basis, or define a projection with a generalized inverse, but the ordinary inverse formula as written requires full column rank. Similarly, if \(P_Zx=0\), then \(x'P_Zx=0\) and no unique 2SLS coefficient is available from this setup.

Worked Example: Explicit Matrix Multiplication for Fitted Values

For another hypothetical data set, let \(z=(1,-1)'\), \(x=(3,1)'\), and \(y=(5,1)'\). Each vector has two observations, and the single instrument gives a \(2\times2\) projection matrix:

$$ z'z=2,\qquad P_Z=\frac{zz'}{z'z} =\frac12 \begin{bmatrix} 1&-1\\ -1&1 \end{bmatrix}. $$

Multiplying by \(x\) gives

$$ \hat{x}=P_Zx =\frac12 \begin{bmatrix} 1&-1\\ -1&1 \end{bmatrix} \begin{bmatrix}3\\1\end{bmatrix} = \begin{bmatrix}1\\-1\end{bmatrix}. $$

The projected outcome is \(P_Zy=(2,-2)'\). Hence \(x'P_Zx=3(1)+1(-1)=2\), and \(x'P_Zy=3(2)+1(-2)=4\). The 2SLS coefficient is \(4/2=2\). These fitted values and the coefficient follow from the projection formula; the very small sample is illustrative only and is not evidence that the IV assumptions hold.

Worked Example: When Relevance Fails Completely

Consider hypothetical vectors \(z=(1,1,1)'\) and \(x=(1,-1,0)'\), with three observations and one instrument. Then \(z'z=3\), but \(z'x=1-1+0=0\). The fitted regressor is

$$ P_Zx=z\frac{z'x}{z'z} =z\frac{0}{3} =\begin{bmatrix}0\\0\\0\end{bmatrix}. $$

Consequently, \(x'P_Zx=0\). The inverse in the 2SLS formula does not exist, so there is no unique coefficient from this instrument and regressor in this setup. Reporting a numerical estimate would require an unjustified workaround; the appropriate conclusion is that this instrument supplies no projected variation in \(x\).

What the Formula Does—and Does Not—Establish

The projection-matrix representation is valuable because it separates three issues that are easy to conflate. The matrix \(P_Z\) defines which variation is retained; the rank condition determines whether the coefficient can be uniquely calculated; and the IV assumptions determine whether the coefficient has the intended causal interpretation. A successful matrix calculation addresses the first two, not automatically the third.

In particular, nonzero sample association between \(Z\) and \(x\) is not proof of instrument validity. The earlier material on instrumental-variable assumptions distinguishes relevance from independence and exclusion: the instruments must be informative about the endogenous regressor, and their relationship with the outcome must support the proposed causal interpretation. Those assumptions cannot generally be established from the projection formula itself.

A common mistake is to say, “The instrument predicts \(x\), so the 2SLS estimate is causal.” Prediction is only the relevance part of the argument. An instrument can strongly predict \(x\) and still be related to the structural error or affect \(y\) through a route other than \(x\). The correction is to report the calculation and the assumptions separately, and to avoid treating algebraic computability as evidence that those assumptions hold.

A second pitfall is to mistake fitted values for observed treatment values. The entries of \(\hat{x}=P_Zx\) are projections, often fractional even when \(x\) is binary. They represent instrument-space components, not a new observed treatment assignment. Finally, if the matrix to be inverted is nearly singular, a finite result should not be mistaken for a stable one. Inspect relevance and the conditioning of the relevant cross-product matrix before relying on the estimate.

Key takeaway: The instrument projection matrix is \(P_Z=Z(Z'Z)^{-1}Z'\), and the fitted endogenous regressor is \(\hat{x}=P_Zx\). For one endogenous regressor, \(\hat{\beta}_{2SLS}=(x'P_Zx)^{-1}x'P_Zy\) requires a well-defined projection and nonzero projected variation. Causal interpretation requires valid IV assumptions beyond these algebraic conditions.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. If \(n=40\) and \(Z\) has \(L=3\) linearly independent columns, what are the dimensions of \(P_Z\) and \(P_Zx\)?
  2. For a single instrument \(z\), suppose \(z'z=10\), \(z'x=5\), and \(z'y=8\). Calculate \(x'P_zx\), \(x'P_zy\), and \(\hat{\beta}_{2SLS}\).
  3. What happens to the ordinary projection formula if two columns of \(Z\) are exact duplicates?
  4. Why does a nonzero value of \(x'P_Zx\) not by itself establish a causal interpretation?

Solutions. (1) \(P_Z\) is \(40\times40\), and \(P_Zx\) is \(40\times1\). (2) \(x'P_zx=(z'x)^2/(z'z)=25/10=2.5\), while \(x'P_zy=(z'x)(z'y)/(z'z)=(5)(8)/10=4\). Thus \(\hat{\beta}_{2SLS}=4/2.5=1.6\). (3) The columns are linearly dependent, so \(Z'Z\) is singular and its ordinary inverse does not exist; use a full-rank representation of the same instrument space rather than that inverse formula. (4) It establishes projected variation, a relevance condition for calculation and identification, but not independence or exclusion. Those assumptions are needed to justify the causal interpretation.

Clinical Biostats