Skip to content

New case study: Epidemiology risk ratio with strata (skeleton) #71

@nicholaskarlson

Description

@nicholaskarlson

Summary

No response

Details

Summary

Add a new Chapter 15/16 style case study for epidemiology:

  • Simulate a simple binary exposure / binary outcome dataset with strata
    (e.g., age group).
  • Provide an analysis script that computes:
    • crude risk ratio,
    • stratum-specific risk ratios,
    • and a pooled / adjusted risk ratio (e.g., Mantel–Haenszel).

This issue is for building the basic simulator + analyzer skeleton.
We can refine the statistics and narrative in later issues.

Files to add

  • scripts/sim_epi_rr_strata.py – simulator for stratified 2×2 tables
  • scripts/chXX_epi_rr_strata.py – analyzer (chapter number TBD; use XX for now)
  • Makefile targets:
    • epi-rr-ci (small n, CI smoke)
    • epi-rr (full demo)
  • Tests:
    • Add the new scripts to tests/test_cli_smoke.py.

Goals

  • Simulator: generate a small dataset with columns like:
    • id, stratum, exposed (0/1), outcome (0/1)
  • Analyzer: read a --data or --datadir input and compute:
    • crude risk ratio with a confidence interval (basic is fine),
    • per-stratum 2×2 counts and risk ratios,
    • a placeholder for pooled/adjusted RR (even if initially just a TODO + rough calculation).
  • Use the shared CLI helper (scripts/_cli.py) for argument parsing.
  • Wire the new scripts into the Makefile and smoke test.

Hints

  • Look at the existing pattern for Ch13/Ch14/Ch15:
    • simulator script → CSV in data/synthetic/
    • analyzer script → summaries/plots in outputs/...
  • For a first pass, you can use simple formulas from standard epi texts,
    or even rely on statsmodels if convenient.
  • Keep everything small, clear, and easily extended in follow-up issues.

Difficulty

Medium: good first issue for someone interested in biostats/epidemiology
and comfortable with basic Python and 2×2 tables.

Files to Touch

No response

Contributor Checklist

  • I have read CONTRIBUTING.md.
  • I can run make lint locally.
  • I can run make test locally.
  • I have checked for existing issues/PRs that might overlap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions