Skip to content
Panel Dataintermediate

Clustered Standard Errors

In a panel model yit=xitβ+ai+uity_{it} = x_{it}'\beta + a_i + u_{it}, the idiosyncratic errors for a given entity are almost always serially correlated over time, and often heteroskedastic too. That breaks the assumptions behind default OLS standard errors, and even heteroskedasticity-robust (White) standard errors stay invalid because they still treat each observation as independent. Invalid here means the reported standard errors can point the wrong way, not merely that they are understated. The fix is to cluster the variance-covariance estimator on the entity, allowing arbitrary correlation of the errors within each entity while assuming independence across entities. In Stata: `xtreg y x, fe vce(cluster id)` or `regress y x, vce(cluster id)`.

Why it matters

Picture each firm watched for ten years. A firm with a good manager tends to do well year after year, so its errors move together across time and the ten observations carry far less independent information than ten unrelated draws would. Default standard errors count all of them as fresh evidence and overstate how much you know. Clustering on the firm says treat each firm as one correlated block and lets the within-firm dependence take any shape. Crucially this changes inference only. The slope estimates do not move, and a wider standard error is honesty about precision, not a different answer about the effect.

Formulas

Cluster-robust sandwich variance
Var^(β^)=(XX)1(g=1GXgu^gu^gXg)(XX)1\widehat{\operatorname{Var}}(\hat{\beta}) = (X'X)^{-1} \Bigl( \sum_{g=1}^{G} X_g' \hat{u}_g \hat{u}_g' X_g \Bigr) (X'X)^{-1}
The bread (XX)1(X'X)^{-1} is the usual OLS piece. The meat sums over the GG entity clusters and lets the residual outer products u^gu^g\hat{u}_g \hat{u}_g' be any within-cluster pattern, so the asymptotics rely on GG being large.
Within-entity error correlation that motivates it
Corr(uit,uis)0for ts\operatorname{Corr}(u_{it}, u_{is}) \neq 0 \quad\text{for } t \neq s
Persistent firm-specific factors leave the same entity correlated across time. White standard errors assume this is zero, so they remain invalid even though they handle heteroskedasticity.

Worked examples

Scenario

Run the same fixed-effects wage regression twice, once with default and once with clustered standard errors, on a worker-by-year panel.

Solution

First `xtset id year`, then `xtreg lwage union exper, fe` followed by `xtreg lwage union exper, fe vce(cluster id)`. The coefficient on `union` is identical across the two runs, say 0.085. What changes is its standard error, which rises from roughly 0.018 to roughly 0.030, so the t-statistic falls from about 4.7 to about 2.8. The clustered version is the honest one because each worker is followed over several years.

NoteCompare the two output blocks side by side: only the standard-error column and the t-statistics move, never the point estimates.
Scenario

A pooled regression of firm investment on cash flow across many firms over time.

Solution

Run `regress invest cashflow size, vce(cluster firmid)`. The slope on `cashflow` is unchanged from the default `regress invest cashflow size`, but the clustered standard error is usually larger because each firm contributes serially correlated errors. Always confirm the design has many firms: with only a handful of clusters the cluster-robust formula is unreliable and the reported significance cannot be trusted.

Common mistakes

  • Thinking clustering changes the coefficients. It does not. The point estimates β^\hat{\beta} are numerically identical to the non-clustered run, because only the variance-covariance matrix is recomputed.
  • Believing clustered standard errors are always larger. They usually grow when within-entity errors are positively correlated, which is the common case, but this is not guaranteed and they can occasionally shrink.
  • Treating clustering as a fix for bias or endogeneity. It corrects inference only. It does nothing about omitted-variable bias, simultaneity, or measurement error, so a biased estimate stays biased with a clustered standard error attached.
  • Clustering when there are very few entities. The asymptotics run in the number of clusters GG, not the number of observations, so with only a handful of clusters the standard errors are unreliable no matter how many rows the dataset has.

Revision bullets

  • Panel errors are usually serially correlated within an entity, so default and White standard errors are invalid.
  • Clustering on the entity allows arbitrary within-entity correlation while assuming independence across entities.
  • Clustering changes inference only, the coefficients β^\hat{\beta} are unchanged.
  • Cluster-robust inference needs many clusters, the asymptotics are in GG, not in the number of observations.
  • It assumes no cross-cluster correlation. Common shocks across entities in the same year may need time effects or two-way clustering.
  • Stata: `xtreg y x, fe vce(cluster id)` or `regress y x, vce(cluster id)`.

Quick check

You re-run a fixed-effects regression with `vce(cluster id)` instead of the default standard errors. What changes?

Why are heteroskedasticity-robust (White) standard errors still invalid for a typical panel?

Connected topics

Sources

  1. Wooldridge (2019), Ch. 14
    Wooldridge, Jeffrey M. Introductory Econometrics: A Modern Approach. 7th ed. Cengage, 2019.
    Chapter 14 develops fixed and random effects for panel data and motivates cluster-robust inference that allows arbitrary serial correlation within an entity.
  2. Wooldridge (2019), Ch. 12
    Wooldridge, Jeffrey M. Introductory Econometrics: A Modern Approach. 7th ed. Cengage, 2019.
    Chapter 12 covers serial correlation and why standard errors that ignore it are invalid, the time-series counterpart of the within-entity dependence that clustering addresses.
How to cite this page
Dr. Phil's Quant Lab. (2026). Clustered Standard Errors. Derivatives Atlas. https://phucnguyenvan.com/concept/efm-clustered-se
Next concept
Serial Correlation in the Errors
Share this page
Built by Dr. Phuc V. Nguyen ·Follow on LinkedInWork with PhilEmail