factorial-anova
Skill0 starsChanged 4 months agoMITView on GitHub
當用戶需要對數據執行多因子變異數分析(Two-way / N-way ANOVA、含交互作用、共變量 ANCOVA),要求完整的主效應與交互效應檢驗、事後兩兩比較、簡單主效應剖析、交互效果圖,並要求最終交付 Word 格式(.docx)報告時觸發。用於實驗設計、A/B×B 測試、多因子田口設計等場景。 EN: Use for two-way / N-way ANOVA or ANCOVA with main effects, interactions, post-hoc pairwise comparisons, simple-effects breakdown, and interaction plots — Word report. Trigger phrases: "two-way ANOVA", "test the interaction", "factorial design analysis", "ANCOVA with covariate".
In this repository9 other files it gives its agents.
- advanced-data-analyticsSkill
- data-preparationSkill
- factor-analysisSkill
- inference-decisionSkill
- literature-reviewSkill
- multivariate-analysisSkill
- regression-analyticsSkill
- survival-analysisSkill
- time-series-analysisSkill
The file
Files
Skill: factorial-anova
多因子變異數分析(Factorial ANOVA / ANCOVA)與 Word 報告匯出。
Metadata
- Description: 對兩個以上因子的獨立樣本設計執行 Type II / Type III ANOVA,含交互作用檢驗、事後兩兩比較(Tukey/Sidak)、簡單主效應剖析、共變量 (ANCOVA)、效應量 (η²/ω²/偏 η²)、交互作用圖。
- Version: 1.0.0
- Entrypoint:
orchestrator.py(CLI:--source {local,sql,hadoop}+--y <col>+--factors <cols>+--covariates <cols>+--ss-type {2,3}) - Related:
- 單因子 ANOVA / t-test / 相關性:
advanced-data-analytics - 迴歸建模:
regression-analytics - EFA / CFA:
factor-analysis
- 單因子 ANOVA / t-test / 相關性:
Analysis Modes
只有 一種 主要模式(factorial),依 --factors 個數與 --covariates 決定分析形態:
| 情境 | --factors | --covariates | 分析類型 |
| Two-way ANOVA | 2 | 0 | y ~ A * B |
| N-way ANOVA | ≥3 | 0 | y ~ A * B * C ... |
| ANCOVA | ≥1 | ≥1 | y ~ cov + A * B |
| One-way (退化) | 1 | 0 | 建議改用 advanced-data-analytics 的 auto 模式 |
決策流程
- 輸入契約校驗(
data_fetcher.py)y為連續數值,factors為類別(自動 to factor),covariates為連續數值- listwise deletion,記錄丟棄筆數
- 若某因子只有 1 個 level → 錯誤攔下
- 若 cell 數量 <2 → 警告(無法估計交互)
- 前置檢驗
- 每個 cell 的樣本量(不平衡設計會影響 SS type 選擇)
- Levene's Test 方差齊性(
car::leveneTest) - 殘差 Shapiro-Wilk(正態性)
- 主分析
- Type II SS(預設,適用平衡+無交互假設;正交因子)
- Type III SS(
--ss-type 3,適用不平衡設計+有交互;預設contr.sum) car::Anova(fit, type=...)
- 效應量(
effectsize套件)- 每個效應項的 偏 η² (partial eta²) + 95% CI
- ω² (omega²) 無偏估計
- Cohen's f(給 power 分析用)
- 事後檢驗(自動觸發,可由
--no-posthoc關)- 主效應顯著 → Tukey HSD(
emmeans::pairs, adjust="tukey") - 交互作用顯著 → 簡單主效應(simple main effects):固定一個因子,比較另一個因子在該 level 上的差異,Sidak 校正
- 兩兩比較都給出 estimate + SE + t + p_adj + 顯著標記
- 主效應顯著 → Tukey HSD(
- 可視化
- 交互作用圖(Interaction Plot):每個因子組合的估計邊際均值 + CI
- 主效應圖(每個因子單獨)
- 殘差 vs Fitted、Q-Q(假設檢驗診斷)
Output Location
預設輸出目錄:./outcome-temp/
fetched_data.csv:資料快照FactorialANOVA_Report.docx:Word 報告interaction_plot.png/main_effects_plot.png/diagnostics.png
Workflow (SOP)
- fetch: schema + variance 校驗(因子至少 2 levels、y/cov 為數值)
- execute:
car::Anova(aov(...), type=II/III)+ 每個效應項 partial η² + Levene + Shapiro - posthoc: 主效應 Tukey / 交互作用 simple effects
- render: 依實際觸發項目動態組裝章節
Constraints
- 數值保留 4 位小數
- Type III 需要
contr.sum對比編碼 → skill 自動設定,執行完自動還原 - 交互作用不顯著(p ≥ 0.05)時,事後只跑主效應;顯著時只跑 simple effects(避免 double-dipping)
- 樣式集中於
templates/word_styles.json
Dependencies
- Python 3.10+:
pandas sqlalchemy python-docx openpyxl pyhive thrift thrift-sasl pure-sasl - R 4.x:
- 必要:
ggplot2 jsonlite car emmeans effectsize - 可選:
showtext sysfonts(CJK 字型)
- 必要:
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

