# Analysis scripts

One self-contained Python script per result. Each reads `../data/`, computes,
and writes JSON into its own `output/` folder. No script reads another
script's output, so they can run in any order.

## Running

```sh
python code/run_all.py              # all scripts
python code/run_all.py --check      # all scripts, compared with the shipped outputs
python code/run_all.py --only occ   # scripts whose path contains "occ"
python code/main_spec/main_spec.py  # any one script directly
```

## Scripts

Panels use one A-number sequence in reading order. The PDF uses separate
appendix figure and table sequences; its original labels are retained below.

| Script | PDF exhibit | Reads (from `data/`) | Panels |
|---|---|---|---|
| `rank_histograms` | Figure 1 | nobelists_analysis | — |
| `main_binscatter_ranks` | Figure 2, Figure A2 | nobelists_analysis | A12 |
| `main_spec` | Table 1, Table A7 | nobelists_analysis | A15 |
| `heterogeneity_spec` | Table 2 | nobelists_analysis | — |
| `parent_field_match/parent_field_perm_test` | Figure 3, Table 3, Figure A4 | nobelists_analysis, occ1950_sci_field_classification | A18 |
| `parent_field_match/parent_field_match_graphs` | Figure A5 | nobelists_analysis, occ1950_sci_field_classification, ipums_parent_field_census_shared | A19 |
| `most_common_occupations` | Figure A1 | nobelists_analysis, microocc_census_shares | A5 |
| `other_rank_functions` | Figure A3 | nobelists_analysis | A13 |
| `father_occ_by_category` | Table A1 | nobelists_analysis | — |
| `occ_shares` | Tables A2, A3 | occ_shares_10group_table, occ_shares_25group_table, occ_shares_occ1950_table | A9, A10, A17 |
| `occ_representation_change` | Table A4 | nobelists_analysis, occ_shares_occ1950_table, occ_rank_timeseries | — |
| `main_robust` | Tables A5, A6 | nobelists_analysis | A2, A14 |
| `gender_spec_robust` | Table A8 | nobelists_analysis | A3 |
| `regional_analysis` | Table A10 | nobelists_analysis | A7 |
| `hetero_trends` | Table A12 | nobelists_analysis | A8 |
| `gender_analysis` | Gender trends, slope-equality Wald tests, and Wilcoxon tests | nobelists_analysis | A6 |

## Notes

- Scripts are Python ports of the authors' original Stata code. Comments
  such as `Replicates a/table_main_spec.do` name the original file, which is
  not included.
- Regressions use OLS with HC1 robust standard errors unless a script's
  docstring says otherwise.
- `parent_field_perm_test` uses a fixed NumPy seed, so its output is
  reproducible; its draws differ from the original Stata run.
- `occ_representation_change` explains a known approximation in the census
  share half of Table A4 in its docstring's ACCURACY section.
