Cluster-Robust Standard Errors

Statistics
Introduced by
Liang & Zeger (GEE sandwich); Cameron & Miller (practitioner synthesis)
Year
1986
Type
Robust variance estimation for regression

What does it do?

Cluster-robust standard errors correct the variance of regression coefficients when observations are correlated within groups such as schools, hospitals, or regions, while leaving the point estimates unchanged.

Liang & Zeger (1986) introduced estimating equations for longitudinal data that give consistent variance estimates under mild assumptions about time dependence, an approach related to the cluster-robust estimator used here. Cameron & Miller (2015) set out the method for applied regression work. Where ordinary standard errors assume independence that the data do not have, they can be too small, and default standard errors can greatly overstate estimator precision.

The intuition behind the method

When data come grouped — pupils inside schools, patients inside hospitals, repeated observations on the same person — the observations in a group are not independent, so the model effectively has fewer truly distinct data points than the raw count suggests. Treating them as independent makes standard errors look artificially tiny and t-statistics look artificially large. Cluster-robust standard errors widen the error bars to reflect the real amount of independent information, leaving the coefficient estimates themselves unchanged.

History

Liang & Zeger (1986) extended generalized linear models to longitudinal data through an estimating-equation approach. It gives consistent estimates of the regression parameters and of their variance under mild assumptions about time dependence, and is closely related to quasi-likelihood. Cameron & Miller (2015) set out the basic cluster-robust method for OLS and the complications that arise in practice, including few clusters, multiway clustering, cluster-specific fixed effects, and estimators other than OLS.

When to use it

Use cluster-robust standard errors when observations are naturally grouped, may be correlated within those groups, and the outcome is modelled linearly as in the page's model; typical cases are panel, longitudinal, or cross-sectional designs with a defined cluster structure. The approach assumes the cluster structure is correctly specified, that clusters are mutually independent, and that the number of clusters is large. Cameron & Miller (2015) frame the method around a large number of clusters without fixing a single minimum. With few clusters the asymptotic correction can be unreliable, and alternatives such as the wild bootstrap or permutation-based inference (see the related pages) should be considered. The linear model given here does not cover binary outcomes, so confirm which estimator you are using before applying the correction to a non-linear model.

Limitations and considerations

  • Its validity rests on a large number of clusters; when the number of clusters is small, the standard errors can be unreliable.
  • The estimator as written is the uncorrected sandwich with no small-sample adjustment, so accuracy in finite samples is not guaranteed even when the cluster count looks adequate.
  • Requires the cluster structure to be correctly specified and clusters to be independent of one another; shared higher-level structure violates this.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Corrects standard errors for arbitrary correlation within clusters without requiring a model of that correlation.
  • Leaves coefficient estimates unchanged; only the variance, t-statistics, and confidence intervals change.
  • Applies to panel, longitudinal, and cross-sectional data wherever a grouping defines the dependence.

Applications

  • Education research where pupils are nested within schools or classrooms.
  • Health studies with patients grouped within hospitals or clinics.
  • Panel and longitudinal economic analyses with repeated observations on firms, regions, or individuals.

How it works

How it works

1

The outcome y for observation i in cluster g is modelled as a linear function of predictors X plus an error term. Crucially, the errors of two observations in the same cluster are allowed to be correlated, while observations in different clusters are assumed independent.

Formula
y_{ig} = X_{ig}\beta + \varepsilon_{ig}, \quad \operatorname{Cov}(\varepsilon_{ig}, \varepsilon_{jh}) = 0 \text{ for } g \neq h, \quad \operatorname{Cov}(\varepsilon_{ig}, \varepsilon_{jg}) \neq 0
2

Rather than re-fitting the model, the method keeps the point estimates β̂ and replaces the variance with a clustered sandwich. Residuals are aggregated within each cluster g, the cluster-level scores Xᵍᵀûᵍ are summed across the G clusters in the meat of the sandwich, and this is wrapped between two copies of (XᵀX)⁻¹. The estimator is designed to remain valid under arbitrary within-cluster correlation when the number of clusters is large. The formula as written contains no small-sample adjustment. Statistical software often applies additional finite-sample scaling, so reported standard errors may differ from this expression; the software documentation should be consulted for the adjustment used.

Formula
\hat{V}_{C}(\hat{\beta}) = (X^{\top}X)^{-1}\left(\sum_{g=1}^{G} X_g^{\top}\hat{u}_g\hat{u}_g^{\top}X_g\right)(X^{\top}X)^{-1}

Common pitfalls

  • Applying the correction when the number of clusters is small. With few clusters the asymptotic standard errors can be unreliable; the wild bootstrap or permutation-based inference (see the related pages) are worth considering instead.
  • Clustering at the wrong level, or treating clusters as independent when they share higher-level structure.
  • Using it in fixed-effects models without considering residual correlation. The within transformation removes unobserved heterogeneity, but serial correlation and heteroskedasticity can remain within each cluster. Cluster-robust standard errors should still be requested at the group level, and can be applied to data in deviation-from-cluster-mean form or in the least squares dummy variable form (Principles of Econometrics, 5th Edition, Sec. 15.3.2).
  • Assuming the single-level, OLS-based expression covers every design. Multiway clustering (grouping on more than one dimension at once) and estimators other than OLS are named as complications in Cameron & Miller (2015) and require variance formulas beyond the expression given here.

Frequently asked questions

Do cluster-robust standard errors change my coefficients?

No. The point estimates from the underlying regression stay exactly the same. Only the variance — and therefore the standard errors, t-statistics, and confidence intervals — is corrected for within-cluster correlation.

How many clusters do I need?

The method is justified for a large number of clusters, and Cameron & Miller (2015) do not fix a single minimum. When the number of clusters is small, the standard errors can be unreliable; in that case the wild cluster bootstrap or permutation-based inference (see the related pages) are worth considering.

At what level should I cluster?

Cluster at the level where correlation is plausibly induced — typically the sampling or treatment-assignment unit, such as the school, hospital, or region. The cluster structure must be correctly specified and clusters should be independent of one another.

How is this different from heteroscedasticity-robust standard errors?

Heteroscedasticity-robust (Huber-White) standard errors allow each observation its own error variance but still treat observations as independent. Cluster-robust standard errors go further, permitting arbitrary correlation among all observations within the same cluster.

Related methods

Sources

  1. Liang, K. Y. & Zeger, S. L. (1986). Longitudinal Data Analysis Using Generalized Linear Models. Biometrika, 73(1), 13-22.

    Open DOI reference
  2. Cameron, A. C. & Miller, D. L. (2015). A Practitioner's Guide to Cluster-Robust Inference. Journal of Human Resources, 50(2), 317-372.

    Open DOI reference
  3. Principles of Econometrics, 5th Edition, Sec. 15.3.2, p. ?