multivariate-analysis
Skill0 starsChanged 4 months agoMITView on GitHub
當用戶需要對多變量資料進行降維(PCA 主成分分析)、分群(K-means / 階層式聚類)或多依變量假設檢驗(MANOVA)分析,並要求交付 Word 格式 (.docx) 報告時觸發。用於市場區隔、客戶分群、探索資料結構、多結果變量的實驗比較等場景。 EN: Use for PCA (dimensionality reduction with biplot / scree), clustering (K-means / hierarchical with silhouette), or MANOVA on multiple dependent variables — Word report. Trigger phrases: "run PCA", "cluster these customers", "MANOVA on these outcomes", "reduce dimensions", "segment users".
In this repository9 other files it gives its agents.
- advanced-data-analyticsSkill
- data-preparationSkill
- factor-analysisSkill
- factorial-anovaSkill
- inference-decisionSkill
- literature-reviewSkill
- regression-analyticsSkill
- survival-analysisSkill
- time-series-analysisSkill
The file
Files
Skill: multivariate-analysis
多變量分析(PCA / Clustering / MANOVA)與 Word 報告匯出。
Metadata
- Description: 對多變量資料執行主成分分析降維、K-means/階層式聚類、MANOVA 多依變量假設檢驗;輸出載荷矩陣、碎石圖、雙標圖、集群輪廓圖、Box's M 檢驗、Wilks/Pillai 統計量。
- Version: 1.0.0
- Entrypoint:
orchestrator.py(CLI:--source {local,sql,hadoop}+--analysis {pca,cluster,manova}+ 對應模式參數) - Related:
- 假設檢驗:
advanced-data-analytics - 迴歸建模:
regression-analytics - 因素分析(EFA/CFA):
factor-analysis - 多因子 ANOVA:
factorial-anova - 生存分析:
survival-analysis
- 假設檢驗:
Analysis Modes
1. pca — 主成分分析
- 輸入: 多個連續數值欄位(
--vars X1 X2 ... Xn;至少 3 個) - 決策流程:
- 標準化: 預設 z-score(
--no-scale關閉) - KMO 適當性檢驗:與 EFA 一致的判定標準
- 主成分萃取:計算所有 PC,依 Kaiser 準則(eigenvalue > 1)自動決定保留數,或
--n-components指定 - 輸出:
- 特徵值表(每 PC 的解釋變異量、累積比例)
- 載荷矩陣(loading matrix)
- 雙標圖 Biplot(前 2 PC 上的觀測點 + 變量向量)
- 碎石圖(Scree Plot)
- PC 得分表(每個觀測在每個 PC 的分數,供下游使用)
- 標準化: 預設 z-score(
2. cluster — 聚類分析
- 輸入: 多個連續數值欄位(
--vars) - 方法(
--method):kmeans(預設): K-means 分群hclust: 階層式聚類(Ward.D2 連結法)
- K 值決定 (K-means)(
--k覆寫;否則自動):- Elbow method(within-cluster SS 曲線)
- Silhouette method(輪廓係數最大)
- 綜合判定,取眾數
- 輸出:
- 分群結果表(每觀測的 cluster label + PC 座標)
- 每 cluster 的中心點與樣本量
- 輪廓係數 (Silhouette coefficient)
- Cluster viz(在 PCA 空間投影,用顏色標記 cluster)
- Elbow / Silhouette 曲線圖
3. manova — 多依變量變異數分析
- 輸入: 多個連續數值 outcome(
--ys Y1 Y2 ... Yn;至少 2 個)+ 1 個以上類別因子(--factors A [B ...]) - 決策流程:
- 前置檢驗:
- Box's M 檢驗(
heplots::boxM):多變量方差齊性 - Multivariate normality(每 cell 的 Mardia 檢驗,若 semTools 可用)
- Box's M 檢驗(
- MANOVA(
manova(cbind(Y1, Y2, ...) ~ factors)):- 4 種統計量: Wilks Lambda、Pillai Trace、Hotelling-Lawley Trace、Roy's Greatest Root
- 每個效應項的多變量 F 值 + df + p 值
- 後續分析(有顯著效應時):
- 每個 outcome 的單變量 ANOVA
- 判別分析(LDA, Linear Discriminant Analysis)作為視覺化
- 前置檢驗:
- 輸出:
- 前置檢驗表
- MANOVA 多變量檢驗表
- 單變量 ANOVA 表(每個 outcome)
- LDA 投影圖(前 2 個判別函數)
Output Location
預設輸出目錄:./outcome-temp/
fetched_data.csv:資料快照Multivariate_Report.docx:Word 報告pca_biplot.png/pca_scree.png:PCA 圖cluster_viz.png/elbow_silhouette.png:Cluster 圖lda_plot.png:MANOVA LDA 投影圖
Workflow (SOP)
- fetch: schema 校驗(欄位存在、型別對)+ 零方差偵測
- execute: 依 analysis mode 分派到對應 R body
- render: 依 analysis mode 動態組裝章節
- 交付:
.docx落地在 output-dir
Constraints
- PCA/Cluster:
--vars中所有欄位需為連續數值,非常數 - MANOVA:
--ys每個必為連續數值;--factors為類別 - Listwise deletion:任一必需欄位為 NA 的列丟棄
- PCA/Cluster 預設標準化(z-score),避免尺度差異主導結果
Dependencies
- Python 3.10+:
pandas sqlalchemy python-docx openpyxl pyhive thrift thrift-sasl pure-sasl - R 4.x:
- 必要:
ggplot2 jsonlite psych cluster factoextra - MANOVA 專用:
heplots MASS - 可選:
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.

