crosstabs 1.0.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.
- crosstabs-1.0.0/.gitignore +45 -0
- crosstabs-1.0.0/PKG-INFO +263 -0
- crosstabs-1.0.0/README.md +229 -0
- crosstabs-1.0.0/crosstabs_mcp/__init__.py +29 -0
- crosstabs-1.0.0/crosstabs_mcp/advanced_stats.py +360 -0
- crosstabs-1.0.0/crosstabs_mcp/server.py +2499 -0
- crosstabs-1.0.0/pyproject.toml +71 -0
- crosstabs-1.0.0/requirements.txt +17 -0
- crosstabs-1.0.0/server.json +21 -0
- crosstabs-1.0.0/tests/__init__.py +1 -0
- crosstabs-1.0.0/tests/test_statistics.py +522 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
venv/
|
|
25
|
+
ENV/
|
|
26
|
+
env/
|
|
27
|
+
|
|
28
|
+
# Testing
|
|
29
|
+
.pytest_cache/
|
|
30
|
+
.coverage
|
|
31
|
+
htmlcov/
|
|
32
|
+
.tox/
|
|
33
|
+
.nox/
|
|
34
|
+
|
|
35
|
+
# IDE
|
|
36
|
+
.idea/
|
|
37
|
+
.vscode/
|
|
38
|
+
*.swp
|
|
39
|
+
*.swo
|
|
40
|
+
|
|
41
|
+
# Claude
|
|
42
|
+
CLAUDE.md
|
|
43
|
+
|
|
44
|
+
# MCP Registry tokens
|
|
45
|
+
.mcpregistry_*
|
crosstabs-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: crosstabs
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: MCP server for statistical crosstabulation analysis with 40+ tools
|
|
5
|
+
Project-URL: Homepage, https://github.com/barangaroo/crosstabs-lite
|
|
6
|
+
Project-URL: Repository, https://github.com/barangaroo/crosstabs-lite
|
|
7
|
+
Project-URL: Documentation, https://github.com/barangaroo/crosstabs-lite/tree/main/mcp-server-python
|
|
8
|
+
Project-URL: Issues, https://github.com/barangaroo/crosstabs-lite/issues
|
|
9
|
+
Author: Crosstabs Team
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
Keywords: chi-square,contingency-tables,cramers-v,crosstabs,fisher-exact,mcp,model-context-protocol,odds-ratio,statistical-analysis,statistics
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: fastmcp>=0.1.0
|
|
25
|
+
Requires-Dist: mcp>=1.0.0
|
|
26
|
+
Requires-Dist: numpy>=1.24.0
|
|
27
|
+
Requires-Dist: pandas>=2.0.0
|
|
28
|
+
Requires-Dist: scipy>=1.10.0
|
|
29
|
+
Requires-Dist: statsmodels>=0.14.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# Crosstabs MCP Server
|
|
36
|
+
|
|
37
|
+
<!-- mcp-name: io.github.barangaroo/crosstabs -->
|
|
38
|
+
|
|
39
|
+
[](https://www.python.org/downloads/)
|
|
40
|
+
[](https://opensource.org/licenses/MIT)
|
|
41
|
+
[](https://modelcontextprotocol.io)
|
|
42
|
+
|
|
43
|
+
A Python MCP (Model Context Protocol) server providing **40+ statistical tools** for contingency table analysis. Designed for AI assistants like Claude to perform rigorous statistical analysis.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
### Core Statistical Tests
|
|
48
|
+
| Test | Description |
|
|
49
|
+
|------|-------------|
|
|
50
|
+
| **Chi-square** | Pearson's chi-square test of independence |
|
|
51
|
+
| **G-test** | Likelihood ratio test (more accurate for small samples) |
|
|
52
|
+
| **Fisher's exact** | Exact test for 2×2 tables |
|
|
53
|
+
| **McNemar's** | Test for paired categorical data |
|
|
54
|
+
|
|
55
|
+
### Effect Sizes & Measures
|
|
56
|
+
| Measure | Use Case |
|
|
57
|
+
|---------|----------|
|
|
58
|
+
| **Cramér's V** | Effect size for any table size (with bias correction) |
|
|
59
|
+
| **Phi coefficient** | Effect size for 2×2 tables |
|
|
60
|
+
| **Odds ratio** | Association strength with confidence intervals |
|
|
61
|
+
| **Relative risk** | Risk comparison between groups |
|
|
62
|
+
| **Risk difference** | Absolute risk reduction |
|
|
63
|
+
| **Attributable risk** | Population-level impact |
|
|
64
|
+
|
|
65
|
+
### Ordinal Measures
|
|
66
|
+
| Measure | Description |
|
|
67
|
+
|---------|-------------|
|
|
68
|
+
| **Spearman's rho** | Rank correlation |
|
|
69
|
+
| **Kendall's tau** | Concordance measure |
|
|
70
|
+
| **Goodman-Kruskal gamma** | Ordinal association |
|
|
71
|
+
| **Somers' D** | Asymmetric ordinal measure |
|
|
72
|
+
| **Stuart's tau-c** | Rectangular table measure |
|
|
73
|
+
|
|
74
|
+
### Agreement & Reliability
|
|
75
|
+
| Measure | Description |
|
|
76
|
+
|---------|-------------|
|
|
77
|
+
| **Cohen's kappa** | Inter-rater agreement |
|
|
78
|
+
| **Weighted kappa** | Agreement with ordinal weights |
|
|
79
|
+
|
|
80
|
+
### Advanced Analysis
|
|
81
|
+
| Tool | Description |
|
|
82
|
+
|------|-------------|
|
|
83
|
+
| **CMH test** | Stratified analysis controlling confounders |
|
|
84
|
+
| **Breslow-Day** | Test homogeneity of odds ratios |
|
|
85
|
+
| **Correspondence analysis** | Dimensionality reduction for tables |
|
|
86
|
+
| **Monte Carlo chi-square** | Exact p-values via simulation |
|
|
87
|
+
| **Power analysis** | Sample size and power calculations |
|
|
88
|
+
| **Multiple comparisons** | Bonferroni and FDR corrections |
|
|
89
|
+
|
|
90
|
+
## Installation
|
|
91
|
+
|
|
92
|
+
### From PyPI (recommended)
|
|
93
|
+
```bash
|
|
94
|
+
pip install crosstabs
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### From source
|
|
98
|
+
```bash
|
|
99
|
+
git clone https://github.com/barangaroo/crosstabs-lite.git
|
|
100
|
+
cd crosstabs-lite/mcp-server-python
|
|
101
|
+
pip install -e .
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Quick Start
|
|
105
|
+
|
|
106
|
+
### Run the MCP Server
|
|
107
|
+
```bash
|
|
108
|
+
crosstabs
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Or directly:
|
|
112
|
+
```bash
|
|
113
|
+
python -m crosstabs_mcp.server
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Configure Claude Code
|
|
117
|
+
|
|
118
|
+
Add to your `~/.claude/claude_desktop_config.json`:
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"mcpServers": {
|
|
123
|
+
"crosstabs": {
|
|
124
|
+
"command": "crosstabs"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Or with Python path:
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"mcpServers": {
|
|
134
|
+
"crosstabs": {
|
|
135
|
+
"command": "python",
|
|
136
|
+
"args": ["-m", "crosstabs_mcp.server"]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Usage Examples
|
|
143
|
+
|
|
144
|
+
Once configured, Claude can perform statistical analysis:
|
|
145
|
+
|
|
146
|
+
### Chi-square Test
|
|
147
|
+
```
|
|
148
|
+
User: Test if there's an association between treatment and outcome:
|
|
149
|
+
Treatment A: 50 success, 30 failure
|
|
150
|
+
Treatment B: 20 success, 40 failure
|
|
151
|
+
|
|
152
|
+
Claude: [Uses chi_square_test with matrix [[50,30],[20,40]]]
|
|
153
|
+
χ² = 11.67, p = 0.0006
|
|
154
|
+
Cramér's V = 0.29 (small-medium effect)
|
|
155
|
+
There is a significant association between treatment and outcome.
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Odds Ratio
|
|
159
|
+
```
|
|
160
|
+
User: Calculate the odds ratio for this case-control study:
|
|
161
|
+
Cases: 30 exposed, 70 unexposed
|
|
162
|
+
Controls: 15 exposed, 85 unexposed
|
|
163
|
+
|
|
164
|
+
Claude: [Uses odds_ratio with matrix [[30,70],[15,85]]]
|
|
165
|
+
OR = 2.43 (95% CI: 1.21-4.87)
|
|
166
|
+
Exposure is associated with 143% higher odds of the outcome.
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Fisher's Exact Test
|
|
170
|
+
```
|
|
171
|
+
User: I have a small sample: [[3,1],[1,5]]. Is it significant?
|
|
172
|
+
|
|
173
|
+
Claude: [Uses fishers_exact with the matrix]
|
|
174
|
+
p = 0.103 (two-tailed)
|
|
175
|
+
Not statistically significant at α=0.05.
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Available Tools
|
|
179
|
+
|
|
180
|
+
| Tool Name | Description |
|
|
181
|
+
|-----------|-------------|
|
|
182
|
+
| `chi_square_test` | Chi-square test of independence |
|
|
183
|
+
| `g_test` | G-test (likelihood ratio) |
|
|
184
|
+
| `fishers_exact` | Fisher's exact test (2×2) |
|
|
185
|
+
| `mcnemar_test` | McNemar's test for paired data |
|
|
186
|
+
| `odds_ratio` | Odds ratio with CI |
|
|
187
|
+
| `relative_risk` | Relative risk with CI |
|
|
188
|
+
| `risk_difference` | Risk difference with CI |
|
|
189
|
+
| `cramers_v` | Cramér's V effect size |
|
|
190
|
+
| `cramers_v_corrected` | Bias-corrected Cramér's V |
|
|
191
|
+
| `phi_coefficient` | Phi for 2×2 tables |
|
|
192
|
+
| `cohens_kappa` | Cohen's kappa |
|
|
193
|
+
| `weighted_kappa` | Weighted kappa |
|
|
194
|
+
| `spearmans_rho` | Spearman's rank correlation |
|
|
195
|
+
| `kendalls_tau` | Kendall's tau-b |
|
|
196
|
+
| `goodman_kruskal_gamma` | Gamma coefficient |
|
|
197
|
+
| `somers_d` | Somers' D |
|
|
198
|
+
| `tau_c` | Stuart's tau-c |
|
|
199
|
+
| `cmh_test` | Cochran-Mantel-Haenszel |
|
|
200
|
+
| `breslow_day` | Breslow-Day test |
|
|
201
|
+
| `linear_trend_test` | Linear-by-linear association |
|
|
202
|
+
| `correspondence_analysis` | Correspondence analysis |
|
|
203
|
+
| `monte_carlo_chi_square` | Monte Carlo exact test |
|
|
204
|
+
| `power_analysis` | Power/sample size |
|
|
205
|
+
| `bonferroni_correction` | Bonferroni p-value adjustment |
|
|
206
|
+
| `fdr_correction` | Benjamini-Hochberg FDR |
|
|
207
|
+
| `standardized_residuals` | Cell residuals |
|
|
208
|
+
| `post_hoc_analysis` | Post-hoc chi-square decomposition |
|
|
209
|
+
| `proportion_ci` | Confidence interval for proportion |
|
|
210
|
+
| `check_assumptions` | Validate chi-square assumptions |
|
|
211
|
+
| `mosaic_plot_data` | Data for mosaic visualization |
|
|
212
|
+
| `stacked_bar_data` | Data for stacked bar chart |
|
|
213
|
+
| `attributable_risk` | Attributable risk measures |
|
|
214
|
+
| `chi_square_yates` | Yates' continuity correction |
|
|
215
|
+
| `detect_outliers` | Outlier detection |
|
|
216
|
+
| `crosstab_from_data` | Build table from raw data |
|
|
217
|
+
| `crosstab_from_csv` | Build table from CSV |
|
|
218
|
+
|
|
219
|
+
## Development
|
|
220
|
+
|
|
221
|
+
### Run Tests
|
|
222
|
+
```bash
|
|
223
|
+
pip install -e ".[dev]"
|
|
224
|
+
pytest tests/ -v
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Project Structure
|
|
228
|
+
```
|
|
229
|
+
mcp-server-python/
|
|
230
|
+
├── crosstabs_mcp/
|
|
231
|
+
│ ├── __init__.py
|
|
232
|
+
│ ├── server.py # Main MCP server
|
|
233
|
+
│ └── advanced_stats.py # Additional functions
|
|
234
|
+
├── tests/
|
|
235
|
+
│ └── test_statistics.py # Test suite (52 tests)
|
|
236
|
+
├── pyproject.toml
|
|
237
|
+
├── requirements.txt
|
|
238
|
+
└── README.md
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Requirements
|
|
242
|
+
|
|
243
|
+
- Python 3.10+
|
|
244
|
+
- mcp >= 1.0.0
|
|
245
|
+
- fastmcp >= 0.1.0
|
|
246
|
+
- numpy >= 1.24.0
|
|
247
|
+
- scipy >= 1.10.0
|
|
248
|
+
- pandas >= 2.0.0
|
|
249
|
+
- statsmodels >= 0.14.0
|
|
250
|
+
|
|
251
|
+
## License
|
|
252
|
+
|
|
253
|
+
MIT License - see [LICENSE](../LICENSE) for details.
|
|
254
|
+
|
|
255
|
+
## Contributing
|
|
256
|
+
|
|
257
|
+
Contributions welcome! Please read [CONTRIBUTING.md](../CONTRIBUTING.md) first.
|
|
258
|
+
|
|
259
|
+
## Links
|
|
260
|
+
|
|
261
|
+
- [Main Repository](https://github.com/barangaroo/crosstabs-lite)
|
|
262
|
+
- [Web Application](https://crosstabs-lite.vercel.app)
|
|
263
|
+
- [MCP Documentation](https://modelcontextprotocol.io)
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# Crosstabs MCP Server
|
|
2
|
+
|
|
3
|
+
<!-- mcp-name: io.github.barangaroo/crosstabs -->
|
|
4
|
+
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://modelcontextprotocol.io)
|
|
8
|
+
|
|
9
|
+
A Python MCP (Model Context Protocol) server providing **40+ statistical tools** for contingency table analysis. Designed for AI assistants like Claude to perform rigorous statistical analysis.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
### Core Statistical Tests
|
|
14
|
+
| Test | Description |
|
|
15
|
+
|------|-------------|
|
|
16
|
+
| **Chi-square** | Pearson's chi-square test of independence |
|
|
17
|
+
| **G-test** | Likelihood ratio test (more accurate for small samples) |
|
|
18
|
+
| **Fisher's exact** | Exact test for 2×2 tables |
|
|
19
|
+
| **McNemar's** | Test for paired categorical data |
|
|
20
|
+
|
|
21
|
+
### Effect Sizes & Measures
|
|
22
|
+
| Measure | Use Case |
|
|
23
|
+
|---------|----------|
|
|
24
|
+
| **Cramér's V** | Effect size for any table size (with bias correction) |
|
|
25
|
+
| **Phi coefficient** | Effect size for 2×2 tables |
|
|
26
|
+
| **Odds ratio** | Association strength with confidence intervals |
|
|
27
|
+
| **Relative risk** | Risk comparison between groups |
|
|
28
|
+
| **Risk difference** | Absolute risk reduction |
|
|
29
|
+
| **Attributable risk** | Population-level impact |
|
|
30
|
+
|
|
31
|
+
### Ordinal Measures
|
|
32
|
+
| Measure | Description |
|
|
33
|
+
|---------|-------------|
|
|
34
|
+
| **Spearman's rho** | Rank correlation |
|
|
35
|
+
| **Kendall's tau** | Concordance measure |
|
|
36
|
+
| **Goodman-Kruskal gamma** | Ordinal association |
|
|
37
|
+
| **Somers' D** | Asymmetric ordinal measure |
|
|
38
|
+
| **Stuart's tau-c** | Rectangular table measure |
|
|
39
|
+
|
|
40
|
+
### Agreement & Reliability
|
|
41
|
+
| Measure | Description |
|
|
42
|
+
|---------|-------------|
|
|
43
|
+
| **Cohen's kappa** | Inter-rater agreement |
|
|
44
|
+
| **Weighted kappa** | Agreement with ordinal weights |
|
|
45
|
+
|
|
46
|
+
### Advanced Analysis
|
|
47
|
+
| Tool | Description |
|
|
48
|
+
|------|-------------|
|
|
49
|
+
| **CMH test** | Stratified analysis controlling confounders |
|
|
50
|
+
| **Breslow-Day** | Test homogeneity of odds ratios |
|
|
51
|
+
| **Correspondence analysis** | Dimensionality reduction for tables |
|
|
52
|
+
| **Monte Carlo chi-square** | Exact p-values via simulation |
|
|
53
|
+
| **Power analysis** | Sample size and power calculations |
|
|
54
|
+
| **Multiple comparisons** | Bonferroni and FDR corrections |
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
### From PyPI (recommended)
|
|
59
|
+
```bash
|
|
60
|
+
pip install crosstabs
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### From source
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/barangaroo/crosstabs-lite.git
|
|
66
|
+
cd crosstabs-lite/mcp-server-python
|
|
67
|
+
pip install -e .
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Quick Start
|
|
71
|
+
|
|
72
|
+
### Run the MCP Server
|
|
73
|
+
```bash
|
|
74
|
+
crosstabs
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or directly:
|
|
78
|
+
```bash
|
|
79
|
+
python -m crosstabs_mcp.server
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Configure Claude Code
|
|
83
|
+
|
|
84
|
+
Add to your `~/.claude/claude_desktop_config.json`:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"mcpServers": {
|
|
89
|
+
"crosstabs": {
|
|
90
|
+
"command": "crosstabs"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Or with Python path:
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"mcpServers": {
|
|
100
|
+
"crosstabs": {
|
|
101
|
+
"command": "python",
|
|
102
|
+
"args": ["-m", "crosstabs_mcp.server"]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Usage Examples
|
|
109
|
+
|
|
110
|
+
Once configured, Claude can perform statistical analysis:
|
|
111
|
+
|
|
112
|
+
### Chi-square Test
|
|
113
|
+
```
|
|
114
|
+
User: Test if there's an association between treatment and outcome:
|
|
115
|
+
Treatment A: 50 success, 30 failure
|
|
116
|
+
Treatment B: 20 success, 40 failure
|
|
117
|
+
|
|
118
|
+
Claude: [Uses chi_square_test with matrix [[50,30],[20,40]]]
|
|
119
|
+
χ² = 11.67, p = 0.0006
|
|
120
|
+
Cramér's V = 0.29 (small-medium effect)
|
|
121
|
+
There is a significant association between treatment and outcome.
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Odds Ratio
|
|
125
|
+
```
|
|
126
|
+
User: Calculate the odds ratio for this case-control study:
|
|
127
|
+
Cases: 30 exposed, 70 unexposed
|
|
128
|
+
Controls: 15 exposed, 85 unexposed
|
|
129
|
+
|
|
130
|
+
Claude: [Uses odds_ratio with matrix [[30,70],[15,85]]]
|
|
131
|
+
OR = 2.43 (95% CI: 1.21-4.87)
|
|
132
|
+
Exposure is associated with 143% higher odds of the outcome.
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Fisher's Exact Test
|
|
136
|
+
```
|
|
137
|
+
User: I have a small sample: [[3,1],[1,5]]. Is it significant?
|
|
138
|
+
|
|
139
|
+
Claude: [Uses fishers_exact with the matrix]
|
|
140
|
+
p = 0.103 (two-tailed)
|
|
141
|
+
Not statistically significant at α=0.05.
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Available Tools
|
|
145
|
+
|
|
146
|
+
| Tool Name | Description |
|
|
147
|
+
|-----------|-------------|
|
|
148
|
+
| `chi_square_test` | Chi-square test of independence |
|
|
149
|
+
| `g_test` | G-test (likelihood ratio) |
|
|
150
|
+
| `fishers_exact` | Fisher's exact test (2×2) |
|
|
151
|
+
| `mcnemar_test` | McNemar's test for paired data |
|
|
152
|
+
| `odds_ratio` | Odds ratio with CI |
|
|
153
|
+
| `relative_risk` | Relative risk with CI |
|
|
154
|
+
| `risk_difference` | Risk difference with CI |
|
|
155
|
+
| `cramers_v` | Cramér's V effect size |
|
|
156
|
+
| `cramers_v_corrected` | Bias-corrected Cramér's V |
|
|
157
|
+
| `phi_coefficient` | Phi for 2×2 tables |
|
|
158
|
+
| `cohens_kappa` | Cohen's kappa |
|
|
159
|
+
| `weighted_kappa` | Weighted kappa |
|
|
160
|
+
| `spearmans_rho` | Spearman's rank correlation |
|
|
161
|
+
| `kendalls_tau` | Kendall's tau-b |
|
|
162
|
+
| `goodman_kruskal_gamma` | Gamma coefficient |
|
|
163
|
+
| `somers_d` | Somers' D |
|
|
164
|
+
| `tau_c` | Stuart's tau-c |
|
|
165
|
+
| `cmh_test` | Cochran-Mantel-Haenszel |
|
|
166
|
+
| `breslow_day` | Breslow-Day test |
|
|
167
|
+
| `linear_trend_test` | Linear-by-linear association |
|
|
168
|
+
| `correspondence_analysis` | Correspondence analysis |
|
|
169
|
+
| `monte_carlo_chi_square` | Monte Carlo exact test |
|
|
170
|
+
| `power_analysis` | Power/sample size |
|
|
171
|
+
| `bonferroni_correction` | Bonferroni p-value adjustment |
|
|
172
|
+
| `fdr_correction` | Benjamini-Hochberg FDR |
|
|
173
|
+
| `standardized_residuals` | Cell residuals |
|
|
174
|
+
| `post_hoc_analysis` | Post-hoc chi-square decomposition |
|
|
175
|
+
| `proportion_ci` | Confidence interval for proportion |
|
|
176
|
+
| `check_assumptions` | Validate chi-square assumptions |
|
|
177
|
+
| `mosaic_plot_data` | Data for mosaic visualization |
|
|
178
|
+
| `stacked_bar_data` | Data for stacked bar chart |
|
|
179
|
+
| `attributable_risk` | Attributable risk measures |
|
|
180
|
+
| `chi_square_yates` | Yates' continuity correction |
|
|
181
|
+
| `detect_outliers` | Outlier detection |
|
|
182
|
+
| `crosstab_from_data` | Build table from raw data |
|
|
183
|
+
| `crosstab_from_csv` | Build table from CSV |
|
|
184
|
+
|
|
185
|
+
## Development
|
|
186
|
+
|
|
187
|
+
### Run Tests
|
|
188
|
+
```bash
|
|
189
|
+
pip install -e ".[dev]"
|
|
190
|
+
pytest tests/ -v
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Project Structure
|
|
194
|
+
```
|
|
195
|
+
mcp-server-python/
|
|
196
|
+
├── crosstabs_mcp/
|
|
197
|
+
│ ├── __init__.py
|
|
198
|
+
│ ├── server.py # Main MCP server
|
|
199
|
+
│ └── advanced_stats.py # Additional functions
|
|
200
|
+
├── tests/
|
|
201
|
+
│ └── test_statistics.py # Test suite (52 tests)
|
|
202
|
+
├── pyproject.toml
|
|
203
|
+
├── requirements.txt
|
|
204
|
+
└── README.md
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Requirements
|
|
208
|
+
|
|
209
|
+
- Python 3.10+
|
|
210
|
+
- mcp >= 1.0.0
|
|
211
|
+
- fastmcp >= 0.1.0
|
|
212
|
+
- numpy >= 1.24.0
|
|
213
|
+
- scipy >= 1.10.0
|
|
214
|
+
- pandas >= 2.0.0
|
|
215
|
+
- statsmodels >= 0.14.0
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
MIT License - see [LICENSE](../LICENSE) for details.
|
|
220
|
+
|
|
221
|
+
## Contributing
|
|
222
|
+
|
|
223
|
+
Contributions welcome! Please read [CONTRIBUTING.md](../CONTRIBUTING.md) first.
|
|
224
|
+
|
|
225
|
+
## Links
|
|
226
|
+
|
|
227
|
+
- [Main Repository](https://github.com/barangaroo/crosstabs-lite)
|
|
228
|
+
- [Web Application](https://crosstabs-lite.vercel.app)
|
|
229
|
+
- [MCP Documentation](https://modelcontextprotocol.io)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Crosstabs MCP Server - Statistical Analysis via Model Context Protocol
|
|
3
|
+
|
|
4
|
+
A comprehensive MCP server providing 40+ statistical tools for contingency
|
|
5
|
+
table analysis, including chi-square tests, Fisher's exact test, effect sizes,
|
|
6
|
+
ordinal measures, and more.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__version__ = "1.0.0"
|
|
10
|
+
|
|
11
|
+
from .server import (
|
|
12
|
+
StatisticalEngine,
|
|
13
|
+
OrdinalTests,
|
|
14
|
+
TrendTests,
|
|
15
|
+
PowerAnalysis,
|
|
16
|
+
MultipleComparison,
|
|
17
|
+
VisualizationData,
|
|
18
|
+
AdditionalStats,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"StatisticalEngine",
|
|
23
|
+
"OrdinalTests",
|
|
24
|
+
"TrendTests",
|
|
25
|
+
"PowerAnalysis",
|
|
26
|
+
"MultipleComparison",
|
|
27
|
+
"VisualizationData",
|
|
28
|
+
"AdditionalStats",
|
|
29
|
+
]
|