11reRandomStats Documentation
22============================
33
4- .. image :: https://github.com/zerotonin/rerandomstats /actions/workflows/tests.yml/badge.svg
5- :target: https://github.com/zerotonin/rerandomstats /actions/workflows/tests.yml
4+ .. image :: https://github.com/zerotonin/reRandomStats /actions/workflows/tests.yml/badge.svg
5+ :target: https://github.com/zerotonin/reRandomStats /actions/workflows/tests.yml
66 :alt: Tests
77
8+ .. image :: https://github.com/zerotonin/reRandomStats/actions/workflows/docs.yml/badge.svg
9+ :target: https://zerotonin.github.io/reRandomStats/
10+ :alt: Docs
11+
812.. image :: https://img.shields.io/badge/License-MIT-yellow.svg
913 :target: https://opensource.org/licenses/MIT
1014 :alt: License: MIT
1115
12- A comprehensive Python toolkit for **re-randomisation statistics ** in the
13- tradition of Sir Ronald A. Fisher.
16+ A comprehensive Python toolkit for **re-randomisation statistics ** in
17+ the tradition of Sir Ronald A. Fisher, extended in v0.2.0 with
18+ time-stratified case-crossover estimators, model-comparison helpers
19+ that share a single algorithmic source for multiple-comparisons
20+ correction, and a dose-response / breakpoint-analysis toolkit
21+ (broken-stick + Davies + Muggeo Pseudo-Score + 4-parameter Hill).
1422
1523Features
1624--------
1725
18- - Fisher's Resampling Test with flexible test statistics (mean, median, sum)
19- - Fisher's Exact Test for 2×2 contingency tables
20- - Multi-group pairwise comparisons with FDR correction
21- - Binomial proportion tests with Wilson confidence intervals
22- - Classical hypothesis test dispatcher (Mann-Whitney U, Kruskal-Wallis, etc.)
23- - CSV data I/O with German-locale support and wide→long conversion
26+ Core (v0.1.0+):
27+
28+ - **Fisher's Resampling Test ** — flexible test statistics
29+ (mean / median / sum differences)
30+ - **Fisher's Exact Test ** — 2×2 contingency table
31+ - **Multi-Group Pairwise Testing ** — with automatic multiple-testing
32+ correction
33+ - **Binomial Proportion Tests ** — single- and two-sample variants
34+ with Wilson confidence intervals
35+ - **Classical Hypothesis Tests ** — unified dispatcher for
36+ Mann-Whitney U, Kruskal-Wallis, Kolmogorov-Smirnov, Mood's
37+ Median, Wilcoxon Rank-Sum, independent t-test, chi-square
38+ - **Data I/O ** — CSV reader with German-locale support and
39+ wide → long table conversion
40+ - **Pretty-Table Output ** — manuscript-ready ASCII / Markdown tables
41+
42+ New in v0.2.0 — three submodules:
43+
44+ - **case_crossover ** — time-stratified case-crossover conditional
45+ logit (Maclure 1991, Lee et al. 2023) with stratified-permutation
46+ backup, daylight-hours covariate, within-event temporal-contrast
47+ test (hot-day-vs-hot-week), and Burke-2015 σ-rescaled effect
48+ translator
49+ - **model_comparison ** — two-sample Wald z-test on
50+ independently-estimated coefficients, nested-model likelihood-
51+ ratio test, single-method correction (`correct_pvalues `), array
52+ helper (`correct_pvalues_array `), and dual-method BH + Bonferroni
53+ report (`benjamini_hochberg `); all four correction helpers route
54+ through one `statsmodels.stats.multitest.multipletests ` call
55+ - **dose_response ** — broken-stick segmented regression with
56+ profile-RSS 95 % CI on the breakpoint, Davies (1987 / 2002) and
57+ Muggeo (2016) Pseudo-Score tests for breakpoint existence,
58+ 4-parameter Hill fit with Sebaugh–McCray (2003) lower-bend point,
59+ and a per-subject iterator that applies any of the four to a panel
60+ of subjects (pickle-safe for ``concurrent.futures.ProcessPoolExecutor ``)
2461
2562Quick Start
2663-----------
2764
65+ Core resampling test:
66+
2867.. code-block :: python
2968
3069 from rerandomstats import FisherResamplingTest
@@ -38,6 +77,43 @@ Quick Start
3877 p_value = test.main()
3978 print (f " p = { p_value:.4f } " )
4079
80+ Multi-comparisons correction on a heterogeneous battery:
81+
82+ .. code-block :: python
83+
84+ from rerandomstats import benjamini_hochberg
85+
86+ # p-values from arbitrary tests (case-crossover, Wald, Poisson, LRT, …)
87+ result = benjamini_hochberg({
88+ " H1" : 0.001 , " H2" : 0.012 , " H3" : 0.040 , " H4" : 0.080 ,
89+ })
90+ for name, row in result[" results" ].items():
91+ print (f " { name} : q = { row[' bh_adjusted_p' ]:.4f } "
92+ f " BH-reject = { row[' bh_reject' ]} " )
93+
94+ Breakpoint detection on dose-response data:
95+
96+ .. code-block :: python
97+
98+ import numpy as np
99+ from rerandomstats import broken_stick_fit, davies_test, hill_fit
100+
101+ x = np.random.uniform(10 , 30 , 300 )
102+ y = np.where(x <= 22 , 38 + 0.05 * x,
103+ 38 + 0.05 * 22 + 0.8 * (x - 22 ))
104+ y += np.random.normal(0 , 0.2 , 300 )
105+
106+ bs = broken_stick_fit(x, y)
107+ print (f " Breakpoint = { bs[' breakpoint' ]:.2f } "
108+ f " [ { bs[' breakpoint_ci_lo' ]:.2f } , { bs[' breakpoint_ci_hi' ]:.2f } ] " )
109+
110+ davies = davies_test(x, y)
111+ print (f " Davies p = { davies[' pvalue' ]:.4f } " )
112+
113+ hill = hill_fit(x, y)
114+ print (f " EC50 = { hill[' ec50' ]:.2f } , Hill n = { hill[' hill_n' ]:.2f } , "
115+ f " lower bend = { hill[' lower_bend' ]:.2f } " )
116+
41117 .. toctree ::
42118 :maxdepth: 2
43119 :caption: Contents
0 commit comments