A decision tree for common psychology analyses — t-tests, ANOVA, regression, moderation, mediation, and linear mixed models — with ready-to-use R code.
| Test | Use when… | Main R function |
|---|---|---|
| Independent samples t-test | Compare means of 2 independent groups | t.test() |
| Paired samples t-test | Compare means of 2 related/repeated conditions | t.test(paired = TRUE) |
| One-way ANOVA | Compare means across 3+ independent groups, 1 factor | aov() |
| ANCOVA | Compare group means while controlling for a continuous covariate | aov(y ~ group + covariate) |
| Factorial (two-way) ANOVA | Compare means across groups defined by 2+ factors | aov(y ~ A * B) |
| Repeated-measures ANOVA | Compare 3+ within-subject conditions (simple, balanced design) | afex::aov_ez() |
| Simple linear regression | Predict a continuous outcome from 1 predictor | lm() |
| Multiple linear regression | Predict a continuous outcome from 2+ predictors | lm() |
| Logistic regression | Predict a binary outcome from 1+ predictors | glm(family = binomial) |
| Moderation | Test if a third variable changes the strength/direction of a relationship | lm(y ~ x * w) |
| Mediation | Test if a third variable explains the mechanism linking two variables | mediation::mediate() |
| Linear mixed model | Repeated/nested/clustered/unbalanced data with random effects | lme4::lmer() |