correlation_matrix
Computes pairwise correlations and p-values for numeric variables from data files or inline data, with Pearson, Spearman, Kendall methods and p-value adjustment for significance testing.
Instructions
correlation_matrix —— 数据探查组 · 相关矩阵(工具 4,核心实现)。
docstring = agent 使用说明书,与 statlab_mcp/docs/design/02_data_exploration_batch2.md 同步维护。
参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json),仅接受本地路径 method (str, "pearson"): pearson / spearman / kendall / kendalltau(逐对取 scipy, 返回对象取 .statistic/.pvalue;pandas corr 无 p 值故不用;kendall 为 kendalltau 的官方别名 v1.1.0 起,两者结果完全相同) p_adjust (str, "fdr_bh"): none / bonferroni / fdr_bh;默认 BH-FDR 并标注; 校正单元 = 实际可计算的上三角对数(常量列对 r/p=null 不参与校正) (statsmodels.multipletests)
返回: 成功 {"status":"ok","result":{...},"summary":"..."};失败 {"status":"error",...} result: {method, n_pairs, p_adjust_method, excluded_columns, correlation, p_value, n_pairwise}(嵌套全矩阵;对角 r=1.0、p=null; 常量列对 r/p=null;n_pairwise 为成对完整样本量)
口径(红队裁决 11):每对成对完整样本;常量列 r/p=null 不参与校正; 数值列 >20 拒绝;排除非数值/全缺失列后 <2 列拒绝;p<0.001 只出现在 summary 文案。
示例: correlation_matrix("samples/clean.csv") correlation_matrix("samples/clean.csv", method="spearman", p_adjust="none") inline 数据: 本工具支持可选 inline_data 参数(v1.2.0 起):与 file_path 二选一, 支持 records 数组或 {"header": [...], "rows": [[...], ...]} 对象两种形态; 规模上限/类型域/data_source 来源标注见 statlab_mcp/docs/SPEC.md 第 12 节。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | No | pearson | |
| p_adjust | No | fdr_bh | |
| file_path | No | ||
| inline_data | No |