Skip to content
Draft: numbers and prose are under review
Contents
Weights, Design, and Estimands

Part II Chapter 7

Whose Decision Was It? Clustering by the Source of Variation

A state law, a classroom lottery, a rainfall shock, a trade exposure: in each study the standard error has to follow whoever, or whatever, made the variation.

DataSix canonical designs · simulation with a known truth · fixest and pyfixest

Four studies, one question

The regression is estimated and the coefficient is the one you hoped for. What remains is the standard error, and here the advice conflicts. The software clustered by nothing. Your advisor says cluster by state. The referee says the policy was administered by counties, so cluster by county. A coauthor has read that two-way clustering is safer, and a methods paper says the level of treatment assignment, which none of the others mentioned. Each choice gives a different interval around the same coefficient, and none of the sources says how you would know which is right. Four published studies show how to decide.

In April 1992 New Jersey raised its minimum wage from $4.25 to $5.05 an hour and Pennsylvania did not. Card and Krueger surveyed fast-food restaurants on both sides of the border before and after, and compared the change in employment (Card and Krueger 1994). In the mid-1980s Tennessee assigned more than eleven thousand kindergarteners and their teachers, by lottery within each school, to small classes or regular ones, and followed them for years (Krueger 1999). In sub-Saharan Africa, year-to-year swings in rainfall move agricultural income, and Miguel, Satyanath, and Sergenti used them to ask whether negative income shocks raise the risk of civil conflict (Miguel, Satyanath, and Sergenti 2004). Between 1990 and 2007 Chinese import competition hit American local labor markets unevenly, according to each market's mix of industries, and Autor, Dorn, and Hanson used that unevenness to measure the effect on manufacturing employment and wages (Autor, Dorn, and Hanson 2013).

Each of these studies has a regression at its center, and each regression has a standard error. Before reading on, ask of each one: what would you cluster on, and why? A state, a school, a classroom, a country, a commuting zone, a year? Nothing? The answers differ, and the reason they differ is not the correlation of the residuals, which is present in every one of these settings at several levels at once. It is where the variation that identifies the coefficient comes from: who or what decided that this unit got this value of the regressor, at what level the decision was made, and how far its consequences reach.

Predict first

Rank the four studies by how many independent pieces of information their regression of interest really rests on. Card and Krueger surveyed about four hundred restaurants; Project STAR enrolled thousands of children in a few hundred classrooms; the conflict study covers about forty countries over twenty years; the trade study has more than seven hundred commuting zones in two periods. Which has the fewest effective observations, and is it the one with the fewest rows?

Chapter 6 worked through one such study in full, Medicaid expansion in the American Community Survey, and gave the principle: a standard error describes a repetition, and clustering is a question about which observations would move together if the study were run again, through the sampling of units or through the assignment of the regressor (Abadie et al. 2023). This chapter applies that principle across the designs economists use most, and then checks it. For each design we build a simulated version in which the source of variation is fixed by construction and the true effect is exactly zero, run every plausible standard error, and count how often a nominal 5 percent test rejects a truth it should reject 5 percent of the time. A standard error that rejects a true null half the time is describing a repetition that never happens.

A classroom lottery

Project STAR is the cleanest case because the researchers know exactly what was randomized. Within each participating school, students and teachers were assigned by lottery to a small class, a regular class, or a regular class with an aide. The unit of assignment was the class: every child in a given classroom got the same treatment, the same teacher, and the same year of shared experience. If the experiment were run again, the lottery would produce different classrooms, and a whole classroom's worth of children would change treatment together. That is the repetition the standard error should describe, and it is why Krueger clustered by classroom rather than treating each child as an independent draw.

Now change one thing. Suppose the program had instead been assigned child by child within each classroom, a tutoring voucher handed to half the children in every room. Children in the same classroom still share a teacher, a peer group, and a school, and their test scores are still correlated within the room. But the lottery no longer moves classrooms; it moves children. Under a repetition, the same classrooms exist and the same children sit in them, and only the voucher changes hands. There is no classroom-level repetition for a classroom-clustered standard error to describe, and Abadie et al. (2023) show that clustering anyway is conservative, sometimes severely so. The correlation of outcomes within classrooms is identical in the two designs. What differs is the level at which the treatment was assigned.

The simulation makes both versions. Forty schools with 4 classrooms each and 4,0004,000EstimandStudents per simulated experiment (40 schools, 4 classrooms each, 25 students per classroom)VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data students, school and classroom shocks, a treatment effect that varies by classroom around an average of exactly zero, and school fixed effects. In the child-by-child arm, the heteroskedasticity-robust standard error rejects the true null 3.9%3.9% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D0a: experiment, treatment assigned student by student; HC1, no clustering (vcov = "hetero")95% CI2.7%–5.1%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the design of the time, and clustering by classroom rejects it 0.4%0.4% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D0a: experiment, treatment assigned student by student; cluster by classroom (vcov = ~classroom)95% CI0.0%–1.1%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotevalid, coarser or more conservative than needed of the time: an interval so wide it almost never rejects anything, including a false null. In the classroom arm, the same robust standard error rejects the truth 44.5%44.5% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D0b: experiment, treatment assigned to whole classrooms; HC1, no clustering (vcov = "hetero")95% CI41.4%–47.6%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence of the time, while clustering by classroom rejects 7.6%7.6% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D0b: experiment, treatment assigned to whole classrooms; cluster by classroom (vcov = ~classroom)95% CI6.0%–9.2%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the design and clustering by school 3.7%3.7% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D0b: experiment, treatment assigned to whole classrooms; cluster by school (vcov = ~school)95% CI2.5%–4.9%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotevalid, coarser or more conservative than needed. Same schools, same children, same correlations. The lottery decides the cluster.

A state variable in an individual regression

Long before difference-in-differences became the workhorse, Moulton studied a simpler situation that is still everywhere: a regression of an individual outcome, a wage, on a variable that is measured for the individual's state, such as the state's unemployment rate or its right-to-work status (Moulton 1990). With tens of thousands of workers and fifty states, the textbook standard error treats each worker as a fresh draw of the state variable. But the state variable takes only fifty values. Every worker in Ohio has Ohio's unemployment rate, and every worker in Ohio also shares whatever unobserved conditions Ohio's labor market carries that year. Two hundred workers per state make each state's average wage precise; they do not create two hundred independent observations of the relationship between state unemployment and wages.

For a regressor that is constant within equal-sized groups, the amount by which the textbook standard error is too small has a closed form, 1+(m−1)ρ\sqrt{1 + (m-1)\rho}, where mm is the group size and ρ\rho the within-group correlation of the errors (Appendix B). It grows with the group size, which is what makes the problem so severe in large microdata. In the simulated version, 50 states with 200 people each, 10,00010,000EstimandObservations in the Moulton design (50 states, 200 people each)VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data observations, an individual covariate, and a state shock giving a within-state error correlation of 0.200.20EstimandIntraclass correlation of the error within states in the Moulton designVarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data, the formula predicts that the correct standard error is 6.39×6.39× ratioEstimandMoulton factor predicted for the design: square root of 1 + (200 - 1) x 0.2, the ratio by which the IID standard error should be inflatedVarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data the textbook one. The state-clustered standard error comes out 6.15×6.15× ratioEstimandMean ratio of the cluster by state standard error to the IID standard error across replications; D1: a regressor that varies only by state (Moulton)n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey data the textbook one on average. The textbook standard error rejects the true null 75.1%75.1% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D1: a regressor that varies only by state (Moulton); IID (fixest default) (vcov = "iid")95% CI72.4%–77.8%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence of the time. The heteroskedasticity-robust standard error rejects it 75.6%75.6% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D1: a regressor that varies only by state (Moulton); HC1, no clustering (vcov = "hetero")95% CI72.9%–78.3%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence of the time, essentially the same figure, which is a lesson in itself: heteroskedasticity was never the problem, so the robust estimator repairs nothing. Clustering by state rejects 6.1%6.1% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D1: a regressor that varies only by state (Moulton); cluster by state (vcov = ~state)95% CI4.6%–7.6%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the design of the time.

Card and Krueger's study is this design at its limit. The minimum wage varied at the state level and there were two states. Clustering by state is not an option with two clusters; there is no within-state repetition to average over and no between-state variation to estimate a variance from. The honest statement is that the study has one treated unit and one comparison unit, and that the inference rests either on the assumption that restaurants within a state are independent given the state, or on a model of state-level shocks, or on a group-level regression of the kind Donald and Lang (2007) proposed for exactly this problem. A few hundred restaurants do not change that count.

A policy that switches on and stays on

Most state-policy studies do not have one border and two years. They have a panel: fifty states observed over twenty years, a policy that switches on in some states in some years and stays on, and state and year fixed effects to absorb permanent differences between states and common shocks to all of them. The coefficient on the policy indicator is a difference-in-differences. Where does its variation come from? From the states that adopted, in the years after they adopted, compared with themselves before and with states that did not adopt. The policy was assigned to a state, for all subsequent years at once. And the state's unobserved conditions, its industry mix, its politics, its labor market, persist from one year to the next.

Bertrand, Duflo, and Mullainathan (2004) showed what this does to the standard error. They took Current Population Survey wage data, assigned placebo laws to randomly chosen states in randomly chosen years, and ran the standard difference-in-differences regression. A placebo law does nothing, so a 5 percent test should reject 5 percent of the time. With conventional standard errors it rejected far more often, because the persistent state shocks and the persistent policy indicator together mean that a state's twenty years of data are closer to one observation than to twenty. State and year fixed effects do not help: they remove a state's average and a year's average, not the shock a state carries from one year into the next.

The simulated version has 50 states, 20 years, 10 people per state-year, 10,00010,000EstimandObservations in the 50-state difference-in-differences design (50 states, 20 years, 10 people per cell)VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data observations, state shocks that follow a first-order autoregression with coefficient ρ=0.8\rho = 0.8, and a placebo policy adopted by half the states in a year drawn between the sixth and the fifteenth. The robust standard error rejects the true null 47.7%47.7% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D2a: difference-in-differences, 50 states, serially correlated state shocks; HC1, no clustering (vcov = "hetero")95% CI44.6%–50.8%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence of the time. Clustering by state-year, a common and defensible-looking choice that lets the 10 people in a cell be correlated but treats a state's consecutive years as independent, rejects 28.3%28.3% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D2a: difference-in-differences, 50 states, serially correlated state shocks; cluster by state-year (vcov = ~state^year)95% CI25.5%–31.1%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence. Clustering by state rejects 5.2%5.2% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D2a: difference-in-differences, 50 states, serially correlated state shocks; cluster by state (vcov = ~state)95% CI3.8%–6.6%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the design, and two-way clustering by state and year 4.8%4.8% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D2a: difference-in-differences, 50 states, serially correlated state shocks; two-way: state and year (vcov = ~state + year)95% CI3.5%–6.1%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotevalid, coarser or more conservative than needed. The state is where the policy was assigned and where the shocks persist. The state-year cell is a level with no mechanism behind it.

Fifty states is a comfortable number of clusters. Many policy studies have far fewer: the handful of states that adopted a particular reform, the ten countries in a currency union, the six cities in a pilot. With 10 states, and 2,0002,000EstimandObservations in the 10-state difference-in-differences designVarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data observations, clustering by state still rejects the truth 5.5%5.5% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D2b: the same design with 10 states; cluster by state (vcov = ~state)95% CI4.1%–6.9%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the design of the time in the simulation, but only because the design is friendly: equal-sized states, half of them treated, and a tt reference distribution with G−1G-1 degrees of freedom. When the treated clusters are few or unusually large, the cluster-robust standard error with t(G−1)t(G-1) critical values can fail badly, and the wild cluster bootstrap or the jackknife of Chapter 6 becomes the appropriate check (MacKinnon and Webb 2017; MacKinnon, Nielsen, and Webb 2023). The count of clusters is part of the design, not a detail of the software.

One coefficient, six standard errors

Placebo state policy in a simulated 50-state panel; standard error relative to the IID value

  • Naive
  • Design-based
IID (fixest 0.13+ default): 1.00×IID (fixest 0.13+ default)1.00×HC1: 1.00×HC11.00×Cluster by state-year: 1.52×Cluster by state-year1.52×Two-way: state and year: 2.52×Two-way: state and year2.52×Cluster by state (fixest <= 0.12 default): 2.57×Cluster by state (fixest <= 0.12 defa…2.57×Driscoll-Kraay, 4 lags: 1.71×Driscoll-Kraay, 4 lags1.71×Standard error × IID standard errorIID (fixest 0.13+ default): 1.00×IID (fixest 0.13+ default)1.00×HC1: 1.00×HC11.00×Cluster by state-year: 1.52×Cluster by state-year1.52×Two-way: state and year: 2.52×Two-way: state and year2.52×Cluster by state (fixest <= 0.12 default): 2.57×Cluster by state (fixest <= 0.12 default)2.57×Driscoll-Kraay, 4 lags: 1.71×Driscoll-Kraay, 4 lags1.71×Standard error × IID standard error
Show data
CategoryValue
IID (fixest 0.13+ default)1.00×
HC11.00×
Cluster by state-year1.52×
Two-way: state and year2.52×
Cluster by state (fixest <= 0.12 default)2.57×
Driscoll-Kraay, 4 lags1.71×
Figure 7.1.The state-policy panel with one draw of data. Only the variance estimator changes. Clustering by state, the level at which the placebo policy was assigned, gives a standard error several times the textbook value; the intermediate options describe neither the sampling nor the assignment.Note: Same data, same coefficient; only the vcov argument to feols changes.Source: Simulation: sim.R with R fixest (this chapter); no survey data

Two dimensions that do not nest

A regression of bilateral trade flows on tariffs or distance has a row for every exporter-importer pair. Everything Germany exports shares German shocks; everything shipped to Brazil shares Brazilian shocks. Neither group contains the other. A firm-year panel in finance has firm shocks that persist over time and year shocks that hit every firm; Petersen (2009) documented how often published standard errors accounted for one and not the other. A regression of outcomes by region and industry, of the kind that arises when a policy varies by industry and its consequences are measured across places, has regional shocks and industry shocks in the same cell.

When the two dimensions are nested, the rule is to cluster at the coarser level, because the coarser cluster contains the finer one. When they are not, no single clustering covers both, and Cameron, Gelbach, and Miller (2011) showed how to combine them: the variance clustered by the first dimension, plus the variance clustered by the second, minus the variance clustered by their intersection. The simulated version has 50 regions and 30 industries, 1,5001,500EstimandRegion-by-industry cells (50 regions, 30 industries)VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data cells, with a region component and an industry component in both the regressor and the error. The robust standard error rejects the truth 40.7%40.7% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D3: region and industry shocks in both regressor and error; HC1, no clustering (vcov = "hetero")95% CI37.7%–43.7%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence of the time. Clustering by region alone rejects 19.1%19.1% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D3: region and industry shocks in both regressor and error; cluster by region (vcov = ~region)95% CI16.7%–21.5%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence and by industry alone 11.9%11.9% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D3: region and industry shocks in both regressor and error; cluster by industry (vcov = ~industry)95% CI9.9%–13.9%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence; each captures one dimension and misses the other. Two-way clustering rejects 5.8%5.8% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D3: region and industry shocks in both regressor and error; two-way: region and industry (vcov = ~region + industry)95% CI4.4%–7.2%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the design.

Two things go wrong in practice. Analysts sometimes cluster by the intersection, region-by-industry, believing it to be the more conservative choice; with one observation per cell it is the robust standard error under another name. And the two-way variance is a difference of matrices and need not be positive definite, so software repairs it, and reports that it has.

Shocks that travel over the map

Rainfall does not respect borders. When Miguel, Satyanath, and Sergenti instrument economic growth with rainfall growth, a dry year in one country is usually a dry year in its neighbors, and so are the unobserved conditions that raise the risk of conflict. Distance to a new road, exposure to a nearby mine, a neighboring county's policy: each of these regressors varies smoothly over space, and so do the unobserved determinants of the outcomes they explain. The natural clusters, countries or counties or states, are administrative lines drawn for other reasons, and a point just inside one is as correlated with its neighbor across the line as with its neighbor inside it.

Conley (1999) proposed a variance estimator for this case that dispenses with groups. Any two observations may be correlated, with a weight that declines with the distance between them and reaches zero at a cutoff chosen by the analyst. The simulated version places 1,6001,600EstimandLattice points in the spatial design (40 by 40, half a degree apart)VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data points on a lattice half a degree apart, roughly 40 to 55 kilometers, and draws the regressor and the error as spatial fields whose correlation decays exponentially with a range of 150 kilometers, plus white noise. It also draws 25 arbitrary administrative blocks of 8 by 8 points, the kind of unit an analyst clusters by for want of anything better.

The robust standard error rejects the truth 51.1%51.1% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D4: spatially correlated regressor and error on a lattice; HC1, no clustering (vcov = "hetero")95% CI48.0%–54.2%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence of the time. Clustering by the 25 blocks rejects 13.2%13.2% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D4: spatially correlated regressor and error on a lattice; cluster by 25 arbitrary blocks (vcov = ~block)95% CI11.1%–15.3%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence: the blocks catch correlation among points that happen to share a block and none across a boundary. A distance cutoff of 100 kilometers, shorter than the range of the dependence, rejects 22.7%22.7% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D4: spatially correlated regressor and error on a lattice; Conley, 100 km cutoff (vcov = conley(100) ~ lat + lon)95% CI20.1%–25.3%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence. A cutoff of 300 kilometers, twice the range, rejects 9.5%9.5% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D4: spatially correlated regressor and error on a lattice; Conley, 300 km cutoff (vcov = conley(300) ~ lat + lon)95% CI7.7%–11.3%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the design, the best of the options and still a few points above nominal, as kernel estimators of a variance tend to be in finite samples. A cutoff of 600 kilometers rejects 19.3%19.3% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D4: spatially correlated regressor and error on a lattice; Conley, 600 km cutoff (vcov = conley(600) ~ lat + lon)95% CI16.9%–21.7%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotecutoff too wide: the variance estimate is itself noisy, worse than 300: a wider window averages over far more pairs and the variance estimate itself becomes noisy. The cutoff is a bandwidth, with the usual trade-off, and reporting several is part of the analysis. Barrios et al. (2012) make the connection back to state policies: when outcomes are spatially correlated across state lines, clustering by state does not remove all of the dependence, and whether the remainder matters depends on how the policy was assigned across the map.

Shocks that hit everyone at once

Cross-country growth regressions, macro panels, and asset-pricing panels share a different structure. A recession, an oil price, a change in the world interest rate hits every unit in the same period, persists into the next, and hits some units harder than others. Unit and period fixed effects remove each unit's average and each period's average exposure, but not the part of the common shock that a heavily exposed unit feels more than a lightly exposed one, and that part is correlated across all units within a period and across neighboring periods. Driscoll and Kraay (1998) extended the Newey–West estimator to this setting: sum the scores across all units within each period, then apply a kernel over time to the period sums (Newey and West 1987). The period sums are the effective observations, so the estimator needs a long time dimension.

The simulated version has 50 units over 400 periods, a monthly panel of a few decades, with 20,00020,000EstimandObservations in the common-shock panel (50 units, 400 periods)VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data observations, unit and period fixed effects, and two independent first-order autoregressive common factors with ρ=0.7\rho = 0.7, one entering the regressor and one the error, with the same unit-specific loadings on both, so that units exposed to the one shock are exposed to the other. Clustering by unit rejects the truth 39.9%39.9% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D5: panel with persistent common shocks in regressor and error; cluster by unit (vcov = ~id)95% CI36.9%–42.9%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence of the time and Newey–West within unit 37.5%37.5% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D5: panel with persistent common shocks in regressor and error; Newey-West within unit, 8 lags (vcov = NW(8) ~ id + time)95% CI34.5%–40.5%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence: both allow any persistence within a unit and no correlation between units in the same period, which is where the dependence lives. Two-way clustering by unit and period rejects 16.9%16.9% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D5: panel with persistent common shocks in regressor and error; two-way: unit and period (vcov = ~id + time)95% CI14.6%–19.2%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence; the period clusters capture the contemporaneous correlation across units and treat consecutive periods as independent, which the persistent factors violate. Driscoll–Kraay with eight lags rejects 7.3%7.3% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D5: panel with persistent common shocks in regressor and error; Driscoll-Kraay, 8 lags (vcov = DK(8) ~ time)95% CI5.7%–8.9%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the design, the closest of the options and still above nominal, for the same finite-sample reason as the spatial kernel. In a shorter panel the same design gave the same ranking with every rate higher.

A design that is not on the menu

The China shock study has a regressor that is neither a state policy nor a smooth field over the map. Each commuting zone's exposure to Chinese imports is a weighted average of national industry-level import shocks, weighted by the zone's initial employment shares in those industries. Two commuting zones with similar industry mixes, one in North Carolina and one in Ohio, receive nearly the same shock, whatever the distance between them, and their outcomes are correlated for the same reason. Adão, Kolesár, and Morales (2019) showed that in this shift-share design the repetition that matters is the draw of industry shocks, not the draw of regions, and that clustering by state or by commuting zone can understate the uncertainty badly while a spatial kernel misses it entirely, since the dependence follows industry mix rather than geography. The remedy organizes the inference around the shocks themselves, at the industry level. No entry on the ordinary variance menu does this, and the point generalizes: when the regressor is built from a small number of underlying shocks, count the shocks.

Predict first

Across the six simulated designs, which is the most often wrong: the textbook standard error, the heteroskedasticity-robust one, or one-way clustering at the finest level available? And is there any design in which clustering at a coarser level than the design requires produces a rejection rate above 5 percent?

How often a nominal 5% test rejects a true null

1,000 simulated data sets per design; 95% Monte Carlo intervals

  • Design-based
  • Naive
EXPERIMENT, STUDENTS RANDOMIZEDHC1, no clustering: 3.9% (95% CI 2.7%–5.1%), n = 1,000HC1, no clusteringcluster by classroom: 0.4% (95% CI 0.0%–1.1%), n = 1,000cluster by classroomcluster by school: 0.5% (95% CI 0.0%–1.2%), n = 1,000cluster by schoolEXPERIMENT, CLASSROOMS RANDOMIZEDHC1, no clustering: 44.5% (95% CI 41.4%–47.6%), n = 1,000HC1, no clusteringcluster by classroom: 7.6% (95% CI 6.0%–9.2%), n = 1,000cluster by classroomcluster by school: 3.7% (95% CI 2.5%–4.9%), n = 1,000cluster by schoolSTATE-LEVEL REGRESSORIID (fixest default): 75.1% (95% CI 72.4%–77.8%), n = 1,000IID (fixest default)HC1, no clustering: 75.6% (95% CI 72.9%–78.3%), n = 1,000HC1, no clusteringcluster by state: 6.1% (95% CI 4.6%–7.6%), n = 1,000cluster by stateDID, 50 STATES, AR(1) SHOCKSHC1, no clustering: 47.7% (95% CI 44.6%–50.8%), n = 1,000HC1, no clusteringcluster by state-year: 28.3% (95% CI 25.5%–31.1%), n = 1,000cluster by state-yearcluster by state: 5.2% (95% CI 3.8%–6.6%), n = 1,000cluster by statetwo-way: state and year: 4.8% (95% CI 3.5%–6.1%), n = 1,000two-way: state and yearDID, 10 STATES, AR(1) SHOCKSHC1, no clustering: 48.1% (95% CI 45.0%–51.2%), n = 1,000HC1, no clusteringcluster by state-year: 30.8% (95% CI 27.9%–33.7%), n = 1,000cluster by state-yearcluster by state: 5.5% (95% CI 4.1%–6.9%), n = 1,000cluster by statetwo-way: state and year: 5.9% (95% CI 4.4%–7.4%), n = 1,000two-way: state and yearREGION X INDUSTRY CELLSHC1, no clustering: 40.7% (95% CI 37.7%–43.7%), n = 1,000HC1, no clusteringcluster by region: 19.1% (95% CI 16.7%–21.5%), n = 1,000cluster by regioncluster by industry: 11.9% (95% CI 9.9%–13.9%), n = 1,000cluster by industrytwo-way: region and industry: 5.8% (95% CI 4.3%–7.2%), n = 1,000two-way: region and industrySPATIAL LATTICE, 150 KM RANGEHC1, no clustering: 51.1% (95% CI 48.0%–54.2%), n = 1,000HC1, no clusteringcluster by 25 arbitrary blocks: 13.2% (95% CI 11.1%–15.3%), n = 1,000cluster by 25 arbitrary blocksConley, 100 km cutoff: 22.7% (95% CI 20.1%–25.3%), n = 1,000Conley, 100 km cutoffConley, 300 km cutoff: 9.5% (95% CI 7.7%–11.3%), n = 1,000Conley, 300 km cutoffConley, 600 km cutoff: 19.3% (95% CI 16.9%–21.8%), n = 1,000Conley, 600 km cutoffPANEL, PERSISTENT COMMON SHOCKScluster by unit: 39.9% (95% CI 36.9%–42.9%), n = 1,000cluster by unitNewey-West within unit, 8 lags: 37.5% (95% CI 34.5%–40.5%), n = 1,000Newey-West within unit, 8 lagstwo-way: unit and period: 16.9% (95% CI 14.6%–19.2%), n = 1,000two-way: unit and periodDriscoll-Kraay, 8 lags: 7.3% (95% CI 5.7%–8.9%), n = 1,000Driscoll-Kraay, 8 lagsRejection rate of a nominal 5% test (true effect is zero)EXPERIMENT, STUDENTS RANDOMIZEDHC1, no clustering: 3.9% (95% CI 2.7%–5.1%), n = 1,000HC1, no clusteringcluster by classroom: 0.4% (95% CI 0.0%–1.1%), n = 1,000cluster by classroomcluster by school: 0.5% (95% CI 0.0%–1.2%), n = 1,000cluster by schoolEXPERIMENT, CLASSROOMS RANDOMIZEDHC1, no clustering: 44.5% (95% CI 41.4%–47.6%), n = 1,000HC1, no clusteringcluster by classroom: 7.6% (95% CI 6.0%–9.2%), n = 1,000cluster by classroomcluster by school: 3.7% (95% CI 2.5%–4.9%), n = 1,000cluster by schoolSTATE-LEVEL REGRESSORIID (fixest default): 75.1% (95% CI 72.4%–77.8%), n = 1,000IID (fixest default)HC1, no clustering: 75.6% (95% CI 72.9%–78.3%), n = 1,000HC1, no clusteringcluster by state: 6.1% (95% CI 4.6%–7.6%), n = 1,000cluster by stateDID, 50 STATES, AR(1) SHOCKSHC1, no clustering: 47.7% (95% CI 44.6%–50.8%), n = 1,000HC1, no clusteringcluster by state-year: 28.3% (95% CI 25.5%–31.1%), n = 1,000cluster by state-yearcluster by state: 5.2% (95% CI 3.8%–6.6%), n = 1,000cluster by statetwo-way: state and year: 4.8% (95% CI 3.5%–6.1%), n = 1,000two-way: state and yearDID, 10 STATES, AR(1) SHOCKSHC1, no clustering: 48.1% (95% CI 45.0%–51.2%), n = 1,000HC1, no clusteringcluster by state-year: 30.8% (95% CI 27.9%–33.7%), n = 1,000cluster by state-yearcluster by state: 5.5% (95% CI 4.1%–6.9%), n = 1,000cluster by statetwo-way: state and year: 5.9% (95% CI 4.4%–7.4%), n = 1,000two-way: state and yearREGION X INDUSTRY CELLSHC1, no clustering: 40.7% (95% CI 37.7%–43.7%), n = 1,000HC1, no clusteringcluster by region: 19.1% (95% CI 16.7%–21.5%), n = 1,000cluster by regioncluster by industry: 11.9% (95% CI 9.9%–13.9%), n = 1,000cluster by industrytwo-way: region and industry: 5.8% (95% CI 4.3%–7.2%), n = 1,000two-way: region and industrySPATIAL LATTICE, 150 KM RANGEHC1, no clustering: 51.1% (95% CI 48.0%–54.2%), n = 1,000HC1, no clusteringcluster by 25 arbitrary blocks: 13.2% (95% CI 11.1%–15.3%), n = 1,000cluster by 25 arbitrary blocksConley, 100 km cutoff: 22.7% (95% CI 20.1%–25.3%), n = 1,000Conley, 100 km cutoffConley, 300 km cutoff: 9.5% (95% CI 7.7%–11.3%), n = 1,000Conley, 300 km cutoffConley, 600 km cutoff: 19.3% (95% CI 16.9%–21.8%), n = 1,000Conley, 600 km cutoffPANEL, PERSISTENT COMMON SHOCKScluster by unit: 39.9% (95% CI 36.9%–42.9%), n = 1,000cluster by unitNewey-West within unit, 8 lags: 37.5% (95% CI 34.5%–40.5%), n = 1,000Newey-West within unit, 8 lagstwo-way: unit and period: 16.9% (95% CI 14.6%–19.2%), n = 1,000two-way: unit and periodDriscoll-Kraay, 8 lags: 7.3% (95% CI 5.7%–8.9%), n = 1,000Driscoll-Kraay, 8 lagsRejection rate of a nominal 5% test (true effect is zero)
Show data
GroupEstimate forEstimate95% CIn
Experiment, students randomizedHC1, no clustering3.9%2.7%–5.1%1,000
Experiment, students randomizedcluster by classroom0.4%0.0%–1.1%1,000
Experiment, students randomizedcluster by school0.5%0.0%–1.2%1,000
Experiment, classrooms randomizedHC1, no clustering44.5%41.4%–47.6%1,000
Experiment, classrooms randomizedcluster by classroom7.6%6.0%–9.2%1,000
Experiment, classrooms randomizedcluster by school3.7%2.5%–4.9%1,000
State-level regressorIID (fixest default)75.1%72.4%–77.8%1,000
State-level regressorHC1, no clustering75.6%72.9%–78.3%1,000
State-level regressorcluster by state6.1%4.6%–7.6%1,000
DiD, 50 states, AR(1) shocksHC1, no clustering47.7%44.6%–50.8%1,000
DiD, 50 states, AR(1) shockscluster by state-year28.3%25.5%–31.1%1,000
DiD, 50 states, AR(1) shockscluster by state5.2%3.8%–6.6%1,000
DiD, 50 states, AR(1) shockstwo-way: state and year4.8%3.5%–6.1%1,000
DiD, 10 states, AR(1) shocksHC1, no clustering48.1%45.0%–51.2%1,000
DiD, 10 states, AR(1) shockscluster by state-year30.8%27.9%–33.7%1,000
DiD, 10 states, AR(1) shockscluster by state5.5%4.1%–6.9%1,000
DiD, 10 states, AR(1) shockstwo-way: state and year5.9%4.4%–7.4%1,000
Region x industry cellsHC1, no clustering40.7%37.7%–43.7%1,000
Region x industry cellscluster by region19.1%16.7%–21.5%1,000
Region x industry cellscluster by industry11.9%9.9%–13.9%1,000
Region x industry cellstwo-way: region and industry5.8%4.3%–7.2%1,000
Spatial lattice, 150 km rangeHC1, no clustering51.1%48.0%–54.2%1,000
Spatial lattice, 150 km rangecluster by 25 arbitrary blocks13.2%11.1%–15.3%1,000
Spatial lattice, 150 km rangeConley, 100 km cutoff22.7%20.1%–25.3%1,000
Spatial lattice, 150 km rangeConley, 300 km cutoff9.5%7.7%–11.3%1,000
Spatial lattice, 150 km rangeConley, 600 km cutoff19.3%16.9%–21.8%1,000
Panel, persistent common shockscluster by unit39.9%36.9%–42.9%1,000
Panel, persistent common shocksNewey-West within unit, 8 lags37.5%34.5%–40.5%1,000
Panel, persistent common shockstwo-way: unit and period16.9%14.6%–19.2%1,000
Panel, persistent common shocksDriscoll-Kraay, 8 lags7.3%5.7%–8.9%1,000
Figure 7.2.In every design the estimator that follows the source of variation sits near the 5 percent line. Estimators that ignore a dimension of the dependence sit far to the right; estimators that are coarser than the design requires sit at or below the line; the two kernel estimators land a few points above it.Note: Highlighted rows match the design; muted rows are valid but coarser than needed; the rest miss part of the dependence.Source: Simulation: sim.R with R fixest (this chapter); no survey data

Each design draws 1,0001,000 replicationsEstimandNumber of simulated data sets per designVarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey dataNoteEach design is drawn from its own fixed seed data sets, so the Monte Carlo standard error of a rejection rate near 5 percent is about 0.7%0.7% percentage pointsEstimandMonte Carlo standard error of a rejection rate whose true value is 5%n1,000VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data points: a rate near 5 percent is a pass, and a rate of 10 percent is not noise. The grid below holds the same results with the mean ratio of each standard error to the textbook value, which measures how much of the uncertainty the textbook formula never saw. Sort by any column, or filter to one design.

The menu, scored
Rejection rate of a nominal 5% test under a true null, and the mean standard error relative to IID
Verdict
30 of 30 rows
Table of eight designs by their candidate vcov arguments with rejection rates and standard-error ratios.
fixest
Experiment, students randomizedHC1, no clusteringvcov = "hetero"
3.9%
1.00×Matches the design
Experiment, students randomizedcluster by classroomvcov = ~classroom
0.4%
1.45×Valid, coarser
Experiment, students randomizedcluster by schoolvcov = ~school
0.5%
1.46×Valid, coarser
Experiment, classrooms randomizedHC1, no clusteringvcov = "hetero"
44.5%
1.00×Misses dependence
Experiment, classrooms randomizedcluster by classroomvcov = ~classroom
7.6%
2.47×Matches the design
Experiment, classrooms randomizedcluster by schoolvcov = ~school
3.7%
2.84×Valid, coarser
State-level regressorIID (fixest default)vcov = "iid"
75.1%
1.00×Misses dependence
State-level regressorHC1, no clusteringvcov = "hetero"
75.6%
1.00×Misses dependence
State-level regressorcluster by statevcov = ~state
6.1%
6.15×Matches the design
DiD, 50 states, AR(1) shocksHC1, no clusteringvcov = "hetero"
47.7%
1.00×Misses dependence
DiD, 50 states, AR(1) shockscluster by state-yearvcov = ~state^year
28.3%
1.48×Misses dependence
DiD, 50 states, AR(1) shockscluster by statevcov = ~state
5.2%
2.74×Matches the design
DiD, 50 states, AR(1) shockstwo-way: state and yearvcov = ~state + year
4.8%
2.71×Valid, coarser
DiD, 10 states, AR(1) shocksHC1, no clusteringvcov = "hetero"
48.1%
1.00×Misses dependence
DiD, 10 states, AR(1) shockscluster by state-yearvcov = ~state^year
30.8%
1.42×Misses dependence
DiD, 10 states, AR(1) shockscluster by statevcov = ~state
5.5%
2.58×Matches the design
DiD, 10 states, AR(1) shockstwo-way: state and yearvcov = ~state + year
5.9%
2.54×Valid, coarser
Region x industry cellsHC1, no clusteringvcov = "hetero"
40.7%
1.00×Misses dependence
Region x industry cellscluster by regionvcov = ~region
19.1%
1.53×Misses dependence
Region x industry cellscluster by industryvcov = ~industry
11.9%
1.79×Misses dependence
Region x industry cellstwo-way: region and industryvcov = ~region + industry
5.8%
2.15×Matches the design
Spatial lattice, 150 km rangeHC1, no clusteringvcov = "hetero"
51.1%
0.99×Misses dependence
Spatial lattice, 150 km rangecluster by 25 arbitrary blocksvcov = ~block
13.2%
2.24×Misses dependence
Spatial lattice, 150 km rangeConley, 100 km cutoffvcov = conley(100) ~ lat + lon
22.7%
1.89×Misses dependence
Spatial lattice, 150 km rangeConley, 300 km cutoffvcov = conley(300) ~ lat + lon
9.5%
2.52×Matches the design
Spatial lattice, 150 km rangeConley, 600 km cutoffvcov = conley(600) ~ lat + lon
19.3%
2.21×Cutoff too wide
Panel, persistent common shockscluster by unitvcov = ~id
39.9%
1.12×Misses dependence
Panel, persistent common shocksNewey-West within unit, 8 lagsvcov = NW(8) ~ id + time
37.5%
1.17×Misses dependence
Panel, persistent common shockstwo-way: unit and periodvcov = ~id + time
16.9%
1.75×Misses dependence
Panel, persistent common shocksDriscoll-Kraay, 8 lagsvcov = DK(8) ~ time
7.3%
2.38×Matches the design

Bars show the share of simulated data sets in which a nominal 5% test rejected a true null; the tick marks 5%. Click a column heading to sort.

Source: Simulation: sim.R with R fixest (this chapter); no survey data

What the examples have in common

The six designs agree on one procedure, and it begins with the regressor rather than the residuals.

  1. Ask who or what decided the value of the regressor, and at what level. A legislature decided for a state; a lottery decided for a classroom; the weather decided for a region of the map; a national trade shock decided for every place with a given industry mix. That level is the first candidate for the cluster. Correlated residuals below it do not by themselves call for clustering, and correlated residuals above it are not removed by fixed effects.
  2. In a nested hierarchy, follow the assignment up. Children in classrooms in schools: cluster by classroom when classrooms are assigned, by school when schools are, and not at all when children are, whatever the intraclass correlation. This is the sense in which the "cluster at the coarser level" rule holds, inside the full sampling-and-assignment statement (Abadie et al. 2023).
  3. When two dimensions of dependence do not nest, use both. Exporter and importer, firm and year, region and industry. Two-way clustering is not clustering by the intersection.
  4. When dependence follows a distance rather than a group, use a kernel. Over the map for spatial shocks, over time within a unit for serial correlation, over time across all units for common shocks. The cutoff should cover the range of the dependence, and a much wider cutoff degrades the estimate rather than protecting it.
  5. Count the clusters before trusting the answer. With fewer than about 50, report the jackknife or the wild cluster bootstrap beside the conventional estimate; with fewer than about 10, randomization inference or a group-level model (Cameron and Miller 2015; MacKinnon, Nielsen, and Webb 2023). Two states is one comparison, however many restaurants.
  6. When the regressor is built from a few underlying shocks, count the shocks. Shift-share exposures, and any design in which a national or global shock reaches units through a known exposure, need inference organized around the shocks (Adão, Kolesár, and Morales 2019).
  7. Write the argument down. The standard error in a published table should come from a choice the analyst made and can defend in the terms above, never from a software default.

The worksheet at the end of Chapter 6 asks for the same inputs, the sampling mechanism, the assignment mechanism, and the number of clusters, and returns the same recommendations. This chapter is the evidence that the recommendations hold when the truth is known.

The tools

Everything above is one argument to one function. In fixest the argument is vcov; pyfixest mirrors it; Stata's vce() option covers most of the same ground (Bergé, Butts, and McDermott 2026).

What it allowsfixestpyfixest
Independent, identically distributed errorsvcov = "iid"vcov = "iid"
Any heteroskedasticity, no correlation (HC1)vcov = "hetero"vcov = "hetero"
Any correlation within a group, none between (CRV1)vcov = ~statevcov = {"CRV1": "state"}
Correlation within either of two non-nested groupsvcov = ~region + industryvcov = {"CRV1": "region+industry"}
Correlation within the intersection of two groupsvcov = ~state^yearvcov = {"CRV1": "state_year"} on a constructed column
Serial correlation within a unit up to a lag (Newey–West)vcov = NW(4) ~ id + timevcov = "NW", vcov_kwargs = {"lag": 4, ...}
Cross-sectional and serial correlation in a panel (Driscoll–Kraay)vcov = DK(4) ~ timevcov = "DK", vcov_kwargs = {"lag": 4, ...}
Spatial correlation within a distance cutoff (Conley)vcov = conley(300) ~ lat + lonnot yet available
Leave-one-cluster-out jackknife (CRV3)not built in; the summclust package computes it for fixest modelsvcov = {"CRV3": "state"}

Two facts about the tool matter more than any row. The default moved: through version 0.12, fixest clustered by the first fixed effect whenever a model had fixed effects, and since 0.13.0 the default is IID for every estimation, so the same script reports different standard errors depending on which version is installed. pyfixest 0.60 also reports IID unless told otherwise. And the small-sample correction is built in: fixest's defaults scale a clustered variance by G/(G−1)G/(G-1) and use a tt distribution on G−1G - 1 degrees of freedom, where GG is the number of clusters or the smaller of the two counts under two-way clustering, matching Stata's conventions (Cameron and Miller 2015). Every rejection rate in this chapter includes that adjustment.

r
library(fixest)
f <- feols(y ~ d | state + year, data = panel)
etable(f, vcov = list("iid", "hetero", ~state^year, ~state + year, ~state, DK(4) ~ year))
python
import pyfixest as pf
panel["state_year"] = panel["state"].astype(str) + "_" + panel["year"].astype(str)
for v in ["iid", "hetero", {"CRV1": "state_year"}, {"CRV1": "state+year"}, {"CRV1": "state"}]:
    print(v, pf.feols("y ~ d | state + year", data=panel, vcov=v).se()["d"])

The explorer below runs that loop on one draw of the state-policy panel: 10,00010,000EstimandObservations in the opening data set (50 states, 20 years, 10 people per state-year)VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data observations, 2525EstimandStates that adopt the (placebo) policy in the opening data setVarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data adopting states, a coefficient of −0.015−0.015EstimandCoefficient on the placebo policy indicator in the opening data set (true value 0)n10,000VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data whose true value is zero. Under the textbook variance its p-value is 0.7140.714Estimandp-value for no effect under IID (fixest 0.13+ default), opening draw (fixest reference distribution)VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data; clustered by state, 0.8870.887Estimandp-value for no effect under Cluster by state (fixest <= 0.12 default), opening draw (fixest reference distribution)VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data. Across the options the largest standard error is 2.57×2.57× ratioEstimandLargest standard error divided by the smallest across the opening draw's vcov argumentsVarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data the smallest. Each choice shows what the estimator lets the errors do, what it returns, and the one argument that changed.

One coefficient, one argument, six answers
The opening panel: 50 states, 20 years, a placebo policy with a true effect of zero. Choose an estimator.
Variance estimator
IID (fixest 0.13+ default)
Misses part of the dependence
0.041
standard error
× IID
1.00×
95% interval
−0.094–0.065
p (true effect 0)
0.714
does not reject

Every observation is an independent draw with the same error variance. Ten people in the same state and year, and the same state in consecutive years, are treated as unrelated.

−0.30−0.20−0.100.000.100.20IID −0.094–0.065HC1 −0.095–0.065Cluster by state-year −0.136–0.106Two-way: state and year −0.228–0.199Cluster by state −0.225–0.195Driscoll-Kraay, 4 lags −0.160–0.130True effect
The same call, one argument changed
Language
feols(y ~ d | state + year, data = panel, vcov = "iid")

Ratios are relative to the IID standard error. Verdicts follow the design: the policy is assigned to states and state shocks persist across years.

What is held fixed. The data set, the regression, and the coefficient (−0.015, on 10,000 observations in 50 states over 20 years, 25 of them adopting the placebo policy). Only the variance estimator changes, so every difference between the panels is a difference in what the standard error assumes about which observations move together.

The chapter reports fixest's answers. The opening draw's IID, HC1, state-year, state, and two-way standard errors were recomputed with pyfixest and agree to the displayed precision; the comparison is in the chapter's manifest. Conley standard errors are not yet implemented in pyfixest.
Analysis Ledger

Six designs, one question: how often does a nominal 5% test reject a true null?

Target population
None. Each design is a synthetic data-generating process built so that the source of variation is known; the lab asks which variance estimator describes it
Estimand
For each design and each candidate vcov argument, the probability that a 5% test of the true null (coefficient = 0) rejects, over repeated draws from the design
Estimator
Share of 1,000 independent draws in which fixest's p-value, under that vcov argument and its default small-sample corrections, is below 0.05
Explicit weights
None (unweighted OLS in every design)
Implicit weights
None beyond OLS
Source of randomness
The design itself: new shocks, new assignment, new regressor in every draw; nothing is sampled from a real population
Variance estimator
Monte Carlo: binomial standard error about 0.7% at a true rate of 5%
Assumptions
The designs are stylized: Gaussian shocks, equal cluster sizes, AR(1) persistence, and an exponential spatial covariance. They fix the mechanism, not the magnitude, of each problem
Numbers reported
  • 1,0001,000 replicationsEstimandNumber of simulated data sets per designVarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey dataNoteEach design is drawn from its own fixed seedreplications
  • 0.7%0.7% percentage pointsEstimandMonte Carlo standard error of a rejection rate whose true value is 5%n1,000VarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey datapercentage points
  • 75.1%75.1% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D1: a regressor that varies only by state (Moulton); IID (fixest default) (vcov = "iid")95% CI72.4%–77.8%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependencerejection rate
  • 6.1%6.1% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D1: a regressor that varies only by state (Moulton); cluster by state (vcov = ~state)95% CI4.6%–7.6%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the designrejection rate
  • 5.2%5.2% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D2a: difference-in-differences, 50 states, serially correlated state shocks; cluster by state (vcov = ~state)95% CI3.8%–6.6%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the designrejection rate
  • 5.8%5.8% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D3: region and industry shocks in both regressor and error; two-way: region and industry (vcov = ~region + industry)95% CI4.4%–7.2%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the designrejection rate
  • 9.5%9.5% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D4: spatially correlated regressor and error on a lattice; Conley, 300 km cutoff (vcov = conley(300) ~ lat + lon)95% CI7.7%–11.3%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the designrejection rate
  • 7.3%7.3% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D5: panel with persistent common shocks in regressor and error; Driscoll-Kraay, 8 lags (vcov = DK(8) ~ time)95% CI5.7%–8.9%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotematches the designrejection rate

What we learned about the question

In four published designs and two more that economists use constantly, the standard error that describes the study's repetition follows the source of the identifying variation: the classroom lottery, the state legislature, the shock that travels over the map or hits every unit at once, the industry shocks behind a shift-share exposure. In every simulated version with a known truth, the estimator that followed that source rejected a true null within a few points of 5 percent, and the two kernel estimators were the ones that fell short. Estimators that ignored a dimension of the dependence rejected the truth 75.1%75.1% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D1: a regressor that varies only by state (Moulton); IID (fixest default) (vcov = "iid")95% CI72.4%–77.8%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence of the time when a regressor varied only by state, 28.3%28.3% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D2a: difference-in-differences, 50 states, serially correlated state shocks; cluster by state-year (vcov = ~state^year)95% CI25.5%–31.1%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence when a panel's state shocks persisted and the analyst clustered by state-year, and 51.1%51.1% rejection rateEstimandShare of 1,000 simulated data sets in which a nominal 5% test rejected the true null; D4: spatially correlated regressor and error on a lattice; HC1, no clustering (vcov = "hetero")95% CI48.0%–54.2%n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey dataNotemisses part of the dependence when a regressor and its error were both spatially correlated. Clustering coarser than the design requires cost precision and stayed at or near the nominal level.

What the method changed

The method changed nothing about any coefficient, and in each design it changed the standard error by a factor the design predicted: 6.15×6.15× ratioEstimandMean ratio of the cluster by state standard error to the IID standard error across replications; D1: a regressor that varies only by state (Moulton)n1,000VarianceSimulationSourceSimulation: sim.R with R fixest (this chapter); no survey data for the state-level regressor against a Moulton prediction of 6.39×6.39× ratioEstimandMoulton factor predicted for the design: square root of 1 + (200 - 1) x 0.2, the ratio by which the IID standard error should be inflatedVarianceNone reportedSourceSimulation: sim.R with R fixest (this chapter); no survey data. It replaced a question about residuals with a question about the regressor: who decided its value, at what level, along how many dimensions, and over what distance. The answers select the standard error, and the software argument follows.

What this analysis does not establish

  • That these rejection rates transfer to any particular study. The simulations fix a mechanism and a magnitude. Real intraclass correlations, persistence, and spatial ranges differ, and so do the consequences of ignoring them.
  • That the matching estimator is exact in small samples. Each design has enough clusters, periods, or spatial extent for its estimator to work with standard corrections. The 10-state design was deliberately friendly; unequal or few treated clusters need the remedies of Chapter 6.
  • That the right cutoff is knowable from the data alone. The spatial and Driscoll–Kraay results depend on a cutoff and a lag chosen with the dependence range in view. In practice the range is an assumption, and reporting several cutoffs is part of the analysis.
  • That the finite-population and superpopulation questions coincide. In the child-by-child lottery, clustering by classroom is conservative because every classroom is observed and the target is the average effect over those classrooms. For an average over a population of classrooms from which these were drawn, the clustered interval is the relevant one. That is a choice of estimand, and the simulation took one side of it.
  • That any of the coefficients means anything causal. Every simulated design is a placebo with a true effect of zero, and the four published studies each rest on identifying assumptions of their own. Standard errors describe the repetition; identification is a separate question that no choice of standard error answers.