Compare poverty rates and uncertainty in Python

Compare national poverty rates for children and older adults, reproduce the weighted estimates, and calculate an interval for their difference using paired Census replicates.

Compare poverty across age groups

Suppose you are preparing a national poverty brief. You want to compare children with adults aged 65 and older, and report how precise that difference is. The CPS ASEC reference supplies person records, explicit poverty-universe flags, prepared weights and national profiles. Its aggregate replicate estimates let you calculate uncertainty for the profiles and for a difference between them.

The optional input.csv selects the two profiles. The same choices appear in the comparisons list in the Python code below. These are analysis parameters; no respondent records or income values are invented.

Download the product samples

Save these three files in your working folder. people.csv contains all 57,646 under-18 and age-65+ records from the paid product, including people outside the official poverty universe. profiles.csv contains the two matching national profiles, and profile_replicates.csv contains all 160 aggregate replicate estimates for each. Every original product column is retained. Complete age groups are supplied so the weighted calculations can be reproduced.

The full $29 edition contains 134,729 people, household and family context, 42 income and poverty profiles, and 6,720 profile replicate estimates across six CSV tables. It covers 2025 income using the 2026 CPS ASEC. Inspect the complete coverage and fields.

Code example

The code selects people in the official poverty universe, calculates each group's weighted poverty rate, and checks it against the supplied profile. It then uses the 160 replicate estimates to calculate 90% confidence intervals. Replicate indexes are paired across groups when calculating the difference; this preserves their covariance.

Paths are relative to your working folder; use from pathlib import Path; print(Path.cwd()) to check it, or supply full paths.

Python 3.10+ · Jupyter, IPython or a script
import csv
import math
from pathlib import Path

# After purchase, point this at the folder containing the extracted CSV files.
DATA = Path(".")
# input.csv contains the same profile choices as this list.
comparisons = [{"profile_id": "poverty_under18_sex0"}, {"profile_id": "poverty_65_plus_sex0"}]


def read_csv(name):
    with (Path(DATA) / name).open(encoding="utf-8-sig", newline="") as stream:
        return list(csv.DictReader(stream))


people = read_csv("people.csv")
profiles = {row["profile_id"]: row for row in read_csv("profiles.csv")}
replicates = {}
for row in read_csv("profile_replicates.csv"):
    replicates.setdefault(row["profile_id"], {})[int(row["replicate"])] = float(row["estimate"])

rates = {}
results = []
for request in comparisons:
    profile_id = request["profile_id"]
    profile = profiles[profile_id]
    age_group = {"poverty_under18_sex0": "under18", "poverty_65_plus_sex0": "65_plus"}[profile_id]
    selected = [row for row in people if row["age_group"] == age_group and row["POV_UNIV"] == "1"]
    population = math.fsum(float(row["analysis_weight"]) for row in selected)
    below = math.fsum(float(row["analysis_weight"]) for row in selected if row["PERLIS"] == "1")
    rate = 100 * below / population
    assert abs(rate - float(profile["estimate"])) < 0.000001
    weights = replicates[profile_id]
    assert set(weights) == set(range(1, 161))
    se = math.sqrt(4 / 160 * math.fsum((weights[i] - rate) ** 2 for i in range(1, 161)))
    rates[profile_id] = rate
    results.append({"profile_id": profile_id, "poverty_rate_pct": f"{rate:.2f}", "ci90_lower": f"{rate - 1.645 * se:.2f}", "ci90_upper": f"{rate + 1.645 * se:.2f}"})
    print(f"{profile['group_label']}: {rate:.2f}% (90% CI {rate - 1.645 * se:.2f}–{rate + 1.645 * se:.2f}%)")

# Replicate indexes are paired across groups, preserving covariance in the difference.
first, second = [request["profile_id"] for request in comparisons]
gap = rates[first] - rates[second]
replicate_gaps = [replicates[first][i] - replicates[second][i] for i in range(1, 161)]
gap_se = math.sqrt(4 / 160 * math.fsum((value - gap) ** 2 for value in replicate_gaps))
print(f"Under 18 minus 65+: {gap:.2f} percentage points (90% CI {gap - 1.645 * gap_se:.2f}–{gap + 1.645 * gap_se:.2f})")

Analysis of the output

Under 18; all sexes: 13.41% (90% CI 12.84–13.97%)
65 and older; all sexes: 9.77% (90% CI 9.32–10.23%)
Under 18 minus 65+: 3.63 percentage points (90% CI 2.92–4.34)

The estimated official poverty rate is 13.41% for children and 9.77% for adults 65 and older. The child rate is 3.63 percentage points higher. The printed interval for that difference describes sampling uncertainty under the Census replicate method. It is calculated from paired replicate differences, not by subtracting endpoints or judging whether two separate intervals overlap.

analysis_weight represents people, not respondent counts. It is the original MARSUPWT divided once by 100. The denominator includes only records with POV_UNIV == "1"; the numerator includes those whose PERLIS == "1". The source's person poverty classification already handles family relationships. Recalculating poverty from a person's own income would answer a different question and misclassify children.

Each standard error is the square root of 4 / 160 times the sum of squared deviations of replicate estimates from the full-sample estimate. The 90% margin of error is 1.645 × standard error. These are normal-approximation intervals for sampling error. They do not measure all reporting, imputation or other nonsampling errors, and the product does not clip interval endpoints.

Using the full dataset

Extract the purchased ZIP and replace the three samples with the full files of the same names, or change DATA at the top of the code to the extracted folder. The same comparison produces the same answer.

The poverty profiles cover all people, under 18, ages 18–64 and ages 65+, each for all sexes combined, males and females. To make another comparison, change the profile choices and the corresponding person filter together. For example, poverty_18_64_sex0 corresponds to age_group == "18_64" with no sex restriction. Always retain the official poverty-universe filter.

The household-income profiles provide the mean and five income-bracket shares nationally and for the four Census regions. Their unit is households, not people. Start from households.csv, select income_universe == "included", and use its household analysis_weight. Income is nominal pretax money income in 2025 dollars; negative values are retained. These profiles do not provide a median.

The included replicate table supports uncertainty for the predefined profiles and their paired differences. It contains aggregate estimates, not individual replicate weights. For a new custom subgroup or another statistic, use the free Census individual replicate file and the source instructions to recompute all 160 estimates. The product's selected person fields also limit which custom questions it can answer.

household_key links person and family records to household context. family_key links people to their source family unit. Primary families and related subfamilies overlap, so adding all family rows would double count. Identifiers apply within this source edition; they do not establish a longitudinal panel. State codes are retained, but this product validates national and Census-region profiles, not county or small-area estimates.

For county planning, the County Income & Poverty Reference supplies annual SAIPE estimates, while the ACS County Demographic Profile supplies five-year estimates. The CPS Labor Force Reference covers separate basic-monthly surveys. These products provide complementary views with different periods, populations and methods; they are not person-level joins to this ASEC file.

Sources and versions

Source: the Census Bureau's 2026 CPS Annual Social and Economic Supplement, describing 2025 income and official poverty. ACD retained the original CSV and fixed-width files, original individual replicate weights, dictionaries and technical documentation. Independent checks reproduce the rounded national public-use benchmarks in Appendix D.

The income year is 2025; the survey edition is 2026. ACD captured the inputs October 19, 2026 UTC and packaged this preparation 2026-10-19. The original microdata first-release date was not independently established; acquisition receipts and server modification dates are retained separately. This is the first ACD edition of these inputs. The source and preparation record documents the release and included processing improvements.

Example checked October 19, 2026 against both these samples and the complete purchased files. Source and processing records, sample checksums · Expected result CSV. Independent preparation; no agency endorsement.