{"id":50765449,"url":"https://github.com/igerber/design-based-did-replication","last_synced_at":"2026-06-11T13:30:24.669Z","repository":{"id":356745807,"uuid":"1231437362","full_name":"igerber/design-based-did-replication","owner":"igerber","description":"Replication code for Gerber (2026), 'Design-Based Variance Estimation for Modern Heterogeneity-Robust Difference-in-Differences Estimators' (arXiv:2605.04124).","archived":false,"fork":false,"pushed_at":"2026-05-09T14:04:15.000Z","size":8001,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-09T15:45:55.295Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igerber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":".zenodo.json","notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-07T00:52:07.000Z","updated_at":"2026-05-09T14:04:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/igerber/design-based-did-replication","commit_stats":null,"previous_names":["igerber/design-based-did-replication"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/igerber/design-based-did-replication","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igerber%2Fdesign-based-did-replication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igerber%2Fdesign-based-did-replication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igerber%2Fdesign-based-did-replication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igerber%2Fdesign-based-did-replication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igerber","download_url":"https://codeload.github.com/igerber/design-based-did-replication/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igerber%2Fdesign-based-did-replication/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34201839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-11T13:30:23.703Z","updated_at":"2026-06-11T13:30:24.663Z","avatar_url":"https://github.com/igerber.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Replication: Design-Based Variance Estimation for Modern Heterogeneity-Robust DiD\n\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.20097360.svg)](https://doi.org/10.5281/zenodo.20097360)\n[![arXiv](https://img.shields.io/badge/arXiv-2605.04124-b31b1b.svg)](https://arxiv.org/abs/2605.04124)\n\nThis repository contains the simulation and empirical-illustration code that\nproduces the numerical results in:\n\n\u003e Gerber, Isaac (2026). *Design-Based Variance Estimation for Modern\n\u003e Heterogeneity-Robust Difference-in-Differences Estimators.*\n\u003e [arXiv:2605.04124](https://arxiv.org/abs/2605.04124).\n\nThe companion software is the [`diff-diff`](https://github.com/igerber/diff-diff)\nPython package, pinned to **v3.3.2**\n([Zenodo DOI](https://doi.org/10.5281/zenodo.19803705)).\n\nThe frozen v1.0 release of this replication artifact (the version that\naccompanies arXiv v1) is archived at\n[10.5281/zenodo.20097361](https://doi.org/10.5281/zenodo.20097361). The\nconcept DOI [10.5281/zenodo.20097360](https://doi.org/10.5281/zenodo.20097360)\nalways resolves to the latest version.\n\n## Layout\n\n```\n.\n├── simulations/\n│   ├── sim_config.py          Scenario / estimator grid\n│   ├── sim_cell.py            Single-cell driver (deterministic seeds via md5)\n│   ├── sim_run.py             Parallel coordinator with checkpointing\n│   ├── sim_analyze.py         Aggregates → console + LaTeX tables\n│   ├── make_figure.py         Coverage figure (Figure 1 in the paper)\n│   ├── nhanes_table.py        Empirical illustration table (NHANES + ACA)\n│   ├── verify_scenarios.py    Sanity checks for the simulation DGPs\n│   ├── sim_validate.py        Validation harness\n│   └── results/               Cell-level CSVs (committed for diff-checking)\n├── data/\n│   └── nhanes/                Frozen NHANES golden JSON (with provenance)\n├── tables/                    Generated LaTeX tables (sim_s{1..4}, nhanes)\n├── figures/                   Generated coverage figure (PDF + PNG preview)\n├── requirements.txt           Pinned Python dependencies\n├── Makefile                   Reproduction targets\n├── CITATION.cff\n├── LICENSE\n└── README.md                  This file\n```\n\n## Reproducing the simulation results\n\n### Quick path (build outputs from committed CSVs)\n\nIf you trust the committed simulation CSVs and only want the tables and figure:\n\n```sh\nmake install          # pinned dependencies into the active Python environment\nmake tables figures   # regenerate LaTeX tables and Figure 1 from results/*.csv\n```\n\nThis takes well under a minute on a normal laptop.\n\n### Full path (rerun simulations from scratch)\n\n```sh\nmake install\nmake clean-results    # wipe simulations/results/\nmake all              # sims → tables → figures\n```\n\nWall-clock time on a 14-core CPU: about 30 minutes for the full grid (33 cells\n× 2,000 replications, three SE methods per replication: HC1, weighted point +\nPSU cluster, full design-based TSL). Total CPU time is ~14 hours; the parallel\ncoordinator divides it across cores. CSVs are written incrementally, so the\nsims can be interrupted and resumed.\n\n### Smoke test\n\n```sh\nmake smoke\n```\n\nRuns five replications of one cell and writes\n`simulations/results/s1_cs_reg_n500.csv`. Use this to verify\n`diff-diff==3.3.2`, the seed pipeline, and the matrix kernels all behave on\nyour machine before kicking off the full grid.\n\n## Determinism\n\nThe per-cell seed is derived from a stable hash of the cell ID:\n\n```python\nseed = rep * 1000 + (md5(cell_id) % 1_000_000)\n```\n\nWe use `hashlib.md5` rather than Python's built-in `hash()` because the latter\nis randomized per interpreter unless `PYTHONHASHSEED` is set, which would\ndefeat reproducibility across machines. The Makefile targets export\n`PYTHONHASHSEED=0` defensively in case other code in the call stack relies\non it.\n\n## Software dependencies\n\nPython 3.9.6, with the package versions in `requirements.txt`:\n\n- `diff-diff==3.3.2` ([Zenodo](https://doi.org/10.5281/zenodo.19803705))\n- `numpy==2.0.2`, `pandas==2.3.3`, `scipy==1.13.1`, `matplotlib==3.9.4`\n\nNewer versions probably work but were not used to produce the committed\nresults.\n\n## NHANES data\n\nThe NHANES illustration in Section 6 of the paper uses a frozen analytic\ngolden file at `data/nhanes/nhanes_realdata_golden.json`. This is a copy of\nthe cross-validation golden file shipped with the diff-diff package\n(`benchmarks/data/real/nhanes_realdata_golden.json`), generated against\nNHANES public-use files from CDC/NCHS for the 2007-2008 and 2015-2016\ncycles. See `data/README.md` for full provenance.\n\n## Citation\n\nIf you use this replication code, please cite both the paper and the\ncompanion package:\n\n```bibtex\n@misc{gerber2026,\n  author       = {Gerber, Isaac},\n  title        = {Design-Based Variance Estimation for Modern Heterogeneity-Robust\n                  Difference-in-Differences Estimators},\n  year         = {2026},\n  eprint       = {2605.04124},\n  archivePrefix = {arXiv},\n  primaryClass = {stat.ME},\n  url          = {https://arxiv.org/abs/2605.04124}\n}\n\n@misc{diffdiff2026,\n  author    = {Gerber, Isaac},\n  title     = {{diff-diff: Difference-in-Differences Causal Inference for Python}},\n  year      = {2026},\n  publisher = {Zenodo},\n  version   = {3.3.2},\n  doi       = {10.5281/zenodo.19803705}\n}\n\n@misc{gerberreplication2026,\n  author    = {Gerber, Isaac},\n  title     = {Replication code: Design-Based Variance Estimation for Modern\n               Heterogeneity-Robust Difference-in-Differences Estimators},\n  year      = {2026},\n  publisher = {Zenodo},\n  version   = {v1.0},\n  doi       = {10.5281/zenodo.20097361}\n}\n```\n\n## License\n\nAll code in this repository is released under the MIT License (see `LICENSE`).\nThe diff-diff package and NHANES public-use data retain their own licenses.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figerber%2Fdesign-based-did-replication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figerber%2Fdesign-based-did-replication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figerber%2Fdesign-based-did-replication/lists"}