Skip to content

Choosing a Statistical Test

A test answers one question about one design. Choose it from the way the experiment was built and the thing it measured, before the results arrive, and the choice will survive a reviewer who asks why. The trees below ask what the study asks, whether the samples are independent or dependent, what type of outcome it measured, how many groups it compares, and how many tests the analysis will run. Each leaf names a test and links to the lesson in this section that runs it in R and Python.

Swinscow and Campbell ask this question before they ask what type of data the study collected, and they give a separate table of tests for each answer. Samples are independent when each group holds different units and nothing links a value in one group to a particular value in another. Samples are dependent when every value has a partner in the other group, either the same unit measured again or a unit matched to it before the experiment. Motulsky states the test of the difference in terms of correlation. A paired test fits when each value in one group is more closely correlated with a specific value in the other group than with random values in that group.

Design Samples Next step
Six treated and six control mice, one value from each mouse Independent Independent samples tree
The same mice measured before and after treatment Dependent, the same units Dependent samples tree
Cells from each of 18 donors split into a control well and a stimulated well, as in the paired samples lesson Dependent, matched by donor Dependent samples tree
An experiment repeated on four days, each run with its own control Dependent, matched by run Dependent samples tree
Hemoglobin measured in each subject at four visits, as in the repeated measures lesson Dependent, repeated measures Dependent samples tree
Cases matched to controls by age and sex before the study Dependent, matched units Dependent samples tree
Four mice per group, three wells from each mouse Independent mice, with three dependent wells inside each mouse Average the wells of each mouse, then the independent samples tree
Some donors measured twice, others once Both A mixed model

The wrong tree changes the answer. The paired samples lesson measures TNF in stimulated and control cells from 18 donors, and its paired t-test gives p = 0.0013. Welch’s t-test on the same numbers treats the two columns as 36 different donors and returns p = 0.36, because the spread between donors stays in its standard error, which is 45.16 pg/mL against 10.85 pg/mL for the paired analysis. Swinscow and Campbell write that “One of the most common mistakes in statistical analysis is to treat dependent variables as independent.”

The same mistake can push the p-value the other way. Four mice per group with three wells each give 12 rows per group and four units. Analyzed as 12 independent values, those rows produce a p-value that is too small, because the three wells of one mouse share that mouse. Average the wells within each mouse and compare the mouse means, or model the mouse as a random effect as the mixed models lesson does. Swinscow and Campbell count a leg ulcer trial the same way: 20 patients with 30 ulcers give 20 independent pieces of information, because an ulcer on one leg can affect the ulcer on the other.

Pairing belongs to the design. Motulsky allows a paired test only when the subjects were matched or paired before the data were collected, and the pairing cannot come from the data under analysis. Swinscow and Campbell put it as “a matched design should be followed by a matched analysis.” A study that mixes the two, with some donors measured twice and others once, fits neither samples tree. Swinscow and Campbell send that case to a statistician; a mixed model can use every observation in it.

Decision tree for the start of the test choice. The first question is what the study asks. A difference between groups leads to a second question: are the samples independent or dependent? Independent samples, with a different unit in each group, go to the independent samples tree. Dependent samples, with the same units measured again or matched units, go to the dependent samples tree. One group against a reference value takes the one-sample t-test or the Wilcoxon signed-rank test, from the paired samples lesson. An association of two variables takes Pearson correlation, or Spearman for ranks, and two categorical variables take the chi-square or Fisher’s exact test. An adjusted effect or a prediction takes the regression for the outcome type: linear, logistic, count, or Cox.

The study asks about Samples or outcome Next step
A difference between groups Independent samples The independent samples tree
A difference between groups Dependent samples The dependent samples tree
One group against a reference value A measurement One-sample t-test, or Wilcoxon signed-rank test
An association of two variables Two measurements Pearson correlation, or Spearman for ranks
An association of two variables Two categorical variables Chi-square or Fisher’s exact test
An adjusted effect, or a prediction Any type Linear, logistic, count, or Cox regression

The one-sample row links to the paired lesson because a paired t-test is a one-sample t-test of the within-pair differences against zero, and that lesson runs both to show the identical result. The same idea runs through the dependent samples tree. Each of its tests compares values within a unit or a matched set.

Decision tree for independent samples, with a different unit in each group. The question is the type of outcome. A measurement takes Welch’s t-test or the Mann-Whitney test for two groups, and one-way ANOVA or Welch’s ANOVA, or the Kruskal-Wallis test, for three or more groups, from the two groups and ANOVA lessons. Three or more groups continue to the multiple testing tree. Ordered categories or a score take the Mann-Whitney test or a test for trend for two groups, and the Kruskal-Wallis test for three or more. A yes or no outcome, or categories, takes Fisher’s exact test, or chi-square for large counts, for two groups, and the chi-square test for three or more, from the categorical data lesson. Time to an event takes Kaplan-Meier curves and the log-rank test, then Cox regression.

Outcome Two groups Three or more groups Lessons
A measurement Welch’s t-test, or the Mann-Whitney test One-way ANOVA or Welch’s ANOVA, or the Kruskal-Wallis test Two groups, ANOVA
Ordered categories, or a score Mann-Whitney test, or a test for trend Kruskal-Wallis test Two groups, ANOVA
Yes or no, or categories Fisher’s exact test, or chi-square for large counts Chi-square test Categorical data
Time to an event Kaplan-Meier and log-rank test, then Cox regression Kaplan-Meier and log-rank test, then Cox regression Kaplan-Meier, Cox regression

For a measurement, the parametric tree chooses between the two tests in each cell. For two groups it gives Welch’s t-test, which does not assume that the groups share a variance, and Delacre, Lakens, and Leys (2017) argue that it should replace Student’s t-test as the default. A significant ANOVA or Kruskal-Wallis test says that the groups are not all equal. It does not say which ones differ, and the multiple testing tree chooses the comparisons that follow. Two crossed factors, such as genotype and treatment, take a two-way ANOVA. A continuous covariate measured before treatment takes ANCOVA.

The ordered categories row comes from Swinscow and Campbell, who give a test for trend or the Mann-Whitney U test with a correction for ties. On a five-point score most values share a rank with other values, so the test needs that correction. The categorical data lesson gives the working rule for the chi-square approximation, an expected count of at least 5 in every cell, and a 2x2 table that fails the rule takes Fisher’s exact test. A binary outcome that needs adjustment for covariates takes logistic regression.

Decision tree for dependent samples, with the same units measured again or matched units. The question is the type of outcome. A measurement takes the paired t-test or the Wilcoxon signed-rank test for two groups, from the paired samples lesson, and repeated measures ANOVA or a mixed model, or the Friedman test, for three or more, from the repeated measures and mixed models lessons. Three or more groups continue to the multiple testing tree. Ordered categories or a score take the Wilcoxon signed-rank test for two groups and the Friedman test for three or more. A yes or no outcome takes McNemar’s test for two groups and Cochran’s Q test for three or more, with no lesson on this site. Time to an event takes conditional proportional hazards regression, a Cox model stratified by matched set, with no lesson on this site.

Outcome Two groups Three or more groups Lessons
A measurement Paired t-test, or the Wilcoxon signed-rank test Repeated measures ANOVA or a mixed model, or the Friedman test Paired samples, repeated measures, mixed models
Ordered categories, or a score Wilcoxon signed-rank test Friedman test Paired samples, repeated measures
Yes or no McNemar’s test Cochran’s Q test None in this section
Time to an event Conditional proportional hazards regression Conditional proportional hazards regression None in this section

Swinscow and Campbell add a footnote to their paired table: “It is the difference between the paired observations that should be plausibly Normal.” For two dependent groups, ask the questions of the parametric tree about the within-pair differences, and not about either column. Repeated measures ANOVA needs every unit at every level, and the repeated measures lesson shows what it and a mixed model do when visits are missing. Swinscow and Campbell warn that “Results measured over time require special care”, and a trial with a long series of visits takes the mixed model for repeated measures.

McNemar’s test is the paired form for a yes or no outcome. Each pair gives one of four combinations of outcomes, and the test uses only the pairs whose two outcomes differ. Cochran’s Q test extends it to three or more matched conditions. A binary outcome on clustered units that needs adjustment for covariates takes a generalized mixed model. For matched survival times, Motulsky lists conditional proportional hazards regression, which fits a Cox model with one stratum for each pair or matched set.

The measurement leaves of both samples trees hold two tests. This tree chooses between them.

Decision tree for the choice between a parametric and a nonparametric test. The first question asks whether the outcome is a rank or a score, or whether some values are off the scale. Yes leads to a nonparametric test. No leads to the second question: are the values positive with a long right tail? Yes leads to an analysis of the logarithm of the values, then to the third question; no leads straight to the third question. The third question asks whether earlier data or the residual plot show a roughly Normal shape. Yes leads to a parametric test. No, or not sure, leads to the fourth question: are there at least two dozen values in each group? Yes leads to a parametric test, and no leads to a nonparametric test.

  1. Is the outcome a rank or a score, or are some values off the scale, too high or too low to measure? If yes, use the nonparametric test.
  2. Are the values positive with a long right tail, as concentrations and expression values often are? If yes, analyze their logarithm. A t-test on log values compares geometric means, and its result reads as a ratio.
  3. Do earlier data of the same kind, or the residual plot of the fitted model, show a roughly Normal shape? If yes, use the parametric test.
  4. If not, or if you cannot tell, does each group hold at least two dozen values? If yes, use the parametric test. If no, use the nonparametric test.

The questions follow Motulsky’s chapter. The fourth is his rule of thumb: “Unless the population distribution is really weird, you are probably safe choosing a parametric test when there are at least two dozen data points in each group.”

No question in the tree runs a Shapiro-Wilk test. Rochon, Gondan, and Kieser (2012) simulated the procedure in which a normality pre-test chooses between the t-test and the Mann-Whitney test, and the pre-test changed the conditional Type I error rate of the test that followed it. Motulsky adds that a formal test of the distribution has little power in small samples, which is where the choice matters most. The checking assumptions lesson reads the residual plot instead.

The nonparametric leaf has a hard floor in small experiments. Three samples per group allow 20 ways to split six ranks between the groups, so the smallest two-sided p-value an exact Mann-Whitney test can return is 2/20 = 0.1. No result from that design falls below 0.05. The Wilcoxon signed-rank test has a floor too: five pairs give 32 equally likely patterns of signs, so its smallest two-sided p-value is 2/32 = 0.0625. In an experiment of that size, answer the third question from earlier data with the same assay, and report the effect with its interval.

Decision tree for more than one test. The question is how many tests answer the study question. One planned primary test needs no correction; report the effect with its interval. Pairwise comparisons after a test of three or more groups take Tukey for all pairs, Dunnett for each group against a control, Games-Howell for unequal variances, or Dunn after Kruskal-Wallis, from the post hoc comparisons lesson. A small family of planned tests takes Holm, or Bonferroni at 0.05 divided by n, from the multiple testing lesson. Many tests, such as one test for each gene, take the Benjamini-Hochberg false discovery rate, from the multiple testing lesson.

Situation Method Lesson
One planned primary test No correction; report the effect with its interval Two groups
Pairwise comparisons after a test of three or more groups Tukey for all pairs, Dunnett against a control, Games-Howell for unequal variances, Dunn after Kruskal-Wallis Post hoc comparisons
A small family of planned tests Holm, or Bonferroni at 0.05/n Multiple testing
Many tests, such as one test per gene Benjamini-Hochberg false discovery rate Multiple testing

Swinscow and Campbell advise deciding before the analysis which hypotheses are confirmatory, and keeping that list short. Their Bonferroni rule tests each of n hypotheses at 0.05/n, so two hypotheses need p < 0.025 each. They call the rule conservative, because tests are rarely independent. Holm’s method controls the same family-wise error rate and never rejects fewer hypotheses than Bonferroni.

Family-wise control is too strict for a genome. One test for each of 20,000 genes puts the Bonferroni threshold at 0.05/20,000, or 2.5e-6. Benjamini and Hochberg (1995) control a different quantity, the expected share of false discoveries among the rejected hypotheses, and that is the correction the multiple testing lesson applies to a gene list.

A cytokine is measured once in the serum of six treated and six control mice.

  1. Each mouse gives one value in one group, so the samples are independent, with six units per group.
  2. The study asks about a difference between groups, and the start tree sends independent samples to the independent samples tree.
  3. The outcome is a measurement and there are two groups, so the leaf is Welch’s t-test or the Mann-Whitney test.
  4. A concentration is positive with a long right tail, so the analysis moves to the log scale. If earlier experiments with the same assay gave roughly Normal log concentrations, the choice is Welch’s t-test on the log values. Without such data, six values per group fall short of two dozen, and the Mann-Whitney test applies.
  5. The study has one planned primary test, so it needs no correction. The report gives the ratio of geometric means with its interval.

If the same six mice were sampled before and after treatment instead, the samples would be dependent. The route would end in the dependent samples tree at the paired t-test on the log differences, and the shape question of the parametric tree would apply to those differences.

Rochon, Gondan, and Kieser, 2012 simulate the two-stage procedure in which a Shapiro-Wilk pre-test chooses between Student’s t-test and the Mann-Whitney test, and show that the pre-test changes the conditional Type I error rate of the test that follows it.

Delacre, Lakens, and Leys, 2017 argue that Welch’s t-test should replace Student’s t-test as the default test for two independent groups.

Benjamini and Hochberg, 1995 define the false discovery rate and give the step-up procedure that controls it.

Choosing a statistical test is chapter 37 of the first edition of Motulsky’s Intuitive Biostatistics, on the GraphPad website. It holds the complete Table 37.1 and Motulsky’s reasoning on parametric tests, paired tests, and one- or two-sided p-values.

Study design and choosing a statistical test is chapter 14, pages 215 to 226, of the 12th edition of Statistics at Square One, edited by Campbell and published by Wiley-Blackwell in 2021. It is the current edition of the chapter this page follows.

Choosing the right test, from John McDonald’s Handbook of Biological Statistics, sorts tests by the number of nominal, measurement, and ranked variables, with a biological example for each. It is a useful cross-check for designs outside these trees.