Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ jobs:
- name: Tests
run: make test

- name: Lint
run: make lint

- name: Tests
run: make test

- name: Tiny Chapter 13 smoke
run: make ch13-ci

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ help:
ch13-ci:
python scripts/sim_stroop.py --n-subjects 6 --n-trials 10 --seed 2025
python scripts/ch13_stroop_within.py --save-plots
python scripts/sim_fitness_2x2.py --n-per-group 5 --seed 2025
python scripts/sim_fitness_2x2.py --n-per-group 40 --seed 2025
python scripts/ch13_fitness_mixed.py --save-plots

.PHONY: ch13
Expand Down
8 changes: 5 additions & 3 deletions tests/test_ch13_fitness.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
SEED = 2025

def test_fitness_mixed_model_signals():
subjects, long_df = sim.simulate(n_per_group=5, seed=SEED)
# Use n_per_group=40 to provide enough data for the model
subjects, long_df = sim.simulate(n_per_group=40, seed=SEED)

# Mixed model with random intercept for id, categorical time/group + covariates
md = smf.mixedlm(
Expand All @@ -18,6 +19,7 @@ def test_fitness_mixed_model_signals():
assert res.params["C(time)[T.post]"] > 5
assert res.pvalues["C(time)[T.post]"] < 1e-6

# interaction should be positive (ProgramB a bit more improvement); allow modest p
# interaction should be positive (ProgramB a bit more improvement)
assert res.params["C(time)[T.post]:C(group)[T.ProgramB]"] > 0
assert res.pvalues["C(time)[T.post]:C(group)[T.ProgramB]"] < 0.2
# With N=80, we can have a stricter p-value check
assert res.pvalues["C(time)[T.post]:C(group)[T.ProgramB]"] < 0.05
Loading