Uncertainty and repeated samples
Fit the same regression three ways. Then draw new samples to see how often each interval contains the known coefficient.
Same data · Same coefficient
Three uncertainty estimates
The coefficient is fixed across these three rows. The standard-error formula and reference degrees of freedom determine the interval. Containment is observable here because the population coefficient is known.
The realized errors
Residuals and group membership
The highlighted points share a group; the other points are gray. A residual is an estimated error. The export also includes the true generated errors and their conditional standard deviations.
How often does the interval cover β?
Each repetition draws new independent groups, fits the regression, and records all three intervals. Choose a starting example and run repeated samples. All methods use identical observations in each repetition.
Observed interval coverage
Coverage is the share of generated intervals containing β. The thin ranges show 95% Monte Carlo uncertainty for that share, using Wilson intervals. They describe simulation precision, not uncertainty about β in one regression.
Individual intervals
Inspect the repetitions
The horizontal scale stays fixed when you change methods within the displayed window. Blue intervals contain β; rust intervals miss it and have an × at the estimate. Select a line, or focus the plot and use arrow keys, to inspect a repetition. Every completed repetition is included in the numerical summary and export.
Reproducible analysis
The corresponding Stata commands
Export the experiment and extract it into a project folder. The sample do-file imports the exact displayed observations. The native simulation generates new draws from the same population design; Stata's random-number stream differs from the browser's.
What the experiment assumes
All groups are independent and equal in size. The predictor and the errors have independent sources, so E(error | x) = 0. Every fit includes an intercept and one predictor; no weights, missing observations or omitted confounders enter this experiment.
Population generator
For group g and row i, x = √ρₓ ag + √(1 − ρₓ) vgi. The error is σs(x)[√ρₑ bg + √(1 − ρₑ) εgi], where s(x) = exp(hx/2 − h²/4). All a, b, v and ε draws are independent standard normals. The normalization keeps the population mean error variance at σ² as h changes. Conditional on x, the within-group error correlation is ρₑ; with varying s(x), unconditional correlation need not equal that value.
Changing a parameter retains the underlying random draws at a fixed seed and sample number. Repeated-sample runs start at sample 1. The browser seed does not reproduce Stata's random-number stream; export the observations for an exact comparison.
Covariance formulas and reference distributions
Conventional inference uses SSE/(N − 2) and assumes independent errors with constant conditional variance. HC1 sums individual squared score contributions and multiplies by N/(N − 2). CR1 sums scores within each group before squaring, then multiplies by [G/(G − 1)]·[(N − 1)/(N − 2)]. Both sandwich formulas use the same OLS residuals.
Conventional and HC1 intervals use t critical values with N − 2 degrees of freedom. CR1 uses G − 1. These match the corresponding unweighted Stata regress options. Normal, independent, constant-variance errors give conventional t inference an exact conditional justification. HC1 and CR1 rely on approximations; the degrees-of-freedom correction does not make them exact.
What changing the covariance cannot do
Robust or clustered inference does not remove omitted-variable bias, establish a causal design, or decide which grouping is appropriate for an empirical study. This generator supplies the grouping and exogeneity. With few independent groups, uneven information or other departures, the usual cluster correction can perform poorly. A clustered standard error can also be smaller than an unclustered one in a particular sample.
Formula references: Stata regress, Methods and formulas; Stata's comparison of covariance estimators. This browser lab has independent numerical checks; it is not a full Stata implementation.