statscrutiny 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. statscrutiny-0.1.0/.gitignore +14 -0
  2. statscrutiny-0.1.0/CHANGELOG.md +27 -0
  3. statscrutiny-0.1.0/CITATION.cff +19 -0
  4. statscrutiny-0.1.0/LICENSE +21 -0
  5. statscrutiny-0.1.0/PKG-INFO +170 -0
  6. statscrutiny-0.1.0/README.md +143 -0
  7. statscrutiny-0.1.0/pyproject.toml +47 -0
  8. statscrutiny-0.1.0/src/statscrutiny/__init__.py +40 -0
  9. statscrutiny-0.1.0/src/statscrutiny/__main__.py +5 -0
  10. statscrutiny-0.1.0/src/statscrutiny/ci.py +188 -0
  11. statscrutiny-0.1.0/src/statscrutiny/cli.py +119 -0
  12. statscrutiny-0.1.0/src/statscrutiny/counts.py +134 -0
  13. statscrutiny-0.1.0/src/statscrutiny/extract.py +133 -0
  14. statscrutiny-0.1.0/src/statscrutiny/grim.py +68 -0
  15. statscrutiny-0.1.0/src/statscrutiny/grimmer.py +91 -0
  16. statscrutiny-0.1.0/src/statscrutiny/pvalues.py +303 -0
  17. statscrutiny-0.1.0/src/statscrutiny/result.py +45 -0
  18. statscrutiny-0.1.0/src/statscrutiny/rounding.py +123 -0
  19. statscrutiny-0.1.0/src/statscrutiny/samplesize.py +105 -0
  20. statscrutiny-0.1.0/src/statscrutiny/tables.py +195 -0
  21. statscrutiny-0.1.0/tests/test_api.py +33 -0
  22. statscrutiny-0.1.0/tests/test_ci.py +85 -0
  23. statscrutiny-0.1.0/tests/test_cli.py +43 -0
  24. statscrutiny-0.1.0/tests/test_counts.py +78 -0
  25. statscrutiny-0.1.0/tests/test_extract.py +68 -0
  26. statscrutiny-0.1.0/tests/test_grim.py +89 -0
  27. statscrutiny-0.1.0/tests/test_pvalues.py +220 -0
  28. statscrutiny-0.1.0/tests/test_pvalues_strict.py +76 -0
  29. statscrutiny-0.1.0/tests/test_rounding.py +53 -0
  30. statscrutiny-0.1.0/tests/test_samplesize.py +57 -0
  31. statscrutiny-0.1.0/tests/test_statcheck_agreement.py +68 -0
  32. statscrutiny-0.1.0/tests/test_tables.py +65 -0
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .pytest_cache/
4
+ .venv/
5
+ dist/
6
+ build/
7
+ *.egg-info/
8
+
9
+ # Local project notes and the manuscript under double-blind review (kept out of the public repository)
10
+ CLAUDE.md
11
+ AGENTS.md
12
+ notes/
13
+ paper/
14
+ .claude/
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ All notable changes are listed here. Versions follow semantic versioning.
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.1.0] - 2026-12-05
8
+
9
+ First public release. The checks were first written for an audit of randomised trials and are released
10
+ here as a standalone package.
11
+
12
+ ### Added
13
+ - p-value recomputation from t, F, chi-square, r and z (`check_pvalue`, `check_pvalue_both`) with
14
+ lenient (rounding or truncation) and strict (round-to-nearest) modes.
15
+ - `df_method` for approximate df (Welch, Satterthwaite, Kenward-Roger) and for inference that the statistic
16
+ and df do not determine (robust, permutation, bootstrap, mixed-model, GEE, cluster: unassessable).
17
+ - `details["p_form"]`: exact, inequality or ns.
18
+ - GRIM and GRIMMER (`check_grim`, `check_grimmer`), only for data declared integer-valued.
19
+ - Counts and percentages (`check_percentage`, `check_percentage_granularity`), sums of categories
20
+ (`check_count_sum`, `check_percentage_sum`), sample sizes (`compare_sample_sizes`, `check_arm_total`).
21
+ Sums flag only over-summing; under-summing is unresolved.
22
+ - Confidence interval, estimate and p-value consistency (`check_ci_pvalue`).
23
+ - Odds ratio, risk ratio and risk difference from 2 x 2 tables (`check_2x2`).
24
+ - APA-style text extraction (`extract_results`, `check_text`) and a command line interface
25
+ (`statscrutiny text`, `statscrutiny csv`).
26
+ - Validation scripts against statcheck 1.6.1 (`scripts/compare_statcheck.py`,
27
+ `scripts/validate_extraction.py`).
@@ -0,0 +1,19 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use statscrutiny, please cite it as below."
3
+ title: "statscrutiny: conservative consistency checks for reported statistics"
4
+ type: software
5
+ authors:
6
+ - family-names: Garibli
7
+ given-names: Nihat
8
+ orcid: "https://orcid.org/0009-0003-4755-6356"
9
+ affiliation: "Baku State University, Baku, Azerbaijan"
10
+ version: 0.1.0
11
+ date-released: 2026-12-05
12
+ license: MIT
13
+ repository-code: "https://github.com/nihatgaribli/statscrutiny"
14
+ keywords:
15
+ - statcheck
16
+ - GRIM
17
+ - GRIMMER
18
+ - reporting errors
19
+ - research integrity
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nihat Garibli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,170 @@
1
+ Metadata-Version: 2.5
2
+ Name: statscrutiny
3
+ Version: 0.1.0
4
+ Summary: Conservative consistency checks for reported statistics: p-values from test statistics, GRIM, GRIMMER, percentages, sums, sample sizes, confidence intervals and 2x2 tables
5
+ Project-URL: Homepage, https://github.com/nihatgaribli/statscrutiny
6
+ Project-URL: Issues, https://github.com/nihatgaribli/statscrutiny/issues
7
+ Author: Nihat Garibli
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: GRIM,GRIMMER,meta-science,p-value,peer review,reporting errors,research integrity,statcheck
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: numpy>=1.24
23
+ Requires-Dist: scipy>=1.10
24
+ Provides-Extra: test
25
+ Requires-Dist: pytest>=8; extra == 'test'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # statscrutiny
29
+
30
+ Conservative consistency checks for reported statistics, in Python.
31
+
32
+ statscrutiny recomputes what can be recomputed from the numbers an article prints
33
+ and reports where they cannot all be true at once. It covers p-values from t, F,
34
+ χ², r and z statistics (like statcheck), GRIM and GRIMMER for means and SDs of
35
+ integer data, counts and percentages, sums of categories, sample sizes across
36
+ the parts of a report, confidence intervals against estimates and p-values, and
37
+ odds ratios, risk ratios and risk differences against their 2 × 2 tables.
38
+
39
+ Two design rules make it suitable for screening by editors, reviewers and
40
+ meta-researchers, where a false alarm costs an author's time and reputation:
41
+
42
+ 1. **Printed numbers are intervals.** `2.35` stands for every true value that
43
+ rounding (any tie rule) or truncation would print as `2.35`. Arithmetic on
44
+ printed values is exact (fractions).
45
+ 2. **A result is flagged only if it is inconsistent under every reasonable
46
+ reading.** Readings the article does not rule out (one- or two-tailed,
47
+ rounded Welch df, another denominator, a different CI method, a swapped
48
+ reference group) give `unresolved`, not an error. Checks that do not apply
49
+ give `unassessable` and are counted as missing coverage, never as passed.
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ pip install statscrutiny # once released on PyPI
55
+ pip install git+https://github.com/nihatgaribli/statscrutiny # development version
56
+ ```
57
+
58
+ Python 3.11 or newer; depends on NumPy and SciPy.
59
+
60
+ ## Quick start
61
+
62
+ ### Check APA-style results in text
63
+
64
+ ```bash
65
+ statscrutiny text article.txt
66
+ ```
67
+
68
+ ```text
69
+ t(28) = 2.20, p = .036 consistent recomputed p compatible with reported p
70
+ !! F(2, 57) = 3.41, p = .40 inconsistent recomputed p incompatible with reported p under every rounding/truncation convention and changes significance at alpha
71
+
72
+ consistent: 1, inconsistent: 1
73
+ ```
74
+
75
+ Options: `--format csv|json`, `--mode strict` (round-to-nearest only, closest to
76
+ statcheck), `--tails two`, `--only-flags`, `--fail-on-flag`. `statscrutiny csv results.csv`
77
+ checks one result per row (columns `test, stat, p, comparator, df1, df2, n, tails,
78
+ adjusted, df_method`).
79
+
80
+ ### From Python
81
+
82
+ Pass printed numbers as strings, so that trailing zeros keep their meaning.
83
+
84
+ ```python
85
+ import statscrutiny as sc
86
+
87
+ sc.check_pvalue("t", "2.20", ".036", df1="28").status # consistent
88
+ sc.check_pvalue("F", "3.41", ".40", df1="2", df2="57").details["crosses_alpha"] # True
89
+ sc.check_pvalue("t", "3.10", ".07", df1="2", tails="two").status # unresolved: fits only a rounded Welch df
90
+
91
+ sc.check_grim("5.19", 28, integer_data=True).status # inconsistent: no integer total gives 5.19
92
+ sc.check_grimmer("3.48", "1.12", 25, integer_data=True).status
93
+ sc.check_percentage(23, 64, "39.1").status # inconsistent (23/64 = 35.9%)
94
+ sc.check_count_sum([20, 15, 6], 40, mutually_exclusive=True).status # inconsistent: over-summing
95
+
96
+ sc.check_ci_pvalue("2.50", "0.50", "4.50", ".14").status # unresolved: CI excludes 0 but p = .14
97
+ sc.check_ci_pvalue("2.50", "0.50", "4.50", ".14", same_test=True).status # inconsistent
98
+ sc.check_2x2(20, 30, 10, 40, "OR", "2.67", "1.09", "6.52").status # consistent (Woolf CI)
99
+
100
+ for found, result in sc.check_text("Participants improved, t(28) = 2.20, p = .036."):
101
+ print(found.text, result.status)
102
+ ```
103
+
104
+ Every check returns a `CheckResult(check, status, reason, details)`.
105
+
106
+ | Status | Meaning |
107
+ | --- | --- |
108
+ | `consistent` | the numbers can agree under some rounding convention and supported interpretation |
109
+ | `inconsistent` | they disagree under every convention and every supported interpretation (a flag) |
110
+ | `unresolved` | they disagree as stated but agree under another plausible reading the article does not rule out |
111
+ | `unassessable` | the check does not apply (adjusted statistics, missing inputs, undeclared integer data, ...) |
112
+
113
+ ## Checks
114
+
115
+ | Function | Method | Rules |
116
+ | --- | --- | --- |
117
+ | `check_pvalue`, `check_pvalue_both` | recompute p from t, F, χ², r, z and df (statcheck; Nuijten et al., 2016) | lenient (rounding or truncation; used for flags) and strict (round-to-nearest) modes; either tail only for t, z, r when unstated, F and χ² upper-tailed; `p < x`, `p > x`, `ns` checked as sets; integer df that fit only as a rounded Welch df → unresolved; `df_method='welch'/'satterthwaite'/'kenward-roger'` treats df as approximate; robust, permutation, bootstrap, mixed-model, GEE and cluster inference → unassessable; adjusted p → unassessable; `crosses_alpha` marks errors that change significance |
118
+ | `check_grim` | GRIM (Brown & Heathers, 2017) | only when the caller declares integer (or 1/k item-mean) data; unadjusted means; unassessable when n·k ≥ 10^decimals |
119
+ | `check_grimmer` | GRIMMER (Anaya, 2016) | sum of squares an integer of the same parity as the sum; SD with n − 1 or n accepted when unstated |
120
+ | `check_percentage`, `check_percentage_granularity` | count/denominator vs percentage | an alternative reported denominator that fits → unresolved |
121
+ | `check_count_sum`, `check_percentage_sum` | sums of categories | only for mutually exclusive categories; over-summing → inconsistent, under-summing → unresolved |
122
+ | `compare_sample_sizes`, `check_arm_total` | sample sizes across abstract, flow diagram, tables | compared only for the same arm, time point and population; attrition is never an error |
123
+ | `check_ci_pvalue` | CI ↔ estimate ↔ p (Altman & Bland, 2011) | estimate outside its CI → inconsistent; CI excludes the null but p ≥ α (or the reverse) → inconsistent only if the CI and p are declared to come from the same Wald test, else unresolved; with a declared z or t distribution, p is recomputed from the CI; ratio measures on the log scale |
124
+ | `check_2x2` | OR, RR, RD from a 2 × 2 table | exact point estimate; Haldane correction accepted for zero cells; match only with the reference swapped → unresolved; CI vs Woolf (OR), Katz (RR), Wald (RD) → unresolved unless the method is declared |
125
+ | `extract_results`, `check_text` | APA-style results in text | t, F, r, χ² (incl. `N =`), z; comma or semicolon before p; any minus sign; tails and p-value adjustment read from the same sentence |
126
+
127
+ All are necessary-condition tests: passing them does not show that a number is correct.
128
+
129
+ ## Comparison with statcheck
130
+
131
+ | | statcheck (R) | statscrutiny (Python) |
132
+ | --- | --- | --- |
133
+ | p from t, F, χ², r, z | yes | yes |
134
+ | printed numbers | rounding of the statistic | rounding **or truncation** of every number, exact arithmetic |
135
+ | one-tailed tests | two-tailed by default; one-tailed through options | either tail accepted when unstated (t, z, r); stated tails read from the sentence |
136
+ | outcome | error / decision error | consistent / inconsistent / unresolved / unassessable, `crosses_alpha` |
137
+ | text extraction | PDF, HTML, text | plain text |
138
+ | GRIM, GRIMMER, percentages, sums, sample sizes, CI, 2 × 2 tables | no | yes |
139
+
140
+ Validation (scripts in `scripts/`, data in `data/validation/`), statcheck 1.6.1 on R 4.6.2:
141
+
142
+ * **p-values**: 3,000 synthetic APA results (seed 20261203). Strict two-tailed mode agrees with statcheck on
143
+ 2,999 / 3,000; the single difference (`t(7) = -4.1, p = .006`) fits a rounded Welch df and is `unresolved`.
144
+ The default lenient rule never flags a result that statcheck accepts.
145
+ * **text extraction**: the same 3,000 results written in varied formats (seed 20261205). statscrutiny extracted
146
+ 3,000 with every value correct, statcheck 2,354 (it does not read a semicolon before p, the superscript ²,
147
+ or a z at the start of a line). On the 2,354 extracted by both, values were identical and the strict
148
+ two-tailed flags agreed on 2,353 (99.96%).
149
+
150
+ The format mix of the extraction test was chosen by the developer; it shows that the listed formats are read
151
+ correctly, not how often they occur in real articles.
152
+
153
+ ## Citing
154
+
155
+ See `CITATION.cff`.
156
+
157
+ ## Contributing
158
+
159
+ Bug reports and pull requests are welcome; see `CONTRIBUTING.md`.
160
+
161
+ ## Licence
162
+
163
+ MIT. See `LICENSE`.
164
+
165
+ ## References
166
+
167
+ * Altman DG, Bland JM. How to obtain the P value from a confidence interval. BMJ. 2011;343:d2304.
168
+ * Anaya J. The GRIMMER test: a method for testing the validity of reported measures of variability. PeerJ Preprints. 2016;4:e2400v1.
169
+ * Brown NJL, Heathers JAJ. The GRIM test: a simple technique detects numerous anomalies in the reporting of results in psychology. Soc Psychol Personal Sci. 2017;8(4):363-9.
170
+ * Nuijten MB, Hartgerink CHJ, van Assen MALM, Epskamp S, Wicherts JM. The prevalence of statistical reporting errors in psychology (1985-2013). Behav Res Methods. 2016;48(4):1205-26.
@@ -0,0 +1,143 @@
1
+ # statscrutiny
2
+
3
+ Conservative consistency checks for reported statistics, in Python.
4
+
5
+ statscrutiny recomputes what can be recomputed from the numbers an article prints
6
+ and reports where they cannot all be true at once. It covers p-values from t, F,
7
+ χ², r and z statistics (like statcheck), GRIM and GRIMMER for means and SDs of
8
+ integer data, counts and percentages, sums of categories, sample sizes across
9
+ the parts of a report, confidence intervals against estimates and p-values, and
10
+ odds ratios, risk ratios and risk differences against their 2 × 2 tables.
11
+
12
+ Two design rules make it suitable for screening by editors, reviewers and
13
+ meta-researchers, where a false alarm costs an author's time and reputation:
14
+
15
+ 1. **Printed numbers are intervals.** `2.35` stands for every true value that
16
+ rounding (any tie rule) or truncation would print as `2.35`. Arithmetic on
17
+ printed values is exact (fractions).
18
+ 2. **A result is flagged only if it is inconsistent under every reasonable
19
+ reading.** Readings the article does not rule out (one- or two-tailed,
20
+ rounded Welch df, another denominator, a different CI method, a swapped
21
+ reference group) give `unresolved`, not an error. Checks that do not apply
22
+ give `unassessable` and are counted as missing coverage, never as passed.
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install statscrutiny # once released on PyPI
28
+ pip install git+https://github.com/nihatgaribli/statscrutiny # development version
29
+ ```
30
+
31
+ Python 3.11 or newer; depends on NumPy and SciPy.
32
+
33
+ ## Quick start
34
+
35
+ ### Check APA-style results in text
36
+
37
+ ```bash
38
+ statscrutiny text article.txt
39
+ ```
40
+
41
+ ```text
42
+ t(28) = 2.20, p = .036 consistent recomputed p compatible with reported p
43
+ !! F(2, 57) = 3.41, p = .40 inconsistent recomputed p incompatible with reported p under every rounding/truncation convention and changes significance at alpha
44
+
45
+ consistent: 1, inconsistent: 1
46
+ ```
47
+
48
+ Options: `--format csv|json`, `--mode strict` (round-to-nearest only, closest to
49
+ statcheck), `--tails two`, `--only-flags`, `--fail-on-flag`. `statscrutiny csv results.csv`
50
+ checks one result per row (columns `test, stat, p, comparator, df1, df2, n, tails,
51
+ adjusted, df_method`).
52
+
53
+ ### From Python
54
+
55
+ Pass printed numbers as strings, so that trailing zeros keep their meaning.
56
+
57
+ ```python
58
+ import statscrutiny as sc
59
+
60
+ sc.check_pvalue("t", "2.20", ".036", df1="28").status # consistent
61
+ sc.check_pvalue("F", "3.41", ".40", df1="2", df2="57").details["crosses_alpha"] # True
62
+ sc.check_pvalue("t", "3.10", ".07", df1="2", tails="two").status # unresolved: fits only a rounded Welch df
63
+
64
+ sc.check_grim("5.19", 28, integer_data=True).status # inconsistent: no integer total gives 5.19
65
+ sc.check_grimmer("3.48", "1.12", 25, integer_data=True).status
66
+ sc.check_percentage(23, 64, "39.1").status # inconsistent (23/64 = 35.9%)
67
+ sc.check_count_sum([20, 15, 6], 40, mutually_exclusive=True).status # inconsistent: over-summing
68
+
69
+ sc.check_ci_pvalue("2.50", "0.50", "4.50", ".14").status # unresolved: CI excludes 0 but p = .14
70
+ sc.check_ci_pvalue("2.50", "0.50", "4.50", ".14", same_test=True).status # inconsistent
71
+ sc.check_2x2(20, 30, 10, 40, "OR", "2.67", "1.09", "6.52").status # consistent (Woolf CI)
72
+
73
+ for found, result in sc.check_text("Participants improved, t(28) = 2.20, p = .036."):
74
+ print(found.text, result.status)
75
+ ```
76
+
77
+ Every check returns a `CheckResult(check, status, reason, details)`.
78
+
79
+ | Status | Meaning |
80
+ | --- | --- |
81
+ | `consistent` | the numbers can agree under some rounding convention and supported interpretation |
82
+ | `inconsistent` | they disagree under every convention and every supported interpretation (a flag) |
83
+ | `unresolved` | they disagree as stated but agree under another plausible reading the article does not rule out |
84
+ | `unassessable` | the check does not apply (adjusted statistics, missing inputs, undeclared integer data, ...) |
85
+
86
+ ## Checks
87
+
88
+ | Function | Method | Rules |
89
+ | --- | --- | --- |
90
+ | `check_pvalue`, `check_pvalue_both` | recompute p from t, F, χ², r, z and df (statcheck; Nuijten et al., 2016) | lenient (rounding or truncation; used for flags) and strict (round-to-nearest) modes; either tail only for t, z, r when unstated, F and χ² upper-tailed; `p < x`, `p > x`, `ns` checked as sets; integer df that fit only as a rounded Welch df → unresolved; `df_method='welch'/'satterthwaite'/'kenward-roger'` treats df as approximate; robust, permutation, bootstrap, mixed-model, GEE and cluster inference → unassessable; adjusted p → unassessable; `crosses_alpha` marks errors that change significance |
91
+ | `check_grim` | GRIM (Brown & Heathers, 2017) | only when the caller declares integer (or 1/k item-mean) data; unadjusted means; unassessable when n·k ≥ 10^decimals |
92
+ | `check_grimmer` | GRIMMER (Anaya, 2016) | sum of squares an integer of the same parity as the sum; SD with n − 1 or n accepted when unstated |
93
+ | `check_percentage`, `check_percentage_granularity` | count/denominator vs percentage | an alternative reported denominator that fits → unresolved |
94
+ | `check_count_sum`, `check_percentage_sum` | sums of categories | only for mutually exclusive categories; over-summing → inconsistent, under-summing → unresolved |
95
+ | `compare_sample_sizes`, `check_arm_total` | sample sizes across abstract, flow diagram, tables | compared only for the same arm, time point and population; attrition is never an error |
96
+ | `check_ci_pvalue` | CI ↔ estimate ↔ p (Altman & Bland, 2011) | estimate outside its CI → inconsistent; CI excludes the null but p ≥ α (or the reverse) → inconsistent only if the CI and p are declared to come from the same Wald test, else unresolved; with a declared z or t distribution, p is recomputed from the CI; ratio measures on the log scale |
97
+ | `check_2x2` | OR, RR, RD from a 2 × 2 table | exact point estimate; Haldane correction accepted for zero cells; match only with the reference swapped → unresolved; CI vs Woolf (OR), Katz (RR), Wald (RD) → unresolved unless the method is declared |
98
+ | `extract_results`, `check_text` | APA-style results in text | t, F, r, χ² (incl. `N =`), z; comma or semicolon before p; any minus sign; tails and p-value adjustment read from the same sentence |
99
+
100
+ All are necessary-condition tests: passing them does not show that a number is correct.
101
+
102
+ ## Comparison with statcheck
103
+
104
+ | | statcheck (R) | statscrutiny (Python) |
105
+ | --- | --- | --- |
106
+ | p from t, F, χ², r, z | yes | yes |
107
+ | printed numbers | rounding of the statistic | rounding **or truncation** of every number, exact arithmetic |
108
+ | one-tailed tests | two-tailed by default; one-tailed through options | either tail accepted when unstated (t, z, r); stated tails read from the sentence |
109
+ | outcome | error / decision error | consistent / inconsistent / unresolved / unassessable, `crosses_alpha` |
110
+ | text extraction | PDF, HTML, text | plain text |
111
+ | GRIM, GRIMMER, percentages, sums, sample sizes, CI, 2 × 2 tables | no | yes |
112
+
113
+ Validation (scripts in `scripts/`, data in `data/validation/`), statcheck 1.6.1 on R 4.6.2:
114
+
115
+ * **p-values**: 3,000 synthetic APA results (seed 20261203). Strict two-tailed mode agrees with statcheck on
116
+ 2,999 / 3,000; the single difference (`t(7) = -4.1, p = .006`) fits a rounded Welch df and is `unresolved`.
117
+ The default lenient rule never flags a result that statcheck accepts.
118
+ * **text extraction**: the same 3,000 results written in varied formats (seed 20261205). statscrutiny extracted
119
+ 3,000 with every value correct, statcheck 2,354 (it does not read a semicolon before p, the superscript ²,
120
+ or a z at the start of a line). On the 2,354 extracted by both, values were identical and the strict
121
+ two-tailed flags agreed on 2,353 (99.96%).
122
+
123
+ The format mix of the extraction test was chosen by the developer; it shows that the listed formats are read
124
+ correctly, not how often they occur in real articles.
125
+
126
+ ## Citing
127
+
128
+ See `CITATION.cff`.
129
+
130
+ ## Contributing
131
+
132
+ Bug reports and pull requests are welcome; see `CONTRIBUTING.md`.
133
+
134
+ ## Licence
135
+
136
+ MIT. See `LICENSE`.
137
+
138
+ ## References
139
+
140
+ * Altman DG, Bland JM. How to obtain the P value from a confidence interval. BMJ. 2011;343:d2304.
141
+ * Anaya J. The GRIMMER test: a method for testing the validity of reported measures of variability. PeerJ Preprints. 2016;4:e2400v1.
142
+ * Brown NJL, Heathers JAJ. The GRIM test: a simple technique detects numerous anomalies in the reporting of results in psychology. Soc Psychol Personal Sci. 2017;8(4):363-9.
143
+ * Nuijten MB, Hartgerink CHJ, van Assen MALM, Epskamp S, Wicherts JM. The prevalence of statistical reporting errors in psychology (1985-2013). Behav Res Methods. 2016;48(4):1205-26.
@@ -0,0 +1,47 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "statscrutiny"
7
+ version = "0.1.0"
8
+ description = "Conservative consistency checks for reported statistics: p-values from test statistics, GRIM, GRIMMER, percentages, sums, sample sizes, confidence intervals and 2x2 tables"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "Nihat Garibli" }]
13
+ requires-python = ">=3.11"
14
+ dependencies = ["numpy>=1.24", "scipy>=1.10"]
15
+ keywords = ["statcheck", "GRIM", "GRIMMER", "p-value", "reporting errors", "research integrity", "meta-science", "peer review"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Science/Research",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Topic :: Scientific/Engineering :: Information Analysis",
27
+ ]
28
+
29
+ [project.optional-dependencies]
30
+ test = ["pytest>=8"]
31
+
32
+ [project.scripts]
33
+ statscrutiny = "statscrutiny.cli:main"
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/nihatgaribli/statscrutiny"
37
+ Issues = "https://github.com/nihatgaribli/statscrutiny/issues"
38
+
39
+ [tool.hatch.build.targets.wheel]
40
+ packages = ["src/statscrutiny"]
41
+
42
+ [tool.hatch.build.targets.sdist]
43
+ include = ["src", "tests", "README.md", "LICENSE", "CHANGELOG.md", "CITATION.cff"]
44
+
45
+ [tool.pytest.ini_options]
46
+ pythonpath = ["src"]
47
+ testpaths = ["tests"]
@@ -0,0 +1,40 @@
1
+ """statscrutiny: conservative consistency checks for reported statistics.
2
+
3
+ Every check takes the numbers as printed (strings, so that trailing zeros keep
4
+ their meaning) and returns a CheckResult with one of four statuses:
5
+ CONSISTENT, INCONSISTENT, UNRESOLVED or UNASSESSABLE. Printed numbers are
6
+ treated as intervals (rounding or truncation), and a result is INCONSISTENT only
7
+ if it disagrees under every reasonable convention and supported interpretation.
8
+
9
+ Check families:
10
+ p-values from t, F, chi2, r, z check_pvalue, check_pvalue_both
11
+ means and SDs of integer data check_grim, check_grimmer
12
+ counts and percentages check_percentage, check_percentage_granularity,
13
+ check_count_sum, check_percentage_sum
14
+ sample sizes compare_sample_sizes, check_arm_total
15
+ confidence intervals check_ci_pvalue
16
+ 2 x 2 tables (OR, RR, RD) check_2x2
17
+ APA-style text extract_results, check_text
18
+ """
19
+
20
+ from .ci import check_ci_pvalue
21
+ from .counts import check_count_sum, check_percentage, check_percentage_granularity, check_percentage_sum
22
+ from .extract import ReportedResult, check_text, extract_results
23
+ from .grim import check_grim
24
+ from .grimmer import check_grimmer
25
+ from .pvalues import check_pvalue, check_pvalue_both
26
+ from .result import CheckResult, Status
27
+ from .samplesize import SampleSizeReport, check_arm_total, compare_sample_sizes
28
+ from .tables import check_2x2
29
+
30
+ __version__ = "0.1.0"
31
+
32
+ __all__ = [
33
+ "CheckResult", "Status", "__version__",
34
+ "check_pvalue", "check_pvalue_both",
35
+ "check_grim", "check_grimmer",
36
+ "check_percentage", "check_percentage_granularity", "check_count_sum", "check_percentage_sum",
37
+ "SampleSizeReport", "compare_sample_sizes", "check_arm_total",
38
+ "check_ci_pvalue", "check_2x2",
39
+ "ReportedResult", "extract_results", "check_text",
40
+ ]
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())