Sub topic 6
The test selection map
This chapter assumes you can already tell continuous data from discrete data, read a p-value against a significance level, and state a null and alternative hypothesis. Here you will turn those pieces into a repeatable way to shortlist a test before you touch any software.
Why a map is needed
Statistical software offers dozens of tests. Picking one by habit, usually the t-test, is how Analyze-phase projects end up with conclusions that do not hold. The test selection map is a lookup that narrows the choice to one or two candidates. It uses two facts you already know when you frame the question:
- The data type of the output, Y, which is the response you want to improve.
- The data type of the input, X, which is the factor you suspect drives Y.
The map does not choose the final test. It gives you a shortlist, and the assumption checks in the next chapters decide among the candidates.
The three questions that drive the map
Answer these in order.
- Is Y continuous or discrete? Cycle time, weight, and temperature are continuous. Defective or not, and count of complaints, are discrete.
- Is X continuous or discrete? Machine speed is continuous. Shift, supplier, and operator are discrete, and each value of a discrete X is a group or level.
- How many groups or samples are involved? Is it one sample compared with a target, two groups, or three or more groups? If there are two groups, are the observations paired?
"Paired" means each observation in one group has a natural partner in the other. Examples are the same part measured before and after a repair, or the same operator on two methods. Paired data must be analyzed as pairs. Treating them as two independent groups throws away the pairing and usually weakens the test.
The map as a table
| Y (output) | X (input) | Design | Parametric test | Fallback when assumptions fail |
|---|---|---|---|---|
| Continuous | None (target value) | One sample vs target | One-sample t-test | One-sample Wilcoxon signed-rank |
| Continuous | Discrete, 2 levels | Independent groups | Two-sample t-test (Welch) | Mann-Whitney |
| Continuous | Discrete, 2 levels | Paired measurements | Paired t-test | Wilcoxon signed-rank on differences |
| Continuous | Discrete, 3+ levels | Independent groups | One-way ANOVA | Kruskal-Wallis, Mood's median |
| Continuous | Continuous | Relationship | Correlation, simple regression | Spearman rank correlation |
| Discrete | None (target rate) | One sample vs target | One-proportion test | Exact binomial test |
| Discrete | Discrete, 2 levels | Independent groups | Two-proportion test | Fisher's exact test |
| Discrete | Discrete, 2+ levels | Association | Chi-square test of association | Fisher's exact test (small tables) |
| Discrete | Continuous | Relationship | Logistic regression | Not covered in this chapter |
Two things about the table are easy to miss.
- The "parametric" column assumes the data meet conditions such as approximate normality. Later chapters cover how to check those conditions.
- The last row is a real case. A pass/fail outcome driven by a continuous input, such as defect rate versus oven temperature, is common in Six Sigma work. It needs logistic regression. Do not force it into a t-test by grouping the temperature into "low" and "high" unless you accept the information loss.
The map as a decision flow
The same logic can be drawn as a flowchart. Starting from the data type of Y avoids most selection mistakes, because Y fixes the family of tests.
A worked example
A plant manager asks whether scrap rate differs across three suppliers of the same raw material. You record the following for each batch:
- The supplier, which is A, B, or C.
- The batch scrap rate, which is a percentage and is treated as continuous.
Y is continuous, X is discrete with three levels, and the groups are independent. The map points to one-way ANOVA, with Kruskal-Wallis as the fallback. The map rules out three tests that would be tempting:
- Running three separate two-sample t-tests inflates the chance of a false positive, which the multiple comparisons chapter covers.
- A chi-square test would apply only if each batch were recorded as simply "scrap" or "not scrap".
- A paired test would apply only if the same batches were measured with all three suppliers, which is impossible here.
Now change the data collection. Suppose you inspect 200 units per supplier and record pass or fail for each unit. Y is now discrete, X is discrete, and the question is about association. The map points to a chi-square test of association. Changing how you measure Y changed the test, even though the business question stayed the same.
Encoding the map in code
Writing the map as a function is a useful check that you understand it. This function returns the shortlist for a scenario.
def shortlist(y, x, levels=2, paired=False):
"""Return (parametric test, fallback) for a Y/X data-type scenario.
y: "continuous" or "discrete"
x: "none" (compare to a target), "discrete", or "continuous"
levels: number of groups when x is "discrete"
paired: True if observations in two groups are naturally paired
"""
if y == "continuous":
if x == "none":
return ("one-sample t-test", "one-sample Wilcoxon")
if x == "continuous":
return ("correlation / simple regression", "Spearman correlation")
if levels == 2 and paired:
return ("paired t-test", "Wilcoxon signed-rank on differences")
if levels == 2:
return ("Welch two-sample t-test", "Mann-Whitney")
return ("one-way ANOVA", "Kruskal-Wallis")
if x == "none":
return ("one-proportion test", "exact binomial test")
if x == "continuous":
return ("logistic regression", "none in this chapter")
if levels == 2:
return ("two-proportion test", "Fisher's exact test")
return ("chi-square test of association", "Fisher's exact test (small tables)")
print(shortlist("continuous", "discrete", levels=3))
print(shortlist("continuous", "discrete", levels=2, paired=True))
print(shortlist("discrete", "discrete", levels=2))Running it prints three tuples: ANOVA with Kruskal-Wallis, the paired t-test with its Wilcoxon fallback, and the two-proportion test with Fisher's exact test.
Common errors when using the map
- Classifying by appearance instead of meaning. Defect counts per unit look like numbers, but they are discrete counts and often do not behave like continuous data. Ask what values the variable can take.
- Binning a continuous Y. Converting measurements to "in spec" and "out of spec" turns a continuous Y into a discrete one. This throws away information and usually requires far more data to detect the same shift.
- Ignoring pairing. If the same units appear in both groups, an independent two-sample test gives the wrong answer. Pairing reduces noise because unit-to-unit variation cancels in the differences.
- Treating the map as final. The parametric column assumes conditions that you must check. If they fail, move to the fallback column instead of forcing the parametric test.
- Using X levels that are not independent groups. Repeated measures on the same units across three conditions are not a one-way ANOVA design.
Exercises
Exercise
A team measures the diameter (mm) of 40 shafts from Machine 1 and 40 shafts from Machine 2, and wants to know whether the mean diameter differs. Identify Y, X, the design, and the shortlisted tests.
Show answer
Y is shaft diameter, which is continuous. X is the machine, which is discrete with two levels. The shafts are independent, so the design is not paired. The shortlist is the Welch two-sample t-test, with Mann-Whitney as the fallback if normality fails.
Exercise
A call center records, for each of 500 calls, whether the issue was resolved on first contact (yes or no) and which of four teams handled it. Which test does the map suggest, and what changes if the team is replaced by call length in minutes?
Show answer
Y is discrete (resolved or not) and X is discrete with four levels, so the map suggests a chi-square test of association, with Fisher's exact test if expected counts are small. If X becomes call length in minutes, X is continuous and Y is discrete, so the map points to logistic regression.