OpenClaw R Stats
When to Use
User asks for any statistical analysis, hypothesis testing, group comparison,
prediction, association, survival analysis, meta-analysis, causal inference,
power/sample size, or mentions R statistical packages.
What This Skill Does NOT Do
- Claim causality from observational data (use "associated with")
- Run large exploratory fishing without clear user intent
- Silently ignore assumption violations
- Report only p-values (always include effect sizes and CIs)
Pre-Flight (Mandatory)
- Confirm dataset exists and is readable
- Run schema inspection:
bash {baseDir}/scripts/run-rstats.sh schema --data <path>
- Report: rows, columns, types, missing values
- If missing > 5%, warn. If n < 30, warn small sample.
Environment Setup
First time or errors: bash {baseDir}/scripts/run-rstats.sh doctor
Install by profile (only when needed):
| Profile |
Script |
Methods |
| Core |
install-core.R |
t-test, regression, ANOVA, chi-sq |
| Survival |
install-survival.R |
KM, Cox, competing risks, RMST |
| Missing |
install-missing.R |
MICE, MCAR test |
| Mixed |
install-mixed.R |
LMM, GLMM, GEE, ICC |
| Bayes |
install-bayes.R |
brms, Bayes factors |
| Causal |
install-causal.R |
PSM, IPTW, IV, DiD, RDD, TMLE |
| Meta |
install-meta.R |
meta-analysis, NMA |
| SEM |
install-sem.R |
SEM, CFA, lavaan |
| Diagnostic |
install-diagnostic.R |
ROC, kappa, alpha |
| Advanced |
install-advanced.R |
GAM, quantile, zero-inflated |
| Power |
install-power.R |
power/sample size |
Workflow
- Determine analysis type (see references/METHOD_TABLE.md)
- Inspect dataset schema
- Build JSON spec:
{
"dataset_path": "<path>",
"analysis_type": "<type>",
"outcome": "<column>",
"predictors": ["<col1>"],
"hypothesis": "<plain language>",
"alpha": 0.05,
"seed": 42,
"output_dir": "<path>"
}
- Save as .json, run:
bash {baseDir}/scripts/run-rstats.sh analyze --spec <path>
- Read summary.json + report.md
- Present: Summary → Statistics → Interpretation → Plots → Assumptions → Caveats
Analysis Selection
For the complete 82-method table with user intent mapping,
see references/METHOD_TABLE.md.
Quick lookup — most common:
| Intent |
analysis_type |
| Compare 2 groups |
ttest or wilcoxon |
| Compare 3+ groups |
anova or kruskal |
| Categorical association |
chisq or fisher |
| Predict continuous |
linear_regression |
| Predict binary |
logistic_regression |
| Survival curves |
kaplan_meier |
| Survival regression |
cox_regression |
| Meta-analysis |
meta_analysis |
| Causal effect |
propensity_match or did |
| Power/sample size |
power_analysis |
Automatic Method Switching
- Non-normal + n < 30 →
wilcoxon over ttest
- Unequal variance → Welch t-test (
equal_var: false)
- Expected cells < 5 →
fisher over chisq
- Overdispersion in Poisson → suggest negative binomial
- Heteroscedastic residuals → robust SE warning
Reporting Rules (Non-Negotiable)
Every analysis MUST include:
- Sample size (n) and missing data handling
- Method name and rationale
- Point estimates with confidence intervals
- Effect sizes (Cohen's d, η², R², OR, HR, etc.)
- Assumption check results
- Limitations
Language: "associated with" / "evidence suggests" — NEVER "proves" / "causes"
Spec Field Reference
See references/SPEC_REFERENCE.md for required/optional fields per analysis_type.
1---2name: r-stats3description: 82 statistical analysis methods in R — regression, survival, Bayesian, meta-analysis, causal inference, SEM, IRT, clinical trial design, and more. JSON spec driven, reproducible, with mandatory effect sizes and assumption checks. Use when: user asks for statistical analysis, hypothesis testing, regression, ANOVA, t-test, chi-square, correlation, survival analysis, Cox regression, meta-analysis, propensity score, causal inference, SEM, IRT, power analysis, sample size calculation, time series forecasting, mixed models, Bayesian analysis, ROC/AUC, agreement/reliability, zero-inflated models, penalized regression, LASSO, group sequential design, or mentions R packages like ggplot2, brms, survival, metafor, lavaan, glmnet, mice, lme4, gee, dagitty, tmle. Multilingual triggers — EN: statistics, regression, significance, predict; ZH: 统计分析, 回归, 检验, 预测, 显著性, 生存分析, 元分析, 贝叶斯; JA: 統計分析, 回帰, 検定, 予測; KO: 통계분석, 회귀, 검정; ES: análisis estadístico, regresión; FR: analyse statistique, régression; DE: st…4---56# OpenClaw R Stats78## When to Use910User asks for any statistical analysis, hypothesis testing, group comparison,11prediction, association, survival analysis, meta-analysis, causal inference,12power/sample size, or mentions R statistical packages.1314## What This Skill Does NOT Do1516- Claim causality from observational data (use "associated with")17- Run large exploratory fishing without clear user intent18- Silently ignore assumption violations19- Report only p-values (always include effect sizes and CIs)2021## Pre-Flight (Mandatory)22231. Confirm dataset exists and is readable242. Run schema inspection: `bash {baseDir}/scripts/run-rstats.sh schema --data <path>`253. Report: rows, columns, types, missing values264. If missing > 5%, warn. If n < 30, warn small sample.2728## Environment Setup2930First time or errors: `bash {baseDir}/scripts/run-rstats.sh doctor`3132Install by profile (only when needed):3334| Profile | Script | Methods |35|---------|--------|---------|36| Core | `install-core.R` | t-test, regression, ANOVA, chi-sq |37| Survival | `install-survival.R` | KM, Cox, competing risks, RMST |38| Missing | `install-missing.R` | MICE, MCAR test |39| Mixed | `install-mixed.R` | LMM, GLMM, GEE, ICC |40| Bayes | `install-bayes.R` | brms, Bayes factors |41| Causal | `install-causal.R` | PSM, IPTW, IV, DiD, RDD, TMLE |42| Meta | `install-meta.R` | meta-analysis, NMA |43| SEM | `install-sem.R` | SEM, CFA, lavaan |44| Diagnostic | `install-diagnostic.R` | ROC, kappa, alpha |45| Advanced | `install-advanced.R` | GAM, quantile, zero-inflated |46| Power | `install-power.R` | power/sample size |4748## Workflow49501. Determine analysis type (see references/METHOD_TABLE.md)512. Inspect dataset schema523. Build JSON spec:53```json54{55 "dataset_path": "<path>",56 "analysis_type": "<type>",57 "outcome": "<column>",58 "predictors": ["<col1>"],59 "hypothesis": "<plain language>",60 "alpha": 0.05,61 "seed": 42,62 "output_dir": "<path>"63}64```654. Save as .json, run: `bash {baseDir}/scripts/run-rstats.sh analyze --spec <path>`665. Read summary.json + report.md676. Present: Summary → Statistics → Interpretation → Plots → Assumptions → Caveats6869## Analysis Selection7071For the complete 82-method table with user intent mapping,72see **references/METHOD_TABLE.md**.7374Quick lookup — most common:7576| Intent | analysis_type |77|--------|--------------|78| Compare 2 groups | `ttest` or `wilcoxon` |79| Compare 3+ groups | `anova` or `kruskal` |80| Categorical association | `chisq` or `fisher` |81| Predict continuous | `linear_regression` |82| Predict binary | `logistic_regression` |83| Survival curves | `kaplan_meier` |84| Survival regression | `cox_regression` |85| Meta-analysis | `meta_analysis` |86| Causal effect | `propensity_match` or `did` |87| Power/sample size | `power_analysis` |8889## Automatic Method Switching9091- Non-normal + n < 30 → `wilcoxon` over `ttest`92- Unequal variance → Welch t-test (`equal_var: false`)93- Expected cells < 5 → `fisher` over `chisq`94- Overdispersion in Poisson → suggest negative binomial95- Heteroscedastic residuals → robust SE warning9697## Reporting Rules (Non-Negotiable)9899Every analysis MUST include:100- Sample size (n) and missing data handling101- Method name and rationale102- Point estimates with confidence intervals103- Effect sizes (Cohen's d, η², R², OR, HR, etc.)104- Assumption check results105- Limitations106107Language: "associated with" / "evidence suggests" — NEVER "proves" / "causes"108109## Spec Field Reference110111See **references/SPEC_REFERENCE.md** for required/optional fields per analysis_type.