Tutorials › Econometrics (Graduate) › Why Conventional Standard Errors Fail Under Clustering

Clustered and Dependent Errors · Tutorial 123 of 952

Why Conventional Standard Errors Fail Under Clustering

Learn how shared cluster shocks create omitted covariance terms in conventional standard errors, and why the number of observations alone does not ensure reliable inference.

Advanced 10 min read

What You'll Learn

  • State the independence and variance assumptions behind conventional OLS standard errors
  • Distinguish heteroskedasticity from within-cluster error dependence
  • Derive the variance of a mean under a shared cluster shock
  • Compare observation-level and dependence-aware variance calculations
  • Recognize why many observations may still contain limited independent information
  • Separate the validity of a coefficient estimate from the validity of its standard error

Why the Observation Count Can Mislead

A regression data set may contain thousands of rows and still provide far less independent information than that row count suggests. This happens when observations in the same school, clinic, firm, village, or other group share unobserved influences. If one group experiences a common shock, the errors for its members tend to move together. Treating every row as an independent source of information can then produce standard errors that are too small and tests that reject too often.

The issue is not simply that observations within a group resemble one another in their measured characteristics. It is dependence in the regression errors, conditional on the regressors. This tutorial identifies the assumption that conventional standard errors make, shows which terms they omit when that assumption fails, and illustrates why adding rows within the same groups does not necessarily solve the problem.

The Covariance Assumption Behind Conventional Standard Errors

Write the linear regression model for \(n\) observations as \(y=X\beta+u\), where \(y\) is the outcome vector, \(X\) is the regressor matrix, \(\beta\) is the coefficient vector, and \(u\) is the error vector. Assume \(X\) has full column rank. The ordinary least squares estimator is \(\hat{\beta}=(X'X)^{-1}X'y\). For inference conditional on \(X\), assume \(E(u\mid X)=0\). This condition gives the estimator its usual conditional unbiasedness; it does not, by itself, establish that a particular standard error is valid.

Definition: The conventional homoskedastic OLS covariance formula is \(\sigma^2(X'X)^{-1}\). It relies on the conditional error covariance matrix being \(\operatorname{Var}(u\mid X)=\sigma^2 I\): every error has the same conditional variance, and errors for distinct observations have zero conditional covariance. The conventional estimated standard errors substitute an estimate of \(\sigma^2\) into this formula.

The condition \(\operatorname{Var}(u\mid X)=\sigma^2 I\) is stronger than merely requiring errors to have mean zero. It rules out both unequal error variances and any correlation across distinct observations. Earlier material on heteroskedasticity-robust inference relaxes the equal-variance part while retaining the requirement that distinct observations have zero conditional covariance. Thus an observation-level heteroskedasticity-robust calculation does not automatically handle clustering: it still does not include covariance between different rows.

For a general conditional covariance matrix \(\Omega=\operatorname{Var}(u\mid X)\), the actual conditional covariance of OLS is

$$ \operatorname{Var}(\hat{\beta}\mid X) =(X'X)^{-1}X'\Omega X(X'X)^{-1}. $$

The conventional formula follows when \(\Omega=\sigma^2 I\). If errors within groups are correlated, \(\Omega\) has off-diagonal entries for pairs of observations in the same group. Those entries contribute to the variance of \(\hat{\beta}\), but the conventional formula sets them to zero.

Shared Shocks and the Variance of a Mean

A simple grouped-outcome model makes the omitted terms visible. Suppose there are \(G\) independent clusters, with \(m\) observations in each cluster. For observation \(i\) in cluster \(g\), let

$$ Y_{gi}=\mu+a_g+e_{gi}, $$

where \(a_g\) is a cluster-specific shock shared by all members of cluster \(g\), and \(e_{gi}\) is an observation-specific error. Assume \(E(a_g)=E(e_{gi})=0\); the cluster shocks are mutually independent with variance \(\tau^2\); the observation-specific errors are mutually independent with variance \(\sigma^2\); and the two collections are independent. Then each individual outcome has variance \(\tau^2+\sigma^2\), while two different outcomes in the same cluster have covariance \(\tau^2\).

The overall sample mean is \(\bar{Y}=(Gm)^{-1}\sum_g\sum_iY_{gi}\). Substituting the model and collecting terms gives

$$ \bar{Y}-\mu =\frac{1}{G}\sum_{g=1}^{G}a_g +\frac{1}{Gm}\sum_{g=1}^{G}\sum_{i=1}^{m}e_{gi}. $$

The two terms on the right are independent. The first averages \(G\) independent cluster shocks; the second averages \(Gm\) independent observation-specific errors. Therefore

$$ \operatorname{Var}(\bar{Y}) =\frac{\tau^2}{G}+\frac{\sigma^2}{Gm}. $$

A calculation that treats all \(Gm\) outcomes as independent, but uses their correct marginal variance, instead gives \((\tau^2+\sigma^2)/(Gm)\). The difference is \((m-1)\tau^2/(Gm)\), which is positive when \(m>1\) and \(\tau^2>0\). The problem grows more pronounced as more observations are added within each cluster while the number of independent cluster shocks remains fixed.

Worked Example: A Large Sample With Shared Cluster Shocks

Hypothetical calculation. Suppose 10 clinics each contribute 20 patients, and an outcome follows \(Y_{gi}=\mu+a_g+e_{gi}\). Let the variance of a clinic shock be \(\tau^2=0.25\), and the variance of an individual error be \(\sigma^2=1\). Assume the independence and mean-zero conditions above hold. There are \(n=200\) observations, but only 10 independent clinic shocks.

The variance of the sample mean that accounts for the shared shocks is

$$ \operatorname{Var}(\bar{Y}) =\frac{0.25}{10}+\frac{1}{10(20)} =0.025+0.005=0.030. $$

Its standard error is \(\sqrt{0.030}=0.1732\) outcome units. In contrast, an independent-observation calculation using the correct marginal variance \(0.25+1=1.25\) gives

$$ \operatorname{Var}_{\mathrm{ind}}(\bar{Y}) =\frac{1.25}{200}=0.00625, \qquad SE_{\mathrm{ind}}=\sqrt{0.00625}=0.07906. $$

The independent-observation standard error is less than half the dependence-aware standard error. This comparison follows from the stated variance model; it is not a claim about any real clinic data. The 200 rows do reduce the contribution of individual noise, but they cannot average away the 10 shared clinic shocks as if those shocks had been independently redrawn for every patient.

How Correlation Enters a Regression Coefficient

For regression, the same issue appears in the score contributions that determine the sampling variation of \(\hat{\beta}\). Let \(x_i\) denote the regressor vector for observation \(i\), and let \(u_i\) be its error. Before multiplying by \((X'X)^{-1}\), the relevant random sum is \(\sum_i x_i u_i\). Its conditional variance is

$$ \operatorname{Var}\left(\sum_i x_i u_i\mid X\right) =\sum_i\sum_j x_i x_j'\operatorname{Cov}(u_i,u_j\mid X). $$

This expression contains both the \(i=j\) variance terms and the \(i\ne j\) covariance terms. The conventional formula keeps only the diagonal contribution implied by \(\sigma^2 I\). Observation-level heteroskedasticity-robust covariance calculations also build their variance estimate from individual-observation contributions; they do not include within-cluster cross-products. If two members of a cluster have positively correlated errors and their regressors point in similar directions, those cross-products can add substantially to the variance of a coefficient estimate. The size and direction of the effect depend on the regressor pattern and the covariance pattern; a smaller conventional standard error is common under positive shared shocks, but should not be asserted in every possible design.

Worked Example: A Cluster-Level Group Indicator

Hypothetical regression. Suppose an outcome is compared across eight independent work sites, four assigned to a program and four to a comparison condition. Each site contributes 25 workers. The program indicator is constant within each site. Suppose the site-level shock variance is \(0.36\), and the individual error variance is \(0.64\). Assume the shocks and individual errors satisfy the independence and mean-zero conditions stated above. For illustration, let the observed average outcomes be 2.4 units in the program sites and 1.8 units in the comparison sites. The fitted coefficient on the program indicator in this two-group regression is the difference \(2.4-1.8=0.6\) outcome units.

The variance of a site’s average outcome around its condition mean is \(0.36+0.64/25=0.3856\). The estimated condition contrast averages four independent site outcomes in each arm, so its variance under the stated model is

$$ \operatorname{Var}(\hat{\beta}_{\mathrm{program}}) =\frac{0.3856}{4}+\frac{0.3856}{4} =0.1928, \qquad SE=\sqrt{0.1928}=0.4391. $$

An independent-worker calculation using the marginal variance \(0.36+0.64=1\) would instead use 100 workers per condition:

$$ \operatorname{Var}_{\mathrm{ind}}(\hat{\beta}_{\mathrm{program}}) =\frac{1}{100}+\frac{1}{100}=0.0200, \qquad SE_{\mathrm{ind}}=\sqrt{0.0200}=0.1414. $$

The calculated coefficient remains 0.6 outcome units in either calculation; what changes is the uncertainty assigned to it. These standard errors are model-based comparisons under the stated variance components, not estimates computed from the two observed condition averages alone. Because the program indicator varies across sites rather than workers, repeatedly measuring more workers at the same sites cannot create additional independent site-level comparisons.

A Direct Check on the Omitted Covariance

The omitted terms can also be checked for two observations in the same cluster. Suppose each has variance 1 and their covariance is 0.4. For their sum, the actual variance is

$$ \operatorname{Var}(u_1+u_2) =\operatorname{Var}(u_1)+\operatorname{Var}(u_2) +2\operatorname{Cov}(u_1,u_2) =1+1+2(0.4)=2.8. $$

The diagonal-only calculation gives \(1+1=2\), omitting \(0.8\). This is the same algebraic omission that occurs in regression, where the errors are weighted by their regressor vectors before the covariance is assembled.

Worked Example: Two Correlated Score Contributions

Hypothetical scalar calculation. Consider two observations in one cluster with the same scalar regressor value \(x_1=x_2=2\), error variances \(\operatorname{Var}(u_1)=\operatorname{Var}(u_2)=1\), and covariance \(\operatorname{Cov}(u_1,u_2)=0.4\). The cluster’s score contribution is \(2u_1+2u_2\). Its variance, including the cross-observation term, is

$$ \operatorname{Var}(2u_1+2u_2) =2^2(1)+2^2(1)+2(2)(2)(0.4) =4+4+3.2=11.2. $$

The diagonal-only contribution is \(4+4=8\). It misses 3.2 units of score variance because it omits the covariance term. This calculation isolates the relevant algebra: the regression covariance also transforms score variance by multiplying on both sides by \((X'X)^{-1}\). It does not, by itself, give a complete standard error for a fitted regression.

What Clustering Changes—and What It Does Not

Within-cluster dependence primarily changes the uncertainty calculation. If \(E(u\mid X)=0\) continues to hold and \(X\) has full column rank, OLS remains conditionally unbiased, even when errors are correlated. But a valid standard error is needed to quantify uncertainty, construct intervals, and conduct tests. If a reported standard error ignores relevant dependence, a confidence interval may be too narrow and a test may reject too frequently. A large observation count does not repair a covariance formula that systematically omits nonzero terms.

The effective amount of independent information depends on how the regressors vary relative to the clusters and how errors co-move within them. For a regressor that changes only between clusters, the number of clusters is especially important for comparison: many observations within each cluster can refine its average, but do not create new independent cluster-level regressor values. This does not mean that every clustered regression has information equal to the number of clusters. It means that the raw row count alone cannot establish that conventional inference is adequate.

The appropriate response is to use an inference method whose variance calculation reflects the dependence structure supported by the study design and assumptions. Heteroskedasticity-robust standard errors alone address unequal individual variances, not arbitrary within-cluster covariance. The construction and finite-sample behavior of cluster-aware covariance estimators require additional choices and are treated separately.

Common Mistake

Wrong reasoning: “There are 5,000 observations, so the standard error must be small and the test reliable. I already used heteroskedasticity-robust standard errors, so dependence is covered.”

Correction: A row count says how many observations were recorded, not how many independent error contributions the variance calculation contains. Observation-level heteroskedasticity-robust methods allow unequal variances but still omit covariance between distinct rows. If observations share a group shock, identify that dependence and use inference that accounts for it; do not infer validity from \(n\) alone.

Key takeaway: Conventional OLS standard errors require zero conditional covariance across observations, in addition to their homoskedasticity assumption. Within-cluster dependence creates off-diagonal covariance terms. When those terms are ignored, a large number of rows can produce a misleading appearance of precision.

Check Your Understanding

Use the assumptions and calculations in this tutorial to answer each question.

  1. In the shared-shock model, which covariance terms are set to zero by the conventional independent-observation calculation?
  2. Suppose the number of observations per cluster increases while the number of clusters stays fixed. Which part of the sample-mean variance shrinks, and which part does not?
  3. Why does an observation-level heteroskedasticity-robust standard error not automatically account for two workers in the same site having correlated errors?
  4. For two errors with variance 1 each and covariance 0.25, calculate the variance of their sum and compare it with a diagonal-only calculation.
  5. Can OLS remain conditionally unbiased when errors are correlated within clusters? State the condition that supports your answer, and explain why the standard error may still be invalid.
Clinical Biostats