Cluster-Robust vs. Robust Standard Errors in Stata Panel Regression
When panel observations within the same unit are correlated, conventional standard errors can be misleading. Learn when to use cluster-robust versus heteroskedasticity-robust SEs in Stata.
03 Aug 2025, 16:06 UTC

Your panel standard errors may be too small
You run a wage regression on panel data where each worker appears in multiple years. Stata's default ordinary least squares standard errors assume every observation is independent. In panel data, that assumption usually fails: wages for the same worker across years are likely correlated because of unobserved ability, fixed firm effects, or persistent personal circumstances. If you ignore this within-unit correlation, standard errors can be understated and t-statistics inflated, making results look more significant than they are.
The useful takeaway is to match Stata's vce() option to the correlation structure. Use cluster-robust standard errors when observations within a panel unit are correlated. Use heteroskedasticity-robust standard errors when only the error variance changes across observations. Stata does not allow both at once, so you must choose.
Cluster-robust versus heteroskedasticity-robust standard errors
vce(robust) computes heteroskedasticity-consistent standard errors. It relaxes the assumption that the error variance is constant across observations, but it still treats observations as independent. This is appropriate when you suspect variance differs by group or over time, but not when repeated observations on the same unit move together.
vce(cluster id) clusters standard errors at the panel unit level—for example, worker ID, firm ID, or school ID. It allows arbitrary correlation of errors within a cluster while assuming independence across clusters. This is the standard choice for panel regressions where the same unit appears multiple times.
Stata rejects vce(cluster id) robust. You must pick one. The practical trade-off is that cluster-robust standard errors require a sufficient number of clusters—commonly 50 or more—to be reliable, whereas heteroskedasticity-robust standard errors do not address within-unit correlation at all.
Worked example: wage regression by worker
Run these commands in the Stata Command window or a Do-file. No administrative permissions are required because this is read-only analysis. Replace your_panel_data.dta and idcode with your dataset and panel unit identifier.
* Example syntax; substitute your own data and variable names
use "your_panel_data.dta", clear
* Conventional OLS standard errors (independence assumed)
regress ln_wage age tenure c.age#c.tenure
* Cluster-robust standard errors by panel unit
regress ln_wage age tenure c.age#c.tenure, vce(cluster idcode)
* Heteroskedasticity-robust standard errors only
regress ln_wage age tenure c.age#c.tenure, vce(robust)
Expected check: compare the standard errors across the three outputs. If the cluster-robust standard errors are materially larger than the conventional ones, within-worker correlation is likely inflating the precision of the default model. If only the heteroskedasticity-robust errors differ, the issue may be changing error variance rather than repeated measures on the same unit.
Risks: clustering on too few units produces unreliable standard errors. Do not cluster at the observation level, and do not use the panel unit as both the cluster and the only regressor without checking degrees of freedom.
Diagnostics and limitations
Before choosing, inspect how many distinct panel units exist. A small number of clusters undermines cluster-robust inference. You can also run estat hettest after a regression to test for heteroskedasticity, though a significant test does not by itself decide between robust and cluster-robust errors.
Neither option fixes model misspecification. Robust standard errors do not correct for omitted variables, functional-form errors, or endogenous regressors. Cluster-robust standard errors do not solve a small-cluster problem. If your substantive conclusion changes depending on which standard error you use, report both and discuss why.
Closing: decide before you report
Start from the data structure, not the output you want. If the same unit appears repeatedly and errors within that unit are plausibly correlated, use vce(cluster id). If observations are independent but error variance varies, use vce(robust). Never request both. After selecting the standard error, use margins to interpret coefficients and export tables with estout or outreg2 for reproducible reporting.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.