Repository navigation
Fix calibration and small-sample uncertainty across detection, fusion, and inference - #1
Merged
Merged
Conversation
- Calibrate MultivariateChangeDetector and SequentialTreatmentResponseDetector thresholds on leave-one-out reference scores. In-sample scores inflated the held-out false-alarm rate from a nominal 5% to 9-40% at minimum sizes. - Default random-effects fusion to modified Hartung-Knapp-Sidik-Jonkman intervals. DerSimonian-Laird Wald intervals covered 76-88% for k = 2-4. - Correct signature-contrast bootstrap variance by sqrt(n/(n-1)) and use Welch t intervals. Percentile intervals covered ~80% at n = 3 per arm. - Refresh the GSE131754 benchmark SEs and document the Phase 4 simple-effect coding. - Skip pysam-dependent tests when the optional extra is missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PDyYDahYopgwfwJXNT11Ze
- Treatment effects: variance-corrected bootstrap SE with Welch t intervals
(percentile CI covered 90% at n=8), arm-centered pooled within-group
omnibus covariance recomputed per permutation, optional within-stratum
permutation, and Holm-adjusted p-values across follow-ups.
- GLS evidence fusion: multiplicative dispersion policy (default) widens the
interval to max(z, t_{k-1} sqrt(Q/(k-1))) x SE when evidence disagrees
beyond the supplied covariance; FIXED keeps prior behavior.
- Move small-sample helpers to a shared module; document completers estimand.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PDyYDahYopgwfwJXNT11Ze
weston-wang
marked this pull request as ready for review
September 26, 2026 01:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes six statistical defects found in a project audit. In each case the stated error rate did not hold at the package's own default or minimum settings.
MultivariateChangeDetectorSequentialTreatmentResponseDetectorPrecisionWeightedFusion(random effects)RandomizedTreatmentEffectEvaluatorfeature CIsGeneralizedLeastSquaresFusionTreatment-effect inference also changes:
randomization_strataargument. In a simulated stratified 8-per-arm trial with a 1.5 SD stratum shift, unrestricted permutation had 1% type I error and 4% power; within-stratum permutation has 5.3% and 25%.Other changes:
Detectors: reference scores are leave-one-out (
reference_score_method="leave_one_out"). The change detector requires at least feature count + 2 reference subjects.Fusion:
RandomEffectsIntervaldefaults toHARTUNG_KNAPP.WALDkeeps the old behaviour.GLS:
EvidenceDispersionPolicy.MULTIPLICATIVE(default). With Q the disagreement statistic and φ = Q/(k−1):evidence_overdispersedwarning when φ > 1.FIXEDkeeps the old behaviour.Small-sample helpers: the variance correction and Welch t critical values are shared in
rejuvenationkit/_small_sample.py.Docs: the GSE131754 benchmark SEs are regenerated from a real rerun (×1.22). Phase 4 coefficients are documented as simple effects.
pysamtests skip when the extra is absent.Research decision and assumptions
Leave-one-out calibration: chosen over K-fold because it keeps nearly all reference data in each refit. The resulting threshold is slightly conservative.
Modified HKSJ: the floor at 1 prevents intervals narrower than DerSimonian–Laird when estimates agree by chance.
GLS interval rule: three rules were compared by simulation:
Unfloored t is exact when Σ is correct up to scale, but it can collapse to near-zero width when estimates agree by chance. Taking max(z, t√φ) keeps it no narrower than the fixed-effect interval, at the cost of being conservative for k ≤ 3.
Bootstrap SEs: the bootstrap is kept for its joint covariance and variance-corrected. Intervals are Welch t because percentile intervals are degenerate at small n.
Feature intervals under strata: they ignore strata, so they are conservative under stratified randomisation. Stratifying the estimator would change the estimand.
Validation
ruff check .ruff format --check .mypypytest: 536 passed, 2 skipped, coverage 85.42%mkdocs build --strictpasses)Examples rerun successfully:
public_gse131754_genomic_fusion.pypublic_dog_phase1_audit.py(11/213 detections, unchanged)randomized_rapamycin_effect.pysynthetic_canine_genomic_fusion.pyfour_phase_workflow.pycanine_multimodal_fusion.pyLimitations and failure modes
🤖 Generated with Claude Code
https://claude.ai/code/session_01PDyYDahYopgwfwJXNT11Ze