Rank tests of spread
Six tests score how far each rank lies from the middle. Most assume the groups share a center, and getting that wrong makes them test location by accident.
What runs in CodeSplash
- STAT095Fligner–Killeen test Runs in CodeSplash
- STAT096Ansari–Bradley test Runs in CodeSplash
- STAT097Mood scale test Runs in CodeSplash
- STAT098Siegel–Tukey test Runs in CodeSplash
- STAT099Klotz normal scores scale test Runs in CodeSplash
- STAT100Conover squared ranks test Runs in CodeSplash
- Equal spread tests Verified in Python and R
You will be able to
- Explain how scale scores turn ranks into a test of spread
- Say why two-group rank scale tests need a common center
- Choose Fligner–Killeen for several groups
Spread as a rank score
ReadIf one group is more spread out, its values pile up at both ends of the joint ranking and the other's sit in the middle. Give each rank a score for how far it lies from the center, then add them up for one group.
The score decides the test:
| Test | Score for rank out of |
|---|---|
| Ansari–BradleyAnsari–Bradley testTwo-group rank test of spread that scores values by how close they sit to the middle of the pooled data. | Distance from the nearer end |
| MoodMood scale testTwo-group rank test of spread based on squared distances of ranks from the middle rank. | |
| Siegel–TukeySiegel–Tukey testRanks values alternately from both ends inward, then runs a Wilcoxon rank-sum test on those ranks. | Ranks that alternate from the ends inward |
| KlotzKlotz testTwo-group scale test using squared normal scores of the ranks. | Squared normal quantile of |
| ConoverConover squared-ranks testRanks the distances from group means, squares the ranks and compares their averages across groups. | Squared ranks of distances from the group mean |
| Fligner–KilleenFligner–Killeen testRank-based test of equal spread using normal scores of each value's distance from its group median. | Normal scores of distances from the group median |
The hidden assumption
PredictPredict first
Two groups of 10 values each. Group A is far more spread out than group B, but B sits far above A with no overlap. What does a Mood test report?
Reveal
No difference. A takes ranks 1 to 10 and B takes 11 to 20 however spread out each one is, so their Mood scores mirror each other and sum to the same total. A smaller shift can do the opposite and mimic a difference. Ansari–Bradley, Mood, Siegel–Tukey and Klotz need the groups to share a center: align them first, or use a test that centers within groups.
Center first
ReadFligner–Killeen and Conover's squared ranks handle this for you: they rank each value's distance from its own group's center, so a location shift has little effect. Fligner–Killeen also works with any number of groups and has a strong record in simulation studies.
Read several at once
ReadIn these examples the true spreads are similar, so large p-values are expected:
- Fligner–Killeen with three groups: = 0.060, p = .971
- Conover: z = −0.27, p = .785
- Klotz: z = −0.10, p = .921
On a pair of groups with an SD ratio of about 1.6, Ansari–Bradley gives p = .541, Mood p = .444 and the exact Siegel–Tukey p = .529. With only 10 values per group, none of them has much power.
Power is the price
ReflectCompare those p-values with the F test on similar data, p = .168. Rank tests give up power under normality in exchange for not depending on it.
Before you collect data, ask how large a spread difference you must detect. Rank tests of spread often need many more observations per group than you'd need to detect a similar shift in location. How many could you get?
Check your understanding
CheckpointCheck yourself
You want a rank-based spread test across five groups whose medians differ. Which fits?
Show the answer
Answer: a
Ansari–Bradley and Siegel–Tukey handle two groups and assume a common center. Fligner–Killeen works from distances to each group's median.
Check yourself
With N = 9 values in total, what is the Mood score for the largest value, rank 9? Use (R − (N+1)/2)².
Show the answer
Answer: 16
(N + 1) / 2 = 5, and (9 − 5)² = 16. The middle rank scores 0.
Check yourself
Which test is designed to do best under normality while staying rank-based?
Show the answer
Answer: b
Klotz uses squared normal scores, so it does well when the data are near-normal.
Do it in CodeSplash
In the appChoose from the rank group in Equal spread tests' Test list. Two-group tests are disabled, with a reason, when you have more than two groups. Set p-value to exact or permutation for small samples.
import pandas as pd
from scipy import stats
df = pd.read_csv("plantgrowth.csv")
groups = [g["weight"] for _, g in df.groupby("group")]
print(stats.fligner(*groups))
a, b = groups[0], groups[1]
print(stats.ansari(a - a.median(), b - b.median())) # center first
print(stats.mood(a - a.median(), b - b.median()))fligner.test(weight ~ group, data = PlantGrowth)
a <- PlantGrowth$weight[PlantGrowth$group == "ctrl"]
b <- PlantGrowth$weight[PlantGrowth$group == "trt1"]
ansari.test(a - median(a), b - median(b)) # center first
mood.test(a - median(a), b - median(b))R's mood.test handles ties approximately; CodeSplash computes the exact tie variance, so results can differ with ties.
Recap
Recap- Rank scale tests score how far each rank lies from the middle.
- Ansari–Bradley, Mood, Siegel–Tukey and Klotz assume a shared center. Align first.
- Fligner–Killeen is a robust default for several groups, at some cost in power.
Concepts in this lesson