pystatsv1 / pystatsv1/PyStatsV1

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

Open
#71 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue help wanted
Dominant language
Python
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the existing Ch13/Ch14/Ch15 simulator and analyzer patterns, then review scripts/_cli.py and tests/test_cli_smoke.py. Add scripts/sim_epi_rr_strata.py and scripts/chXX_epi_rr_strata.py, wire epi-rr-ci and epi-rr into the Makefile, and ensure the smoke tests cover both scripts and the requested risk-ratio summaries.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, cli, data, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.