Common Statistical Tests Are Linear Models
For theoretical background, see Jonas Kristoffer Lindeløv’s Common statistical tests are linear models.
Parametric Tests¶
| Classical Test | bossanova Code | Tutorial |
|---|
| One-sample t-test | model("y ~ 1", df) | One-Sample |
| Paired t-test | model("y ~ condition + (1|subject)", df) | Within-Subject |
| Independent t-test | model("y ~ group", df) | Two-Sample |
| Welch’s t-test | model("y ~ group", df).infer(errors="unequal_var") | Two-Sample |
| Pearson correlation | model("zscore(y) ~ zscore(x)", df) (slope = r) | Correlation |
| One-way ANOVA | model("y ~ group", df).infer("joint").effects | ANOVA |
| Welch’s ANOVA | model("y ~ group", df).infer("joint").infer(errors="unequal_var").effects | ANOVA |
| Two-way ANOVA | model("y ~ a * b", df).infer("joint").effects | ANOVA |
| ANCOVA | model("y ~ group + covariate", df) | ANOVA |
| RM-ANOVA | model("y ~ condition + (1|subject)", df) | Within-Subject |
Rank-Based (Non-Parametric) Tests¶
| Classical Test | bossanova Code | Tutorial |
|---|
| Wilcoxon signed-rank | model("signed_rank(y) ~ 1", df) | One-Sample |
| Wilcoxon signed-rank (paired) | model("rank(y) ~ condition + (1|subject)", df) | Within-Subject |
| Mann-Whitney U | model("rank(y) ~ group", df) | Two-Sample |
| Kruskal-Wallis | model("rank(y) ~ group", df).infer("joint").effects | ANOVA |
| Spearman correlation | model("zscore(rank(y)) ~ zscore(rank(x))", df) | Correlation |
| Friedman test | model("rank(y) ~ condition + (1|subject)", df) | Within-Subject |
Count Data (GLM)¶
| Classical Test | bossanova Code | Tutorial |
|---|
| Chi-square goodness of fit | model("count ~ category", df, family="poisson") | Count Data |
| Chi-square independence | model("count ~ row * col", df, family="poisson") (test interaction) | Count Data |
Robust Inference¶