Why Cluster the 2SLS Standard Error?
In many instrumental-variable studies, observations are grouped: patients attend the same clinic, students attend the same school, or workers belong to the same firm. Outcomes or structural errors within a group may move together. Treating every observation as independent can then understate or otherwise misstate uncertainty. A cluster-robust standard error allows arbitrary dependence within each specified cluster while relying on independence across clusters.
Clustering changes the estimated sampling variability of a 2SLS coefficient, not the 2SLS coefficient itself. The coefficient is calculated from the observed outcome, regressors, and instruments. The covariance estimator is a separate calculation that accounts for how residual score contributions may co-move within groups.
2SLS and the Cluster Sandwich
Let \(y\) be the \(n \times 1\) outcome vector, \(X\) the \(n \times k\) matrix of regressors in the structural equation, and \(Z\) the \(n \times L\) instrument matrix. The columns of \(Z\) include the instruments and any included exogenous regressors used as instruments. Assume the model is \(y=X\beta+u\), the instruments satisfy the required exogeneity conditions, and the relevant matrices have full rank. Define \(P_Z=Z(Z'Z)^{-1}Z'\). The 2SLS estimator is:
Write \(u_g\) and \(Z_g\) for the residual vector and instrument matrix belonging to cluster \(g\). In practice, the residuals are estimated as \(\hat{u}=y-X\hat{\beta}_{2SLS}\), and \(\hat{u}_g\) denotes the corresponding cluster portion. Define the cluster’s transformed score contribution by:
The unadjusted cluster-robust, or CR0, covariance estimator is:
The outer product \(\hat{q}_g\hat{q}_g'\) retains the joint contribution of all observations in cluster \(g\). In particular, it includes cross-products between different observations in the same cluster. The standard error for coefficient \(j\) is \(\sqrt{\widehat{\mathrm{Var}}_{CR0}(\hat{\beta}_{2SLS})_{jj}}\).
Why the Scores Are Aggregated First
The 2SLS estimating equation is \(X'P_Z(y-X\beta)=0\). For the true coefficient, its cluster-level contribution has the form \(X'Z(Z'Z)^{-1}Z_g'u_g\). If clusters are independent, the variance of the sum of their contributions is the sum of their cluster variances. Within a cluster, however, the individual contributions need not be independent, so the cluster sum must be formed before taking an outer product.
The following calculation gives the sandwich structure. Let \(\hat{A}\) be the derivative, with sign reversed, of the estimating equation with respect to \(\beta\). A first-order expansion of the equation around the true coefficient gives an estimation error approximately equal to \(\hat{A}^{-1}\) times the sum of the cluster scores. Under independence across clusters, the variance of that sum is estimated by the sum of the cluster-score outer products. Multiplying on both sides by \(\hat{A}^{-1}\) gives:
This is a sandwich estimator: the middle “meat” reflects cluster-level score variability, and the two “bread” matrices map that variability onto the 2SLS coefficient scale. It is the same 2SLS estimator as before; only its covariance calculation uses the cluster structure.
Worked Example: A Scalar IV Estimate With Two Clusters
Consider hypothetical data for a scalar structural equation with no intercept, one regressor \(x\), and one instrument \(z\). There are four observations in two clusters. Use the unadjusted CR0 covariance estimator.
| Observation | Cluster | \(z_i\) | \(x_i\) | \(y_i\) |
|---|---|---|---|---|
| 1 | A | 1 | 1 | 2 |
| 2 | A | 1 | 2 | 1 |
| 3 | B | 2 | 2 | 4 |
| 4 | B | 2 | 4 | 3 |
For a single instrument and regressor, the 2SLS coefficient is \(\sum_i z_i y_i/\sum_i z_i x_i\). Substituting the data gives:
The fitted structural values are \(x_i\hat{\beta}_{2SLS}\). Thus the residuals are \(13/15,-19/15,26/15,-23/15\). Multiplying each residual by its instrument gives the observation-level score contributions \(13/15,-19/15,52/15,-46/15\). Sum within each cluster:
In this scalar case, the unadjusted cluster variance simplifies to the sum of squared cluster scores divided by \((\sum_i z_ix_i)^2\). Therefore:
The corresponding CR0 standard error is \(\sqrt{0.001422}=0.03771\) coefficient units. The calculation illustrates the defining operation: add the observation scores within each cluster, then square the cluster sums.
What Clustering Changes
If the cluster assignments change but \(y\), \(X\), and \(Z\) remain fixed, \(\hat{\beta}_{2SLS}\) remains fixed. The residuals and the cluster score sums are also determined by those same data and assignments. What changes is the way score contributions are grouped before their outer products are summed. If positive and negative scores cancel within a cluster, the cluster sum may be small; if they reinforce one another, it may be large. Neither pattern is guaranteed to make the clustered standard error larger than an estimator that assumes independent observations.
Worked Example: Changing the Clustering Changes the Standard Error
Use the same hypothetical observations and 2SLS coefficient from the previous calculation, but suppose each observation is treated as its own cluster. This is a different dependence assumption, not a change to the data or fitted coefficient. The four individual score contributions are \(13/15,-19/15,52/15,-46/15\). Their squared sum is:
With the same denominator, \((\sum_i z_ix_i)^2=15^2=225\), the estimated variance and standard error are:
The coefficient is still \(17/15=1.1333\), but the standard error differs from the two-cluster CR0 result because the score contributions are no longer allowed to cancel within clusters. In an actual study, clusters should be selected to reflect the sampling or assignment structure and plausible dependence—not chosen to produce a preferred standard error.
Finite-Sample Adjustments and Conditions
CR0 is the direct cluster sandwich. Some software reports a finite-sample-adjusted version instead. For example, a commonly used multiplier is \( \frac{G}{G-1}\frac{n-1}{n-K} \), where \(K\) is the number of regressors in the structural equation. Conventions differ across software and settings, so a reported clustered standard error should be accompanied by the adjustment convention when it matters. This multiplier changes the covariance estimate, not the 2SLS coefficient.
Worked Example: Applying a Specified Small-Sample Multiplier
Return to the four-observation, two-cluster calculation and use the stated multiplier, with \(G=2\), \(n=4\), and \(K=1\) regressor (there is no intercept). The multiplier is:
Applying it to the CR0 variance gives:
This adjusted value uses a particular convention; another implementation may use a different correction. More importantly, two clusters are far too few to rely confidently on ordinary large-\(G\) cluster-robust approximations. The arithmetic is valid for the specified formula, but it does not make inference with so few independent clusters reliable.
The usual justification for cluster-robust inference is asymptotic in the number of independent clusters, not simply the number of observations. It requires, in broad terms, that the clusters be independent of one another, that dependence within a cluster be accommodated by the cluster-level variance, that the relevant IV moments and identification conditions hold, and that no small number of clusters dominate the total information. With few clusters, the unadjusted sandwich can be biased and conventional large-sample reference distributions can be unreliable; a simple degrees-of-freedom or variance multiplier does not resolve every few-cluster problem.
Use the specified structural regressors and instruments to obtain \(\hat{\beta}_{2SLS}\). Do not change the point estimator merely because the standard errors will be clustered.
Form \(\hat{u}=y-X\hat{\beta}_{2SLS}\), then calculate each cluster score \(\hat{q}_g=X'Z(Z'Z)^{-1}Z_g'\hat{u}_g\).
Sum \(\hat{q}_g\hat{q}_g'\) across clusters and multiply on both sides by \(\hat{A}^{-1}\), where \(\hat{A}=X'Z(Z'Z)^{-1}Z'X\).
Take square roots of the covariance diagonal, state the clustering unit and any finite-sample correction, and assess whether the number of independent clusters supports the approximation.
Common Mistakes
- Clustering the second-stage regression as if it were ordinary least squares. The 2SLS covariance must use the IV estimating equation and instrument-based scores. A covariance calculation that ignores the 2SLS structure is not the cluster-robust 2SLS sandwich.
- Squaring observation scores before aggregating. This discards within-cluster cross-products. The required cluster contribution is \((\sum_{i\in g}\text{score}_i)(\sum_{i\in g}\text{score}_i)'\), not the sum of observation-level score outer products.
- Claiming clustering changes the coefficient. It changes the estimated covariance and standard errors, not the 2SLS coefficient computed from fixed \(y\), \(X\), and \(Z\).
- Assuming a clustered standard error must be larger. Aggregated scores can reinforce or cancel within clusters. The direction of the change depends on the data and cluster structure.
- Ignoring the number of clusters. A large observation count does not substitute for many independent clusters. With very few clusters, usual cluster-robust approximations may be unreliable.
Check Your Understanding
Use the definitions and calculations above to answer the following.
- In the cluster sandwich, why are score contributions summed within a cluster before their outer product is taken?
- For fixed \(y\), \(X\), and \(Z\), what changes if only the covariance estimator is changed from observation-level to cluster-robust?
- In the first worked example, what are the two cluster score sums, and why do they not cancel each other inside either cluster?
- Why does a large number of observations not, by itself, guarantee reliable cluster-robust inference?
- If a software package applies a finite-sample multiplier, does that multiplier change the 2SLS coefficient? What information should accompany a reported clustered standard error?