# Reproducibility package

## Study

**Trends and Population Contributors to Cesarean Delivery in the United States, 2016–2024: A Repeated Cross-Sectional Analysis Using a Modified Robson Classification**

This package reproduces the aggregate results reported in the accompanying manuscript. All estimates were computed from the final 2016–2024 U.S. National Vital Statistics System (NVSS) natality public-use files distributed by the National Center for Health Statistics (NCHS). No person-level birth records are included in this package.

## Data sources

- NCHS Vital Statistics Online Data Portal: <https://www.cdc.gov/nchs/data_access/vitalstatsonline.htm>
- Annual natality archive pattern: `https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Datasets/DVS/natality/NatYYYYus.zip`
- 2024 natality user guide: <https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Dataset_Documentation/DVS/natality/UserGuide2024.pdf>

The SHA-256 digest, downloaded byte count, fixed-width record count, processing time, and flow counts for every annual source archive are stored in `aggregate_YYYY.json` and reproduced in the results workbook. The 2024 count of 3,628,934 U.S.-resident births after excluding 9,502 births to non-U.S. residents agrees exactly with the published NCHS final total.

## Analytic population

The source population was live births in the 50 states and the District of Columbia. The analysis:

1. excludes births to non-U.S. residents;
2. retains hospital births only;
3. excludes records with unknown delivery method;
4. classifies records with sufficient plurality, presentation, gestational-age, previous-cesarean, parity-proxy, and labor-onset information.

Annual modified Robson classification completeness ranged from 99.00% to 99.58% among records with a known delivery method.

## Modified Robson implementation

The operational definitions are encoded in `aggregate_natality.py`. Key departures from a clinical Robson implementation are explicit:

- Parity is proxied by live-birth order because a direct parity field is not available consistently in the public-use files. A recorded previous cesarean overrides a first-live-birth code for classification.
- Group 9 uses the NVSS category `other presentation`; it cannot be restricted exactly to transverse or oblique lie.
- Labor onset is derived from induction and trial-of-labor fields. Induction recorded as `yes` is classified as induced. For induction `no`, vaginal births and cesarean births with trial of labor are classified as spontaneous; cesarean births without trial of labor are classified as prelabor cesareans.
- Groups 2 and 4 retain the 2a/2b and 4a/4b induced/prelabor subgroups in the aggregate outputs.
- Records with unresolved required variables are not forced into a group. Missingness, unclassifiable counts, and prespecified conflict-resolution counts are reported separately.

## Software

- Python 3.12
- NumPy
- SciPy
- Matplotlib
- python-docx (only needed to rebuild the manuscript)

Install the packages listed in `requirements.txt` in a clean environment. Set `MPLCONFIGDIR` to a writable directory if the default Matplotlib cache is unavailable.

## Reproduction

From the package root:

```bash
python -m pip install -r requirements.txt
export MPLCONFIGDIR=/tmp/robson-matplotlib
mkdir -p "$MPLCONFIGDIR"
```

To download and aggregate all annual source files sequentially:

```bash
export CODEX_PRIMARY_RUNTIME_PYTHON="$(command -v python)"
bash analysis/run_annual_pipeline.sh 2016 2017 2018 2019 2020 2021 2022 2023 2024
```

The pipeline downloads one annual archive, verifies that the ZIP is readable, streams the fixed-width records into aggregate counts, writes `analysis/aggregate_YYYY.json`, and removes the person-level archive after successful aggregation.

To aggregate an already downloaded annual archive:

```bash
python analysis/aggregate_natality.py \
  --year 2024 \
  --zip /path/to/Nat2024us.zip \
  --output analysis/aggregate_2024.json
```

To reproduce estimates and figures from the included aggregate JSON files:

```bash
python analysis/analyze_results.py \
  --input-dir analysis \
  --output-dir outputs/analysis
```

To rebuild the Word manuscript and cover letter:

```bash
python analysis/build_manuscript.py \
  --results outputs/analysis/analysis_results.json \
  --figure-dir outputs/analysis \
  --output-dir outputs/final
```

## Analysis

- Annual and group-specific cesarean rates use complete classified births as denominators.
- Binomial 95% confidence intervals use the Wilson method.
- Temporal trends use log-linear quasi-Poisson models with the classified birth count as the exposure; annual percentage change is reported with Pearson-dispersion-adjusted confidence intervals.
- The 2016–2024 absolute change is separated into population-share and within-group-rate effects using an asymmetric Kitagawa decomposition. The group-level effects sum exactly to the observed overall change.
- Prespecified sensitivity analyses exclude 2020–2021 and exclude modified group 9.

## Included outputs

- Nine annual aggregate JSON files
- Machine-readable analysis results in `analysis_results.json`
- Publication figures as PNG and 300-dpi LZW-compressed TIFF files
- Formula-driven results workbook with source provenance and data-quality audit
- English manuscript and journal-oriented cover letter

## Important interpretation limits

This is a repeated cross-sectional descriptive analysis of deidentified public-use birth-certificate records. It does not establish causal effects or clinical appropriateness. The public-use data lack detailed indications for cesarean delivery, complete parity, hospital identifiers, fetal deaths and non-live deliveries, and the clinical detail required to reproduce original Robson group 9 exactly. Large sample sizes make very small differences statistically detectable; interpretation should prioritize absolute percentage-point changes and the decomposition.

