references/test_selection_guide.md
6.8 KB查看排版效果| 1 | # Statistical Test Selection Guide |
| 2 | |
| 3 | Choose a model for the estimand, sampling unit and dependence structure. A Shapiro-Wilk/Levene p-value is not an automatic switch between tests. The routes below are candidates whose assumptions must match the study. |
| 4 | |
| 5 | ## Decision Tree for Test Selection |
| 6 | |
| 7 | ### 1. Comparing Groups |
| 8 | |
| 9 | #### Two Independent Groups |
| 10 | - **Independent mean contrast**: Welch's t-test (`pg.ttest(..., correction=True)`); pooled Student's test only with justified common variance |
| 11 | - **Rank/distribution contrast**: Mann-Whitney U (Wilcoxon rank-sum); a median shift interpretation requires comparable distributional shapes |
| 12 | - **Binary outcome**: Chi-square test or Fisher's exact test (if expected counts < 5) |
| 13 | - **Ordinal outcome**: Mann-Whitney U test |
| 14 | |
| 15 | #### Two Paired/Dependent Groups |
| 16 | - **Paired mean contrast**: Paired t-test on aligned within-subject differences; assess differences, not marginal normality |
| 17 | - **Symmetric paired difference distribution**: Wilcoxon signed-rank; otherwise consider a sign test for the prespecified median-difference question |
| 18 | - **Binary outcome**: McNemar's test |
| 19 | - **Ordinal outcome**: Signed-rank only when difference magnitudes and symmetry are meaningful; consider a sign test or ordinal model otherwise |
| 20 | |
| 21 | #### Three or More Independent Groups |
| 22 | - **Continuous outcome, normally distributed, equal variances**: One-way ANOVA |
| 23 | - **Continuous outcome, normally distributed, unequal variances**: Welch's ANOVA |
| 24 | - **Independent rank/distribution contrast**: Kruskal-Wallis H; a median interpretation requires comparable shapes |
| 25 | - **Binary/categorical outcome**: Chi-square test |
| 26 | - **Ordinal outcome**: Kruskal-Wallis H test |
| 27 | |
| 28 | #### Three or More Paired/Dependent Groups |
| 29 | - **Repeated continuous means**: Repeated measures ANOVA with suitable covariance/sphericity correction, or a mixed model |
| 30 | - **Complete blocks/repeated rank contrast**: Friedman test; missing/unequal visits may require a model |
| 31 | - **Binary outcome**: Cochran's Q test |
| 32 | |
| 33 | #### Multiple Factors (Factorial Designs) |
| 34 | - **Continuous outcome**: Two-way ANOVA (or higher-way ANOVA) |
| 35 | - **With covariates**: ANCOVA |
| 36 | - **Mixed within and between factors**: Mixed ANOVA |
| 37 | |
| 38 | ### 2. Relationships Between Variables |
| 39 | |
| 40 | #### Two Continuous Variables |
| 41 | - **Linear association**: Pearson correlation; usual small-sample parametric inference assumes an appropriate joint model |
| 42 | - **Monotone rank association**: Spearman rank correlation, selected by the estimand rather than a marginal normality test |
| 43 | - **Rank-based data**: Spearman or Kendall's tau |
| 44 | |
| 45 | #### One Continuous Outcome, One or More Predictors |
| 46 | - **Single continuous predictor**: Simple linear regression |
| 47 | - **Multiple continuous/categorical predictors**: Multiple linear regression |
| 48 | - **Categorical predictors**: ANOVA/ANCOVA framework |
| 49 | - **Non-linear relationships**: Polynomial regression or generalized additive models (GAM) |
| 50 | |
| 51 | #### Binary Outcome |
| 52 | - **Single predictor**: Logistic regression |
| 53 | - **Multiple predictors**: Multiple logistic regression |
| 54 | - **Rare events**: Exact logistic regression or Firth's method |
| 55 | |
| 56 | #### Count Outcome |
| 57 | - **Poisson-distributed**: Poisson regression |
| 58 | - **Overdispersed counts**: Negative binomial regression |
| 59 | - **Excess zeros with a justified separate structural-zero process**: Zero-inflated Poisson/negative binomial; many zeros alone do not establish zero inflation |
| 60 | |
| 61 | #### Time-to-Event Outcome |
| 62 | - **Comparing survival curves**: Log-rank test |
| 63 | - **Modeling with covariates**: Cox proportional hazards regression |
| 64 | - **Parametric survival models**: Weibull, exponential, log-normal |
| 65 | |
| 66 | ### 3. Agreement and Reliability |
| 67 | |
| 68 | #### Inter-Rater Reliability |
| 69 | - **Categorical ratings, 2 raters**: Cohen's kappa |
| 70 | - **Categorical ratings, >2 raters**: Fleiss' kappa or Krippendorff's alpha |
| 71 | - **Continuous ratings**: Intraclass correlation coefficient (ICC) |
| 72 | |
| 73 | #### Test-Retest Reliability |
| 74 | - **Continuous measurements**: Choose and report an ICC model (agreement/consistency, single/average, random/fixed raters); Pearson correlation alone does not measure agreement |
| 75 | - **Internal consistency**: Cronbach's alpha |
| 76 | |
| 77 | #### Agreement Between Methods |
| 78 | - **Continuous measurements**: Bland-Altman analysis |
| 79 | - **Categorical classifications**: Cohen's kappa |
| 80 | |
| 81 | ### 4. Categorical Data Analysis |
| 82 | |
| 83 | #### Contingency Tables |
| 84 | - **2x2 table**: Chi-square test or Fisher's exact test |
| 85 | - **Larger than 2x2**: Chi-square when expected counts support the approximation; current SciPy also supports generalized exact/resampling procedures |
| 86 | - **Ordered categories**: Cochran-Armitage trend test |
| 87 | - **Paired categories**: McNemar's test (2x2) or McNemar-Bowker test (larger) |
| 88 | |
| 89 | ### 5. Bayesian Alternatives |
| 90 | |
| 91 | Any of the above tests can be performed using Bayesian methods: |
| 92 | - **Group comparisons**: Bayesian t-test, Bayesian ANOVA |
| 93 | - **Correlations**: Bayesian correlation |
| 94 | - **Regression**: Bayesian linear/logistic regression |
| 95 | |
| 96 | **Advantages of Bayesian approaches:** |
| 97 | - Provides probability of hypotheses given data |
| 98 | - Naturally incorporates prior information |
| 99 | - Provides credible intervals instead of confidence intervals |
| 100 | - No p-value interpretation issues |
| 101 | |
| 102 | ## Key Considerations |
| 103 | |
| 104 | ### Sample Size |
| 105 | - No universal n=30 rule establishes validity or power. For small samples assess model assumptions; exact/permutation methods need exchangeability, tie handling and the correct sampling unit |
| 106 | - Very large samples: Even small effects may be statistically significant; focus on effect sizes |
| 107 | |
| 108 | ### Multiple Comparisons |
| 109 | - When conducting multiple tests, adjust for multiple comparisons using: |
| 110 | - Bonferroni correction (conservative) |
| 111 | - Holm-Bonferroni (less conservative) |
| 112 | - False Discovery Rate (FDR) control (Benjamini-Hochberg) |
| 113 | - Tukey HSD for post-hoc ANOVA comparisons |
| 114 | |
| 115 | ### Missing Data |
| 116 | - Complete case analysis (listwise deletion) |
| 117 | - Multiple imputation |
| 118 | - Maximum likelihood methods |
| 119 | - Ensure missing data mechanism is understood (MCAR, MAR, MNAR) |
| 120 | |
| 121 | ### Effect Sizes |
| 122 | - Always report effect sizes alongside p-values |
| 123 | - See `effect_sizes_and_power.md` for guidance |
| 124 | |
| 125 | ### Study Design Considerations |
| 126 | - Randomized controlled trials: Standard parametric/non-parametric tests |
| 127 | - Observational studies: Consider confounding and use regression/matching |
| 128 | - Clustered/nested data: Use mixed-effects models or GEE |
| 129 | - Time series: Use time series methods (ARIMA, etc.) |
| 130 | |
| 131 | ## Implementation sources and limits |
| 132 | |
| 133 | Reviewed 2026-10-01: [SciPy Mann-Whitney](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.mannwhitneyu.html), [Wilcoxon](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.wilcoxon.html), [Pingouin repeated measures](https://pingouin-stats.org/generated/pingouin.rm_anova.html). Small tied samples need an appropriate permutation/asymptotic method; the default automatic method is not universally exact. Compute rounded difference scores when floating-point subtraction creates spurious distinct ranks. Survival, Firth/exact logistic, agreement, missing-data and complex factorial routes here are design guidance, not executed implementations. |
文件内容是平台检查时读出的文本,只供查看。平台不会运行包里的任何脚本或程序。

