Statistical Analysis 标志

Statistical Analysis

社区
jaechang-hits
statistical-analysis

Guided statistical analysis: test choice, assumption checks, effect sizes, power, APA reporting. Pick tests, verify assumptions, or format results for publication. Covers frequentist (t-test, ANOVA, chi-square, regression, correlation, survival, count, reliability) and Bayesian. Use statsmodels or pymc-bayesian-modeling to fit.

概览

发布者jaechang-hits
代码仓库SciAgent-Skills
技能名称statistical-analysis
星标数
381
复刻数
45
附带文件
3
许可协议CC-BY-4.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 3 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 jaechang-hits 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Statistical Analysis AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/jaechang-hits/SciAgent-Skills/tree/main/skills/biostatistics/statistical-analysis
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jaechang-hits/SciAgent-Skills.git /tmp/SciAgent-Skills
mkdir -p .claude/skills
cp -r /tmp/SciAgent-Skills/skills/biostatistics/statistical-analysis .claude/skills/statistical-analysis
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Statistical Analysis,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Statistical Analysis。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Statistical Analysis 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Statistical Analysis

Overview

Statistical analysis is the systematic process of selecting appropriate tests, verifying assumptions, quantifying effect magnitudes, and reporting results. This knowhow guides test selection, assumption diagnostics, and APA-style reporting for frequentist and Bayesian analyses in academic research.

Key Concepts

Frequentist vs Bayesian Framework

AspectFrequentistBayesian
Core outputp-value, confidence intervalPosterior distribution, credible interval
Interpretation"How likely is this data if H0 is true?""How likely is H1 given the data?"
Null supportCannot support H0 (only fail to reject)Can quantify evidence for H0 via Bayes Factor
Prior infoNot usedIncorporated via prior distributions
Sample sizeRequires adequate powerWorks with any sample size
Best forStandard analyses, large samplesSmall samples, prior info, complex models

Statistical vs Practical Significance

A statistically significant result (p < .05) may be trivially small in practice. Always report:

  • Effect size: Magnitude of the effect (Cohen's d, eta-squared, r, R-squared)
  • Confidence interval: Precision of the estimate
  • Context: Clinical/practical relevance in the domain

Common Effect Sizes

TestEffect SizeSmallMediumLarge
t-testCohen's d0.200.500.80
t-test (small n)Hedges' g0.200.500.80
ANOVAeta-squared partial0.010.060.14
ANOVAomega-squared0.010.060.14
Correlationr0.100.300.50
RegressionR-squared0.020.130.26
Regressionf-squared0.020.150.35
Chi-squareCramer's V0.070.210.35
Chi-square 2x2phi coefficient0.100.300.50

Cohen's benchmarks are guidelines, not rigid thresholds -- domain context always matters.

Assumptions Overview

Most parametric tests require:

  1. Independence: Observations are independent of each other
  2. Normality: Data (or residuals) are approximately normally distributed
  3. Homogeneity of variance: Groups have similar variances (for group comparisons)
  4. Linearity: Relationship between variables is linear (for regression)

When assumptions are violated:

  • Normality violated, n > 30: Proceed -- parametric tests are robust with large samples
  • Normality violated, n < 30: Use non-parametric alternative
  • Variance heterogeneity: Use Welch's correction (t-test) or Welch's ANOVA
  • Linearity violated: Add polynomial terms, transform variables, or use GAMs

Test-Specific Assumption Workflows

T-test assumptions: (1) Check normality per group with Shapiro-Wilk + Q-Q plots. (2) Check homogeneity with Levene's test. (3) If normality violated: Mann-Whitney U (independent) or Wilcoxon signed-rank (paired). If variance heterogeneity: use Welch's t-test.

ANOVA assumptions: (1) Normality per group. (2) Homogeneity via Levene's test. (3) For repeated measures: check sphericity (Mauchly's test); if violated, apply Greenhouse-Geisser (epsilon < 0.75) or Huynh-Feldt (epsilon > 0.75) correction. (4) If normality violated: Kruskal-Wallis (independent) or Friedman (repeated).

Linear regression assumptions: (1) Linearity via residuals-vs-fitted plot. (2) Independence via Durbin-Watson test (1.5-2.5 acceptable). (3) Homoscedasticity via Breusch-Pagan test + scale-location plot. (4) Normality of residuals via Q-Q plot + Shapiro-Wilk. (5) Multicollinearity via VIF (>10 = severe, >5 = moderate).

Logistic regression assumptions: (1) Independence. (2) Linearity of log-odds with continuous predictors (Box-Tidwell test). (3) No perfect multicollinearity (VIF). (4) Adequate sample size (10-20 events per predictor minimum).

Specialized Test Categories

Beyond the main decision flowchart, several specialized test families address specific data types:

Survival / time-to-event analysis:

  • Log-rank test: Compares survival curves between groups (non-parametric)
  • Cox proportional hazards: Models time-to-event with covariates; assumes proportional hazards
  • Parametric survival models: Weibull, exponential, log-normal for known distributional forms
  • Use when outcome is time until an event (death, relapse, failure) with possible censoring

Count outcome models:

  • Poisson regression: For count data where mean approximately equals variance
  • Negative binomial regression: For overdispersed counts (variance > mean)
  • Zero-inflated models: For excess zeros beyond what Poisson/NB predicts
  • Use when outcome is a count (number of events, incidents, occurrences)

Agreement and reliability:

  • Cohen's kappa: Inter-rater agreement for categorical ratings (2 raters)
  • Fleiss' kappa / Krippendorff's alpha: Agreement for >2 raters
  • Intraclass correlation coefficient (ICC): Continuous ratings reliability
  • Cronbach's alpha: Internal consistency of multi-item scales
  • Bland-Altman analysis: Agreement between two measurement methods (continuous)
  • Use when assessing measurement reliability or inter-rater consistency

Categorical data extensions:

  • McNemar's test: Paired binary outcomes (2x2)
  • Cochran's Q test: Paired binary outcomes (3+ conditions)
  • Cochran-Armitage trend test: Ordered categories in contingency tables

Decision Framework

Test Selection Flowchart

What is your research question?
|
+-- Comparing GROUPS on a continuous outcome?
|   |
|   +-- How many groups?
|   |   +-- 2 groups
|   |   |   +-- Independent -> Independent t-test (or Mann-Whitney U)
|   |   |   +-- Paired/repeated -> Paired t-test (or Wilcoxon signed-rank)
|   |   +-- 3+ groups
|   |      +-- Independent -> One-way ANOVA (or Kruskal-Wallis)
|   |      +-- Repeated -> Repeated-measures ANOVA (or Friedman)
|   |
|   +-- Multiple factors? -> Factorial ANOVA / Mixed ANOVA
|   +-- With covariates? -> ANCOVA
|
+-- Testing a RELATIONSHIP between variables?
|   |
|   +-- Both continuous?
|   |   +-- Normal -> Pearson correlation
|   |   +-- Non-normal or ordinal -> Spearman correlation
|   |
|   +-- Predicting continuous outcome?
|   |   +-- 1 predictor -> Simple linear regression
|   |   +-- Multiple predictors -> Multiple linear regression
|   |
|   +-- Predicting categorical outcome?
|   |   +-- Binary -> Logistic regression
|   |   +-- Ordinal -> Ordinal logistic regression
|   |
|   +-- Predicting count outcome?
|   |   +-- Equidispersed -> Poisson regression
|   |   +-- Overdispersed -> Negative binomial regression
|   |   +-- Excess zeros -> Zero-inflated Poisson/NB
|   |
|   +-- Time-to-event outcome?
|       +-- Compare survival curves -> Log-rank test
|       +-- With covariates -> Cox proportional hazards
|
+-- Testing ASSOCIATION between categorical variables?
|   +-- Expected cell count >= 5 -> Chi-square test
|   +-- Expected cell count < 5 -> Fisher's exact test
|   +-- Ordered categories -> Cochran-Armitage trend test
|   +-- Paired categories -> McNemar's test
|
+-- Assessing AGREEMENT / RELIABILITY?
    +-- Categorical, 2 raters -> Cohen's kappa
    +-- Categorical, >2 raters -> Fleiss' kappa
    +-- Continuous ratings -> ICC
    +-- Two measurement methods -> Bland-Altman analysis
    +-- Internal consistency -> Cronbach's alpha

Quick Reference Table

Research QuestionData TypeNormal?TestNon-parametric Alternative
2 independent groupsContinuousYesIndependent t-testMann-Whitney U
2 paired groupsContinuousYesPaired t-testWilcoxon signed-rank
3+ independent groupsContinuousYesOne-way ANOVAKruskal-Wallis
3+ repeated groupsContinuousYesRepeated-measures ANOVAFriedman test
2 variablesContinuousYesPearson rSpearman rho
Predict continuousMixed--Linear regression--
Predict binaryMixed--Logistic regression--
Predict countsCount--Poisson / Negative binomial--
Time-to-eventSurvival--Cox PH / Log-rank--
2 categoricalCategorical--Chi-square / Fisher's exact--
Rater agreementCategorical--Cohen's kappa / Fleiss' kappa--
Method agreementContinuous--Bland-Altman / ICC--

Best Practices

  1. Pre-register analyses when possible to distinguish confirmatory from exploratory findings. Specify primary outcome, tests, and correction methods before data collection
  2. Always check assumptions before interpreting results. Run normality tests (Shapiro-Wilk), homogeneity tests (Levene's), and residual diagnostics. Document results even when assumptions are met
  3. Report effect sizes with confidence intervals for every test. p-values alone are insufficient -- effect sizes convey practical importance
  4. Report all planned analyses including non-significant findings. Selective reporting inflates false positive rates
  5. Use appropriate multiple comparison corrections. Bonferroni (conservative), Holm (step-down, less conservative), or FDR/Benjamini-Hochberg (for many tests). Choose based on the number of comparisons and acceptable error rate
  6. Visualize data before and after analysis. Box plots for group comparisons, scatter plots for correlations, residual plots for regression diagnostics
  7. Conduct sensitivity analyses to assess robustness: re-run with outliers removed, different transformations, or alternative tests
  8. Anti-pattern -- p-hacking: Testing multiple outcomes, subgroups, or model specifications until p < .05 inflates false positives. Pre-register to avoid
  9. Anti-pattern -- HARKing (Hypothesizing After Results are Known): Presenting exploratory findings as confirmatory undermines scientific integrity
  10. Anti-pattern -- misinterpreting non-significance: Failure to reject H0 does not mean H0 is true. Use Bayesian methods or equivalence testing to support null

Common Pitfalls

  1. Misinterpreting p-values as probability of the hypothesis being true. p-values measure P(data | H0), not P(H0 | data). How to avoid: Use precise language: "If the null hypothesis were true, the probability of observing data this extreme is p = ..."

  2. Confusing statistical significance with practical importance. A large sample can make trivially small effects significant. How to avoid: Always report and interpret effect sizes alongside p-values

  3. Running post-hoc power analysis after a non-significant result. Post-hoc power is a mathematical function of the p-value and adds no new information. How to avoid: Use sensitivity analysis instead -- determine what effect size the study could detect at 80% power

  4. Ignoring assumption violations and proceeding with parametric tests. How to avoid: Run assumption checks systematically. Use Welch's corrections, non-parametric alternatives, or transformations when violated

  5. Multiple comparisons without correction. Running 20 tests at alpha = .05 gives ~64% chance of at least one false positive. How to avoid: Apply Bonferroni, Holm, or FDR correction. Report both corrected and uncorrected p-values

  6. Treating ordinal data as continuous. Likert scales are ordinal -- means and standard deviations assume equal intervals. How to avoid: Use non-parametric tests (Mann-Whitney, Kruskal-Wallis) or ordinal regression

  7. Ignoring missing data patterns. Listwise deletion assumes MCAR, which is rarely true. How to avoid: Assess missingness mechanism (MCAR, MAR, MNAR). Use multiple imputation for MAR data

  8. Confusing correlation with causation. Observational studies cannot establish causal relationships regardless of effect size. How to avoid: Use causal language only for experimental designs with random assignment

  9. Not reporting non-significant results. Publication bias and file-drawer effect distort the literature. How to avoid: Report all pre-registered analyses. Consider registered reports

  10. Using one-tailed tests to "improve" significance. One-tailed tests should be pre-specified based on strong directional hypotheses. How to avoid: Default to two-tailed. Only use one-tailed when justified a priori

Workflow

Standard Analysis Pipeline

  1. Define research question and hypotheses

    • State H0 and H1 explicitly
    • Specify primary outcome and covariates
  2. Select statistical test (use Decision Framework above)

    • Match test to data type, design, and assumptions
    • Plan multiple comparison corrections if needed
  3. Conduct a priori power analysis

    • Specify target effect size (from literature or clinical relevance)
    • Set alpha = .05, power = .80 (minimum), determine required n
    • Libraries: statsmodels.stats.power, pingouin
  4. Inspect and clean data

    • Check for missing data patterns (MCAR/MAR/MNAR)
    • Identify outliers (IQR method: Q1 - 1.5IQR / Q3 + 1.5IQR, or z-scores > 3)
    • Verify variable types and coding
    • The original assumption_checks.py script provides automated normality, homogeneity, and outlier detection with visualization
  5. Check assumptions (see Test-Specific Assumption Workflows above)

    • Normality: Shapiro-Wilk test + Q-Q plots (visual primary for n > 50)
    • Homogeneity: Levene's test + box plots
    • Linearity: Residual plots (for regression)
    • Sphericity: Mauchly's test (for repeated measures)
    • Document results and remedial actions
  6. Run primary analysis

    • Execute planned test with appropriate library (scipy.stats, pingouin, statsmodels)
    • Calculate effect size and confidence interval
    • For Bayesian analyses: specify priors, run MCMC, check convergence (see references/bayesian_statistics.md)
  7. Conduct post-hoc and secondary analyses

    • Post-hoc pairwise comparisons (Tukey HSD, Bonferroni)
    • Sensitivity analyses (remove outliers, alternative methods)
    • Exploratory analyses (clearly labeled)
  8. Report results in APA format

    • Descriptive statistics (M, SD, n per group)
    • Test statistic, degrees of freedom, exact p-value
    • Effect size with confidence interval
    • See references/reporting_standards.md for templates

Bundled Resources

  • references/effect_sizes_and_power.md -- Detailed guide to calculating, interpreting, and reporting effect sizes (Cohen's d, Hedges' g, Glass's delta, eta-squared, omega-squared, partial eta-squared, phi coefficient, standardized beta, f-squared, Cramer's V, odds ratio); a priori, sensitivity, and correlation power analysis with code examples. Condensed from 582-line original.

  • references/bayesian_statistics.md -- Comprehensive Bayesian analysis guide: Bayes' theorem, prior specification, ROPE (Region of Practical Equivalence), prior sensitivity analysis, Bayesian t-test/ANOVA/correlation/regression, hierarchical models, model comparison (WAIC/LOO), convergence diagnostics. Condensed from 662-line original.

  • references/reporting_standards.md -- APA-style reporting templates for t-tests, ANOVA, regression, correlation, chi-square, non-parametric, and Bayesian analyses; pre-registration guidance; methods section templates (participants, design, measures); null results reporting; reporting checklist. Condensed from 470-line original.

Fully-Consolidated Files (no separate reference file)

  • test_selection_guide.md (130 lines original) -- Fully consolidated into Decision Framework (flowchart + Quick Reference Table) and Specialized Test Categories subsection in Key Concepts. Combined coverage: flowchart (~35 lines) + Quick Reference Table (~15 lines) + Specialized Test Categories (~35 lines) = ~85 lines covering all original capabilities. Original content on sample size considerations, multiple comparisons, and missing data was consolidated into Best Practices and Common Pitfalls. Omitted: study design considerations (RCTs, observational, clustered data) -- general guidance covered by statsmodels-statistical-modeling skill.

  • assumptions_and_diagnostics.md (370 lines original) -- Fully consolidated into Key Concepts (Assumptions Overview + Test-Specific Assumption Workflows) and Workflow Steps 4-5. Combined coverage: Assumptions Overview (~12 lines) + Test-Specific Assumption Workflows (~20 lines) + Workflow Steps 4-5 (~16 lines) = ~48 lines. The original contained detailed code blocks for each assumption check; since this is Knowhow (not Skill), code is referenced rather than reproduced. Key diagnostic thresholds preserved (VIF > 10, Durbin-Watson 1.5-2.5, variance ratio < 2-3). Omitted: extensive Python code blocks for individual checks (normality, homogeneity, linearity, logistic regression diagnostics) -- available in scipy.stats and pingouin documentation. Sample size rules of thumb covered in Workflow Step 3.

Script Disposition

  • assumption_checks.py (540 lines) -- Contains 6 functions: check_normality(), check_normality_per_group(), check_homogeneity_of_variance(), check_linearity(), detect_outliers(), comprehensive_assumption_check(). As Knowhow entry, script functions are referenced in Workflow Step 4 rather than reproduced inline. Key capabilities (Shapiro-Wilk, Levene's, IQR/z-score outlier detection, Q-Q plots) are described in Assumptions Overview and Test-Specific Assumption Workflows. Users needing automated checking should use scipy.stats and pingouin directly following the patterns described.

Intentional Omissions

  • Time series methods (ARIMA, ACF/PACF) -- specialized topic beyond core statistical testing scope
  • Mixed-effects models / GEE -- covered by statsmodels-statistical-modeling skill
  • Bootstrap and permutation tests -- mentioned in passing; detailed implementation deferred to computational statistics resources

Further Reading

  • Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.)
  • Field, A. (2013). Discovering Statistics Using IBM SPSS Statistics (4th ed.)
  • Gelman, A., & Hill, J. (2006). Data Analysis Using Regression and Multilevel/Hierarchical Models
  • Kruschke, J. K. (2014). Doing Bayesian Data Analysis (2nd ed.)
  • APA Publication Manual: https://apastyle.apa.org/
  • Cross Validated (stats Q&A): https://stats.stackexchange.com/

Related Skills

  • statsmodels-statistical-modeling -- Implementing OLS, GLM, Logit, time-series models programmatically
  • pymc-bayesian-modeling -- Full Bayesian modeling with MCMC sampling
  • scikit-learn-machine-learning -- Predictive modeling, cross-validation, classification
  • matplotlib-scientific-plotting -- Creating publication-quality statistical figures
  • hypothesis-generation -- Structured hypothesis formulation before statistical testing

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Statistical Analysis AI 技能有什么作用?

Guided statistical analysis: test choice, assumption checks, effect sizes, power, APA reporting. Pick tests, verify assumptions, or format results for publication. Covers frequentist (t-test, ANOVA, chi-square, regression, correlation, survival, count, reliability) and Bayesian. Use statsmodels or pymc-bayesian-modeling to fit.

为什么在 TypingMind 中使用 Statistical Analysis?

因为您只需安装一次,就能搭配任何模型使用。Statistical Analysis 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Statistical Analysis?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/jaechang-hits/SciAgent-Skills/tree/main/skills/biostatistics/statistical-analysis。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Statistical Analysis?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Statistical Analysis 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Statistical Analysis 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Statistical Analysis AI 技能免费吗?

是的。jaechang-hits 已在 GitHub 上根据 CC-BY-4.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇