Choosing a statistical test is one of the most common sticking points in a thesis. The right test depends on your research question, the type of your data, how many groups you have and whether the same people were measured more than once. Use the chooser below, then read the reference table to see menu paths in SPSS and function names in Python.
Which test should I use?
Answer a few questions and get a suggested test, how to run it in SPSS and in Python, and what to report.
Before you test: three checks
- Type of data. Numeric (continuous), ordinal (ranked, such as Likert items) or categorical (groups or labels).
- Design. Are groups independent (different people) or related (the same people measured again, or matched pairs)?
- Assumptions. Many tests assume roughly normal data, similar variances and independent observations. Check them with plots and tests such as Shapiro-Wilk (normality) and Levene (variances). With small samples be especially careful.
Reference table: common tests
| Question | Test | SPSS menu | Python (SciPy / statsmodels) |
|---|---|---|---|
| Two independent groups, numeric | Independent t-test (or Mann-Whitney U if not normal) | Analyze > Compare Means > Independent-Samples T Test | scipy.stats.ttest_ind, mannwhitneyu |
| Same people, two times, numeric | Paired t-test (or Wilcoxon signed-rank) | Analyze > Compare Means > Paired-Samples T Test | scipy.stats.ttest_rel, wilcoxon |
| Three or more independent groups | One-way ANOVA (or Kruskal-Wallis) | Analyze > Compare Means > One-Way ANOVA | scipy.stats.f_oneway, kruskal |
| Same people, three or more times | Repeated-measures ANOVA (or Friedman) | Analyze > General Linear Model > Repeated Measures | statsmodels AnovaRM, scipy.stats.friedmanchisquare |
| Relationship, two numeric variables | Pearson (or Spearman) | Analyze > Correlate > Bivariate | scipy.stats.pearsonr, spearmanr |
| Association, two categorical variables | Chi-square (or Fisher's exact) | Analyze > Descriptive Statistics > Crosstabs > Statistics | scipy.stats.chi2_contingency, fisher_exact |
| Predict a numeric outcome | Linear regression | Analyze > Regression > Linear | statsmodels.formula.api.ols |
| Predict a yes/no outcome | Logistic regression | Analyze > Regression > Binary Logistic | statsmodels.formula.api.logit |
| Reliability of a scale | Cronbach's alpha | Analyze > Scale > Reliability Analysis | pingouin.cronbach_alpha |
| Check normality | Shapiro-Wilk and plots | Analyze > Descriptive Statistics > Explore > Plots | scipy.stats.shapiro |
Menu names can differ slightly between SPSS versions. The Python names refer to the SciPy, statsmodels and pingouin libraries.
A tiny Python example
from scipy import stats
df = pd.read_csv("survey.csv")
a = df.loc[df["group"] == "A", "score"]
b = df.loc[df["group"] == "B", "score"]
print(stats.shapiro(a), stats.shapiro(b)) # normality
print(stats.levene(a, b)) # equal variances
print(stats.ttest_ind(a, b, equal_var=False)) # Welch t-test
Reporting results well
- State the test, why you chose it, and which assumptions you checked.
- Report the test statistic, degrees of freedom (if any), exact p-value, sample size and an effect size with a confidence interval.
- Do not describe a non-significant result as "proof of no difference", and do not describe a significant correlation as causation.
- Describe any data cleaning, outlier handling and missing data decisions.