Skip to content

Commit b076cd4

Browse files
committed
Correct statistical-method guidance in analysis skill docs
1 parent 5d844de commit b076cd4

3 files changed

Lines changed: 32 additions & 16 deletions

File tree

skills/stat-analyze-distribution/SKILL.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,35 @@ description: Characterize the distribution of one or more numeric variables with
1818
- Data table (CSV or TSV) with at least one numeric column
1919
- Optional:
2020
- Column(s) to analyze (default: all numeric columns)
21-
- Normality test method: `shapiro` (default, n < 5000) or `ks` (Kolmogorov-Smirnov, larger samples)
21+
- Normality test method: `shapiro` (default, n 5000) or `anderson` (Anderson-Darling, recommended for larger samples)
2222
- Output directory (default: `./dist_output`)
2323

2424
## Workflow
2525

2626
1. Read the data file; identify numeric columns to analyze (or use user-specified subset).
2727
2. For each target column, compute summary statistics: mean, median, standard deviation, variance, min, max, 25th/75th percentiles, skewness, kurtosis.
28-
3. Run normality test: Shapiro-Wilk (n ≤ 5000) or Kolmogorov-Smirnov (n > 5000). Report test statistic and p-value.
29-
4. Classify each variable: `normal` (p > 0.05) or `non-normal` (p ≤ 0.05), with note on sample size.
28+
3. Run normality test:
29+
- Shapiro-Wilk when n ≤ 5000
30+
- Anderson-Darling when n > 5000
31+
Report test statistic, p-value (or significance level where applicable), and sample size.
32+
4. Classify each variable as `approximately_normal` or `non_normal` using both test output and Q-Q plot inspection (do not classify from hypothesis-test p-value alone).
3033
5. Generate plots for each variable: histogram with density overlay, Q-Q plot.
3134
6. If multiple variables, produce a summary table across all variables.
3235
7. Write summary statistics table (TSV) and plots (PDF) to output directory.
33-
8. Report which variables appear normally distributed and suggest appropriate downstream tests.
36+
8. Save an executable analysis script (`analysis_code.py` or `analysis_code.R`) and software version manifest (`session_info.txt`) used to produce results.
37+
9. Report which variables appear normally distributed and suggest appropriate downstream tests.
3438

3539
## Output Contract
3640

37-
- Summary statistics table (TSV): variable, n, mean, median, sd, variance, skewness, kurtosis, normality_test, test_statistic, p_value, is_normal
41+
- Summary statistics table (TSV): variable, n, mean, median, sd, variance, skewness, kurtosis, normality_test, test_statistic, p_value_or_significance, normality_call
3842
- Histogram + density plot per variable (PDF)
3943
- Q-Q plot per variable (PDF)
44+
- Reproducibility artifacts: `analysis_code.py` or `analysis_code.R`, plus `session_info.txt`
4045

4146
## Limits
4247

43-
- Shapiro-Wilk test is unreliable for n > 5000; automatically switches to KS test.
48+
- Shapiro-Wilk test is unreliable for very large n; use Anderson-Darling and visual diagnostics instead.
49+
- Avoid one-sample KS tests against a fitted normal distribution unless a corrected procedure is explicitly implemented.
4450
- Normality tests have low power for small samples (n < 20); visual inspection of Q-Q plot is recommended.
4551
- Does not handle categorical or date columns; these are silently skipped.
4652
- Common failure: non-numeric columns passed explicitly cause an error — pre-filter if needed.

skills/stat-compare-multiple-groups/SKILL.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ description: Compare a continuous variable across three or more groups using one
2525
## Workflow
2626

2727
1. Read data; validate that group column has three or more levels.
28-
2. Run normality test (Shapiro-Wilk) and Levene's test for each group.
28+
2. Run normality tests (Shapiro-Wilk) within each group and run one global Levene's test across groups for homogeneity of variance.
2929
3. If all groups are normal and variances are approximately equal: one-way ANOVA.
3030
- If second factor provided: two-way ANOVA with interaction term.
3131
4. If normality or homogeneity of variance is violated: Kruskal-Wallis test.
@@ -34,15 +34,17 @@ description: Compare a continuous variable across three or more groups using one
3434
- Kruskal-Wallis: Dunn test with Benjamini-Hochberg correction.
3535
6. Compute effect size: eta-squared (η²) for ANOVA, epsilon-squared for Kruskal-Wallis.
3636
7. Generate a box plot with all groups and pairwise significance brackets.
37-
8. Write results and plot (PDF) to output directory.
38-
9. Report: omnibus test result, effect size, significant pairwise comparisons.
37+
8. Save the executable analysis script (`analysis_code.py` or `analysis_code.R`) and software version manifest (`session_info.txt`) used to produce results.
38+
9. Write results and plot (PDF) to output directory.
39+
10. Report: omnibus test result, effect size, significant pairwise comparisons.
3940

4041
## Output Contract
4142

4243
- Omnibus test result (TSV): test, statistic, df, p_value, effect_size, effect_size_type
4344
- Post-hoc comparisons table (TSV): group1, group2, statistic, p_value, adj_p_value, significant
4445
- Box plot with significance brackets (PDF)
4546
- Decision log explaining method selection (printed to stdout)
47+
- Reproducibility artifacts: `analysis_code.py` or `analysis_code.R`, plus `session_info.txt`
4648

4749
## Limits
4850

skills/stat-logistic-regression/SKILL.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,31 @@ description: Fit a logistic regression model for binary outcomes, report odds ra
2727

2828
1. Read data; validate that outcome column is binary; encode predictors as needed.
2929
2. Split data into training and test sets (stratified by outcome).
30-
3. Fit logistic regression on training set using maximum likelihood estimation.
31-
4. Report for each coefficient: log-odds estimate, standard error, z-statistic, p-value, odds ratio, 95% CI for odds ratio.
30+
3. Fit logistic regression on training set:
31+
- If `regularization=none`: unpenalized MLE fit for inferential reporting.
32+
- If `regularization=l1` or `l2`: cross-validated penalized fit for prediction-focused modeling.
33+
4. Report coefficients:
34+
- Unpenalized model: log-odds estimate, standard error, z-statistic, p-value, odds ratio, 95% CI.
35+
- Penalized model: shrunken coefficients and odds ratios; do not report classical p-values/z-statistics from penalized fit.
3236
5. Evaluate on test set: compute AUC-ROC, plot ROC curve, compute confusion matrix at 0.5 threshold (accuracy, sensitivity, specificity, PPV, NPV).
33-
6. Compute Hosmer-Lemeshow goodness-of-fit test for calibration.
34-
7. If regularization is used: report optimal lambda from cross-validation, coefficients at optimal lambda.
35-
8. Write coefficient table (TSV), performance metrics (TSV), ROC curve plot (PDF), and calibration plot (PDF) to output directory.
37+
6. Compute Hosmer-Lemeshow goodness-of-fit test for calibration for the unpenalized model; for penalized models, report calibration curve and Brier score.
38+
7. If regularization is used: report optimal lambda from cross-validation and non-zero coefficients at optimal lambda.
39+
8. Save the executable analysis script (`analysis_code.py` or `analysis_code.R`) and software version manifest (`session_info.txt`) used to produce results.
40+
9. Write coefficient table(s), performance metrics (TSV), ROC curve plot (PDF), and calibration plot (PDF) to output directory.
3641

3742
## Output Contract
3843

39-
- Coefficient table (TSV): term, log_odds, std_error, z_statistic, p_value, odds_ratio, ci_lower_or, ci_upper_or
40-
- Performance metrics (TSV): auc, accuracy, sensitivity, specificity, ppv, npv, hl_test_p
44+
- Coefficient table (TSV, unpenalized): term, log_odds, std_error, z_statistic, p_value, odds_ratio, ci_lower_or, ci_upper_or
45+
- Coefficient table (TSV, penalized): term, log_odds, odds_ratio, selected_at_lambda
46+
- Performance metrics (TSV): auc, accuracy, sensitivity, specificity, ppv, npv, hl_test_p_or_na, brier_score
4147
- ROC curve (PDF)
4248
- Confusion matrix (printed to stdout)
49+
- Reproducibility artifacts: `analysis_code.py` or `analysis_code.R`, plus `session_info.txt`
4350

4451
## Limits
4552

4653
- Assumes independence of observations; does not account for clustering or repeated measures.
4754
- Requires sufficient events per variable (EPV ≥ 10 recommended) to avoid overfitting.
4855
- Class imbalance can inflate accuracy; examine sensitivity/specificity and AUC.
56+
- Penalized models are prediction-oriented; classical inferential statistics (standard errors/p-values) are not directly interpretable from penalized coefficients.
4957
- Common failure: outcome column with more than two levels — binarize before running.

0 commit comments

Comments
 (0)