The Census ships 80 replicate weights with every record in the American Community Survey public use microdata. They are there so you can compute standard errors that match the way the sample was actually drawn. Most code that touches this data ignores them and treats the rows as an independent sample.
This project uses them and measures what ignoring them costs. It runs on the 2023 one year file, 3.4 million person records, on a laptop.
The 2023 ACS one year PUMS national person file, csv_pus.zip from the Census FTP site. Two CSV files, 2.3 GB unzipped, 3,405,809 person records with 287 columns each.
The pipeline reads 92 of those columns: ten analysis variables, the person weight, and the 80 replicate weights. It keeps the 1,690,440 people aged 25 to 64, spread over 2,462 PUMAs in 51 states, whose weights sum to 172.5 million. The earnings work uses the 957,805 of them who worked full time all year.
Income is put on a common scale with ADJINC before anything else happens, which for this file is a factor of 1.019518.
Design effect here is the design based variance over the variance you would get from a simple random sample of the same size. Above 1 means the design costs you precision.
| Estimate | Value | Design SE | Simple random sample SE | Design effect |
|---|---|---|---|---|
| Mean wage, full time full year | 84,330 | 109.4 | 85.5 | 1.64 |
| Mean wage, men | 93,899 | 162.4 | 129.5 | 1.57 |
| Mean wage, women | 72,300 | 130.5 | 101.3 | 1.66 |
| Mean wage, high school only | 56,150 | 147.3 | 101.7 | 2.10 |
| Employment rate, men | 0.8151 | 0.00055 | 0.00042 | 1.71 |
| Employment rate, women | 0.7275 | 0.00061 | 0.00048 | 1.60 |
Across the 51 state mean log wages the design effect runs from 1.00 in New Jersey to 2.56 in Delaware, with a median of 1.62. So the typical state estimate carries 27 percent more sampling error than the simple formula reports.
The pipeline computes all three alongside the design based one.
Treating the weights as observation counts is the one that really hurts. Do that and you are claiming a sample of 172 million people, so the standard error comes out about 13 times too small. This is what you get by default if you expand the rows by their weight, or hand weighted counts to a test that expects counts.
The simple random sample formula is too small by the design effect, so a median of 27 percent for state means.
The Kish linearized formula is the careful version, and it is not uniformly too small. For state mean log wage it lands within 3 percent of the design based value. For the male minus female gap inside a state it is 14 percent too large, because calibration to known population totals removes variance that the formula cannot see.
The replicate variance estimator is tested by simulation, not argument. A synthetic population of 280,469 people in 80,000 households is built with a known mean, then sampled 500 times the way the ACS samples: systematically within clusters, with nonresponse, then post stratified to known totals, with replicate weights built and recalibrated for every draw.
| Method | Coverage of a nominal 95 percent interval | Mean standard error over the true spread |
|---|---|---|
| Replicate weights | 96.8 | 1.01 |
| Simple random sample | 81.6 | 0.70 |
| Kish linearized | 82.0 | 0.70 |
| Weights as observation counts | 22.2 | 0.15 |
The replicate interval covers, and its standard error is within 1 percent of the spread the estimate actually has. An interval you would call 95 percent covers 82 percent of the time with the simple formula and 22 percent if you treat the weights as counts.
For a within group difference the replicate estimator comes out 23 percent conservative, since the post stratification margins pin the group totals and remove variability the estimator still charges for.
Every state is compared against the national value, for the mean log wage and for the male minus female gap. That is 102 tests, run twice, once with design based standard errors and once with naive ones.
Four flip at the 0.05 level, and they flip in both directions.
Alaska looks different from the national wage level under the naive test, p 0.040, and does not under the design based test, p 0.051. Alaska has a design effect of 2.26, among the highest in the file.
Iowa, North Carolina and Vermont have pay gaps that differ from the national gap under the design based test and do not under the naive one. There the naive standard error is the one that is too big.
Benjamini-Hochberg and Holm are applied on top. Under BH control the two methods agree on 46 against 47 states for wage levels and 18 against 17 for gaps.
Among full time full year workers aged 25 to 64, men average 0.2147 log points more in wages than women, design standard error 0.0019. That is a 19.3 percent gap. The widest state gap is Louisiana at 0.323 log points, the narrowest is Rhode Island at 0.110.
With education, age, hours, weeks and region controlled, the coefficient on being female is -0.2524 with a design standard error of 0.0015.
Log wage on education, age, sex, hours, weeks and region, fitted once with the person weight and 80 more times with the replicate weights.
| Term | Coefficient | Design SE | Robust SE | Weighted least squares SE |
|---|---|---|---|---|
| Female | -0.2524 | 0.001538 | 0.001697 | 0.000126 |
| Bachelor degree | 0.7714 | 0.003800 | 0.003781 | 0.000274 |
| Graduate degree | 0.9887 | 0.003889 | 0.003976 | 0.000288 |
| Hours per week, in tens | 0.1345 | 0.001353 | 0.001356 | 0.000079 |
Huber-White robust standard errors land within 10 percent of the design based ones, median ratio 1.00 over the 13 terms. The textbook weighted least squares standard error is about 13 times too small, for the same reason as before: it reads the weights as frequencies.
Education by race and ethnicity, a 5 by 5 table over 1,690,440 people. Scaling the weighted counts to the population gives a Pearson statistic of 17.5 million on 16 degrees of freedom. On the sample scale it is 171,297. The Rao-Scott correction divides by a mean generalized design effect of 2.18 and gives 78,560.
All of them reject independence, which was never in doubt at this sample size. The number worth keeping is the 2.18: the uncorrected statistic is more than twice as large as it should be, and at a smaller sample size that is the difference between a result and nothing.
The smallest difference in state mean log wage you could detect at 80 percent power is 0.0232 log points under the real design against 0.0180 if the sample were simple random. You need 1.62 times as many people for the same answer.
Alaska makes it concrete. Power to detect a 5 percent wage difference there is 0.48 under the real design. Assume simple random sampling and you would think it was 0.81, and plan a study that cannot find what you are looking for.
Wages in this file are not continuous. After the income adjustment, 4.5 percent of the male weighted total sits on one value, 50,975 dollars, which is 50,000 as reported. Another 4.2 percent sits on 60,000 and 3.7 percent on 100,000.
This matters for quantiles. The male 90th percentile lands on the 170,000 spike, where the 1,000 dollar bin holds 0.42 percent of the weight against 0.03 percent in the bins on either side. The estimate barely moves across replicates because the density under it is enormous, so that row reports a design effect of 0.17. It is telling you about reporting behavior, not about the sample design. Mean based results do not have this problem.
The variance estimator is the one the Census documents for PUMS. Take the estimate from each of the 80 replicate weights, square the deviation from the full sample estimate, sum, and multiply by 4/80. Differences between estimates are formed replicate by replicate so the covariance is carried along, which matters when comparing a state against a national figure that contains it.
Written from scratch rather than taken from a library:
- the Paley construction of an order 80 Hadamard matrix, and successive difference replicate weights built from it
- weighted means, totals, ratios, proportions and quantiles, each with replicate standard errors
- quantiles by interpolation inside a bin, the way the Census computes medians, which is what makes them work on data with heavy spikes at round numbers
- weighted least squares over the replicate weights, plus model, robust and unweighted standard errors for comparison
- the Rao-Scott corrected chi-square, with generalized design effects taken from the eigenvalues of the replicate covariance against the multinomial covariance
- Benjamini-Hochberg and Holm
- minimum detectable effect and power that take the design effect into account
- the normal, t, chi-square and F distributions, and the incomplete beta and gamma functions under them
That last one means the package itself needs only numpy and pandas. scipy and statsmodels are test dependencies.
125 tests. Every piece that could be checked against something else is.
- the distribution functions against scipy, to 1e-9
- weighted least squares against statsmodels, and the robust standard errors against its HC1
- Benjamini-Hochberg and Holm against statsmodels multipletests, exactly
- the unweighted chi-square against scipy chi2_contingency
- weighted quantiles against numpy percentile on expanded data, exactly
- the Hadamard matrix against its defining identity, for orders 4 through 80
- the replicate variance against the closed form successive difference formula, which it matches to 1e-10 when the cluster count equals the replicate count
- feed the estimator independent perturbations instead of real replicate weights and it reproduces the Kish linearized variance, which pins down the 4/80 constant
No comments and no docstrings anywhere, checked with tokenize and ast rather than a regular expression. pyflakes is clean.
There is also a synthetic data generator that writes a full scale fake PUMS file with the real schema, clustered households, calibrated weights and its own replicate weights. The whole pipeline was built and verified against 3.2 million synthetic records before the real file was downloaded.
pip install -e .
python -m censusinf synth
python -m censusinf ingest
python -m censusinf all
synth writes the fake file and is only needed if you do not have the real one. With the real data, put psam_pusa.csv and psam_pusb.csv under data/raw and skip it.
Individual stages are estimate, compare, regress, tables, power and coverage. Results land in artifacts as CSV.
Every tunable lives in config.toml and is validated on load, including the universe definition, the confidence level, the quantile grid, the regression terms and the simulation settings.
On an 8 GB laptop the ingest takes about 70 seconds and the full analysis about 150 seconds, peaking at 1.1 GB of memory.
censusinf/
replicate.py Hadamard construction and replicate weight building
design.py weighted estimators and the replicate variance
quantiles.py binned weighted quantiles
linear.py replicate weighted least squares
tables.py Rao-Scott corrected chi-square
multitest.py Benjamini-Hochberg and Holm
power.py minimum detectable effect and power
distributions.py normal, t, chi-square, F, incomplete beta and gamma
ingest.py chunked reader for the raw PUMS files
analysis.py the analysis stages
coverage.py the coverage simulation
synth.py synthetic PUMS generator
cli.py stage runner
config.py config loading and validation
geography.py state codes, names and regions
io.py CSV and array output
tests/