Advanced Quantitative Methods 360-301 • CEGEP, Montreal

Corrected exercises: nonparametric tests (360-301)

These ten corrected exercises cover the rank tests of Advanced Quantitative Methods 360-301 for Social Science students: Mann-Whitney, Wilcoxon, Kruskal-Wallis, Spearman and the sign test, with every calculation done by hand and every decision justified.

The thread of the set fits in one sentence: replacing values by their ranks makes a test insensitive to the shape of the distribution and to extreme values, at the price of information that you must then give back to the reader in another form.

Three pitfalls are named outright: the reversed decision rule, where you reject for a small statistic, the idea that rank tests assume nothing, and the conclusion of a rank test worded in terms of means.

10 corrected exercises • 100 points • 150 minutes

This chapter is part of 360-301, every chapter with its set and sheet Before you start Revision sheet: the traps and the method for this chapter

Self-checking set Type your answers and check them question by question: the page tells you right or wrong before you open the solution. With an account, every answer right on the first try earns points, and your right answers stay filled in when you come back.

Course recap

  • • Ranks are insensitive to the size of the gaps: replacing 40 with 400 changes no rank.
  • • Ties: the AVERAGE rank of the positions occupied. The sum of all ranks must equal N(N+1)2\dfrac{N(N+1)}{2}.
  • • MANN-WHITNEY, two independent groups: Uj=Rj−nj(nj+1)2U_{j}=R_{j}-\dfrac{n_{j}\left(n_{j}+1\right)}{2}, with U1+U2=n1n2U_{1}+U_{2}=n_{1}n_{2}. Reject if the smaller UU is LESS THAN OR EQUAL TO the critical value.
  • • Un1n2\dfrac{U}{n_{1}n_{2}} is the probability of superiority: the share of pairs in which one group exceeds the other. It is the effect size to report.
  • • WILCOXON, paired samples: rank the ∣di∣\left|d_{i}\right|, then add up the ranks of the positive and of the negative differences. W++W−=n(n+1)2W^{+}+W^{-}=\dfrac{n(n+1)}{2}. It assumes SYMMETRY of the differences.
  • • KRUSKAL-WALLIS, kk groups: H=12N(N+1)∑Rj2nj−3(N+1)H=\dfrac{12}{N(N+1)}\sum \dfrac{R_{j}^{2}}{n_{j}}-3\left(N+1\right), compared with a chi-square distribution with k−1k-1 degrees of freedom. An OMNIBUS test.
  • • SPEARMAN: rs=1−6∑di2n(n2−1)r_{s}=1-\dfrac{6\sum d_{i}^{2}}{n\left(n^{2}-1\right)}, where did_{i} is the difference between the two ranks. It measures MONOTONICITY, not linearity.
  • • SIGN TEST: binomial distribution with parameters nn and 0.50.5. It assumes only independence, and it ignores the size of the differences.
  • • Efficiency of Mann-Whitney relative to the t test: 3π≈0.955\dfrac{3}{\pi}\approx 0.955 under the normal distribution, that is 4.7% more observations; it EXCEEDS 1 for heavy-tailed distributions.
  • • All these tests assume INDEPENDENCE, and most of them assume that the distributions being compared have the same SHAPE.
  • • A rank test gives no estimate in the original unit: you must report medians, quartiles and a probability of superiority.

Part A: the basics (/50)

Exercise 1: Why switch to ranks

Parametric tests assume a shape for the distribution. When that assumption is untenable, you replace the values by their RANKS and test on those: that is the whole idea of nonparametric methods.

  • a) Name three situations in which ranks are called for.
  • b) Replace the values 12, 15, 9, 40, 11 by their ranks, then start over after changing 40 to 400. What do you observe?
  • c) Which assumption do rank tests keep all the same?
  • d) On which measurement scale is a rank test required, and why is the t test an abuse there?
  • e) How are ties handled?

Type your answers, the page tells you right or wrong 0/15

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) Ordinal variable, small nonnormal samples, presence of extreme values
  • b) Ranks 33, 44, 11, 55, 22 in both cases; the mean goes from 17.417.4 to 89.489.4
  • c) Independence, always; and, most often, equal SHAPES of the distributions compared
  • d) On the ordinal scale: a mean there assumes comparable gaps that nothing guarantees
  • e) Average rank of the positions occupied; the total stays N(N+1)2\dfrac{N(N+1)}{2}
a)

First situation, an ORDINAL variable: a satisfaction rating, a ranking, a coded level of education. Second situation, SMALL SAMPLES combined with a clearly nonnormal distribution: below about thirty observations per group, the central limit theorem no longer saves you. Third situation, the presence of EXTREME VALUES: a single outlier can move a mean by several standard deviations, while it moves a rank by only one place.

b)

Ranks of 12, 15, 9, 40, 11: 33, 44, 11, 55, 22. Changing 40 to 400 gives exactly the same ranks: 33, 44, 11, 55, 22. The mean, on the other hand, goes from 17.4 to 89.4. This is the central property of ranks: they are INSENSITIVE to the size of the gaps and keep only the order, which makes them robust and, at the same time, less informative.

c)

They keep the assumption of INDEPENDENCE of the observations, which is never negotiable, and most of them also assume that the distributions being compared have the SAME SHAPE, differing only in location. Without that last assumption, a rejection by Mann-Whitney does not necessarily translate into a difference of medians: it only indicates that an observation from one group tends to exceed an observation from the other.

d)

On an ORDINAL scale. The t test compares means, and a mean assumes that the gaps between successive values are comparable, which an ordinal scale does not guarantee: nothing says that the gap between “disagree” and “neutral” equals the one between “neutral” and “agree”. Computing a mean there is therefore a convention, and testing it as if it were a quantity is an abuse. Ranks use only the order, which is exactly the information the scale contains.

e)

Each tied value receives the AVERAGE RANK of the positions it occupies. Three equal observations in positions 4, 5 and 6 each receive the rank 4+5+63=5\dfrac{4+5+6}{3}=5. The total of the ranks therefore stays N(N+1)2\dfrac{N(N+1)}{2}, which is the check to make. If there are many ties, the variance of the ranks decreases and a correction must be applied to the formulas, otherwise the test becomes too conservative.

Tick the exercises you have done or want to review: a free account, no password, keeps your ticks and your right answers from one visit to the next, tells you which chapter to tackle next and lets you ask for the exercise you are missing. Create your space, an email is enough.

Exercise 2: The Mann-Whitney test

The nonparametric counterpart of the t test for two independent groups. You pool the two groups, rank everything, and look at whether one group systematically occupies the high ranks.

Group A, 6 students: 12, 15, 17, 21, 24, 30. Group B, 7 students: 9, 11, 14, 16, 19, 22, 26.

  • a) Rank the thirteen values and give the rank of each.
  • b) Compute the rank sums RAR_{A} and RBR_{B}, and check their total.
  • c) Compute UA=RA−nA(nA+1)2U_{A}=R_{A}-\dfrac{n_{A}\left(n_{A}+1\right)}{2} and UBU_{B}, then check that UA+UB=nAnBU_{A}+U_{B}=n_{A}n_{B}.
  • d) The critical value of UU for nA=6n_{A}=6 and nB=7n_{B}=7 is 6 at the two-sided 5% level. Conclude.
  • e) What does the retained value of UU mean in concrete terms?

Type your answers, the page tells you right or wrong 0/15

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) Ranks 11 to 1313: B occupies 11, 22, 44, 66, 88, 1010, 1212 and A the odd ranks from 33 on
  • b) RA=48R_{A}=48, RB=43R_{B}=43, total 91=13×14291=\dfrac{13\times 14}{2}
  • c) UA=27U_{A}=27, UB=15U_{B}=15, and 27+15=42=6×727+15=42=6\times 7
  • d) Keep U=15U=15; since 15>615>6, do not reject
  • e) Out of the 4242 pairs, 1515 favour B and 2727 favour A, that is 64%64\% against the 50%50\% expected
a)

In increasing order, with the group in parentheses: 9 (B) rank 1, 11 (B) rank 2, 12 (A) rank 3, 14 (B) rank 4, 15 (A) rank 5, 16 (B) rank 6, 17 (A) rank 7, 19 (B) rank 8, 21 (A) rank 9, 22 (B) rank 10, 24 (A) rank 11, 26 (B) rank 12, 30 (A) rank 13.

b)

RA=3+5+7+9+11+13=48R_{A}=3+5+7+9+11+13=48. RB=1+2+4+6+8+10+12=43R_{B}=1+2+4+6+8+10+12=43. Total: 48+43=9148+43=91, which must equal N(N+1)2=13×142=91\dfrac{N(N+1)}{2}=\dfrac{13\times 14}{2}=91. The check passes, which guarantees that no rank was forgotten or counted twice.

c)

UA=48−6×72=48−21=27U_{A}=48-\dfrac{6\times 7}{2}=48-21=27. UB=43−7×82=43−28=15U_{B}=43-\dfrac{7\times 8}{2}=43-28=15. Check: 27+15=42=6×7=nAnB27+15=42=6\times 7=n_{A}n_{B}. This identity is automatic and serves as a second safeguard.

d)

Keep the SMALLER of the two, U=15U=15. The decision rule of rank tests is reversed compared with parametric tests: you reject when the statistic is LESS THAN OR EQUAL TO the critical value. Since 15>615>6, you do not reject: the data do not allow us to conclude that the two groups differ at the 5% level.

e)

UB=15U_{B}=15 means that, among the 42 possible pairs made of one member of A and one member of B, there are 15 in which the member of B exceeds the member of A. Under the null hypothesis you would expect half of them, that is 21. So we observe a slight advantage for group A, 27 pairs out of 42, or 64%: real but far too weak for thirteen observations. It is this reading in terms of pairs that gives the test its meaning, and it is directly tied to the probability that a member drawn at random from A exceeds a member drawn at random from B.

12345678910111213BBABABABABABArank of each observation, group A on top

Exercise 3: The Wilcoxon signed-rank test

The nonparametric counterpart of the paired t test. You compute the individual differences, rank their ABSOLUTE VALUES, then give each rank back the sign of its difference.

Eight students, differences (after minus before): +4+4, −1-1, +6+6, +3+3, +5+5, −2-2, +7+7, +9+9.

  • a) Rank the absolute values of the eight differences.
  • b) Compute W+W^{+}, the sum of the ranks of the positive differences, and W−W^{-}. Check their total.
  • c) The critical value for n=8n=8 is 3 at the two-sided 5% level. Conclude.
  • d) What do you do with a difference of zero?
  • e) In what way is this test more informative than the simple sign test?

Type your answers, the page tells you right or wrong 0/12

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) Ranks of the absolute values: 11 for −1-1, 22 for −2-2, then 33 to 88 for the positive ones
  • b) W+=33W^{+}=33, W−=3W^{-}=3, total 36=8×9236=\dfrac{8\times 9}{2}
  • c) W=3≤3W=3\le 3: only just rejected at the 5%5\% level
  • d) Exclude it and reduce nn, which changes the critical value; the essential thing is to say so
  • e) It uses the ranks of the sizes, not only the signs; the price is the symmetry assumption
a)

Absolute values: 4, 1, 6, 3, 5, 2, 7, 9. Sorted: 1, 2, 3, 4, 5, 6, 7, 9, which gives the ranks 1 to 8 in that order. So rank 1 for the difference −1-1, rank 2 for −2-2, rank 3 for +3+3, rank 4 for +4+4, rank 5 for +5+5, rank 6 for +6+6, rank 7 for +7+7, rank 8 for +9+9.

b)

W+=3+4+5+6+7+8=33W^{+}=3+4+5+6+7+8=33. W−=1+2=3W^{-}=1+2=3. Total: 33+3=3633+3=36, which must equal n(n+1)2=8×92=36\dfrac{n(n+1)}{2}=\dfrac{8\times 9}{2}=36. The check passes.

c)

Keep the smaller one, W=3W=3. The rule is to reject if W≤WcritW\le W_{crit}: since 3≤33\le 3, you only just REJECT the null hypothesis at the 5% level. The observed improvement is therefore significant, by the narrowest of margins. Note that strict equality is enough to reject, which is not obvious and is read from the definition of the critical value: it is the largest WW whose cumulative probability does not exceed 2.5% on each side.

d)

A difference of zero can receive neither a sign nor a useful rank: the dominant practice is to EXCLUDE it and reduce nn accordingly, which changes the critical value. A more conservative variant splits the zeros between the two camps. What matters is to say what you did: with small samples, excluding two zeros out of ten noticeably changes the threshold.

e)

The SIGN test looks only at the direction of each difference, plus or minus, and ignores their size: on our data it would see six pluses and two minuses, without knowing that the two negative differences are the smallest of all. Wilcoxon, by ranking the absolute values, takes this extra information into account and becomes markedly more powerful. The price is one more assumption: the distribution of the differences must be approximately SYMMETRIC about its median, otherwise the ranks of the positive and negative differences are not comparable.

4+41−16+63+35+52−27+78+9rank of each absolute difference, sign shown by colour

Exercise 4: The Kruskal-Wallis test

The nonparametric counterpart of one-way analysis of variance, for kk independent groups. Same principle: rank everything and compare the rank sums.

Three groups of four. A: 22, 25, 28, 31. B: 18, 20, 24, 27. C: 12, 15, 17, 21.

  • a) Rank the twelve values and give the three rank sums.
  • b) Check that the total equals N(N+1)2\dfrac{N(N+1)}{2}.
  • c) Compute H=12N(N+1)∑Rj2nj−3(N+1)H=\dfrac{12}{N(N+1)}\sum \dfrac{R_{j}^{2}}{n_{j}}-3\left(N+1\right).
  • d) HH approximately follows a chi-square distribution with k−1k-1 degrees of freedom. Conclude at the 5% level.
  • e) After rejecting, how do you identify the groups that differ?

Type your answers, the page tells you right or wrong 0/13

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) RA=39R_{A}=39, RB=27R_{B}=27, RC=12R_{C}=12
  • b) 39+27+12=78=12×13239+27+12=78=\dfrac{12\times 13}{2}
  • c) H=12156×598.5−39≈7.038H=\dfrac{12}{156}\times 598.5-39\approx 7.038
  • d) df=2df=2 and 7.038>5.9917.038>5.991: reject, p-value close to 0.0300.030
  • e) By pairwise Mann-Whitney tests, at the Bonferroni threshold 0.053≈0.0167\dfrac{0.05}{3}\approx 0.0167
a)

Increasing order: 12 (C) 1, 15 (C) 2, 17 (C) 3, 18 (B) 4, 20 (B) 5, 21 (C) 6, 22 (A) 7, 24 (B) 8, 25 (A) 9, 27 (B) 10, 28 (A) 11, 31 (A) 12. Sums: RA=7+9+11+12=39R_{A}=7+9+11+12=39; RB=4+5+8+10=27R_{B}=4+5+8+10=27; RC=1+2+3+6=12R_{C}=1+2+3+6=12.

b)

39+27+12=7839+27+12=78, and 12×132=78\dfrac{12\times 13}{2}=78. The check passes. Notice the order of the sums: A occupies the high ranks, C the low ranks, which the test is going to formalize.

c)

∑Rj2nj=3924+2724+1224=1,521+729+1444=2,3944=598.5\sum \dfrac{R_{j}^{2}}{n_{j}}=\dfrac{39^{2}}{4}+\dfrac{27^{2}}{4}+\dfrac{12^{2}}{4}=\dfrac{1{,}521+729+144}{4}=\dfrac{2{,}394}{4}=598.5. Then H=1212×13×598.5−3×13=12156×598.5−39=0.076923×598.5−39=46.038−39≈7.038H=\dfrac{12}{12\times 13}\times 598.5-3\times 13=\dfrac{12}{156}\times 598.5-39=0.076923\times 598.5-39=46.038-39\approx 7.038.

d)

Degrees of freedom: k−1=2k-1=2. The chi-square critical value is 5.991 at the 5% level. Since 7.038>5.9917.038>5.991, you REJECT: at least one of the three groups differs from the others. The p-value is about 0.030. A customary caveat: the chi-square approximation assumes at least five observations per group, and we have only four; software would use the exact distribution of HH here, and the conclusion might be a little less clear-cut.

e)

Exactly as after an analysis of variance: by pairwise comparisons, here Mann-Whitney tests, with a correction of the threshold for the number of comparisons. With three groups, three comparisons, hence a Bonferroni threshold of 0.053≈0.0167\dfrac{0.05}{3}\approx 0.0167. With such small samples, no pairwise comparison will reach that threshold: the overall test detects a general trend that the individual comparisons lack the power to locate, a common situation that you must know how to report rather than hide.

Exercise 5: Spearman's coefficient

The nonparametric counterpart of Pearson's correlation. You replace each variable by its ranks and compute the correlation of those ranks, which amounts to measuring MONOTONICITY rather than linearity.

12345678910612182430364248rank of the explanatory variablemonotonic, nonlinear relationship
  • a) State the formula rs=1−6∑di2n(n2−1)r_{s}=1-\dfrac{6\sum d_{i}^{2}}{n\left(n^{2}-1\right)} and say what did_{i} is.
  • b) Eight students have mathematics ranks 1 to 8 and French ranks 2, 1, 4, 3, 6, 5, 8, 7. Compute rsr_{s}.
  • c) What would rsr_{s} equal if the two rankings coincided exactly? If they were exactly reversed?
  • d) On the graph, the relationship is perfectly increasing but curved. What are Spearman's and Pearson's coefficients, respectively?
  • e) In which cases is Spearman preferable to Pearson?

Type your answers, the page tells you right or wrong 0/13

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) did_{i} is the gap between the two ranks of the same observation; with ties, use Pearson on the ranks
  • b) ∑di2=8\sum d_{i}^{2}=8, so rs=1−48504≈0.905r_{s}=1-\dfrac{48}{504}\approx 0.905
  • c) +1+1 if the rankings coincide, −1-1 if they are exactly reversed
  • d) Spearman is 11, Pearson about 0.900.90: monotonicity versus linearity
  • e) Monotonic nonlinear relationship, extreme values, and mandatorily when a variable is ordinal
a)

did_{i} is the difference between the two ranks of the same observation: its rank on the first variable minus its rank on the second. The formula assumes there are no ties; with ties, you compute Pearson's coefficient directly ON THE RANKS, which gives the same result when there are no ties and remains correct when there are.

b)

Differences: 1−2=−11-2=-1; 2−1=12-1=1; 3−4=−13-4=-1; 4−3=14-3=1; 5−6=−15-6=-1; 6−5=16-5=1; 7−8=−17-8=-1; 8−7=18-7=1. Squares: eight times 1, so ∑di2=8\sum d_{i}^{2}=8. Then rs=1−6×88×(64−1)=1−48504=1−0.095238≈0.905r_{s}=1-\dfrac{6\times 8}{8\times \left(64-1\right)}=1-\dfrac{48}{504}=1-0.095238\approx 0.905. The two rankings are therefore in very strong agreement, which you can see by eye since each student moves by only one rank.

c)

If they coincided exactly, all the did_{i} would be zero and rs=1r_{s}=1. If they were exactly reversed, we would have ∑di2=n(n2−1)3\sum d_{i}^{2}=\dfrac{n\left(n^{2}-1\right)}{3}, here 8×633=168\dfrac{8\times 63}{3}=168, so rs=1−6×168504=1−2=−1r_{s}=1-\dfrac{6\times 168}{504}=1-2=-1. The coefficient therefore does range between −1-1 and +1+1, like Pearson's.

d)

Since the relationship is strictly increasing, the ranks match perfectly and rs=1r_{s}=1 exactly. Pearson's coefficient, for its part, is only about 0.90, because it measures the fit to a LINE and the relationship is exponential. That is the essential difference between the two: Spearman reaches 1 as soon as the relationship is monotonic, whatever its shape, whereas Pearson requires linearity.

e)

First case, when the relationship is monotonic but NONLINEAR: Spearman recognizes it for what it is, Pearson underestimates it. Second case, in the presence of EXTREME VALUES: a single point far away can take a Pearson coefficient from 0.2 to 0.8 or the reverse, while it moves a rank by only one place. We add a third case, a mandatory one: when at least one of the two variables is ORDINAL, Pearson's coefficient simply makes no sense.

12345678910612182430364248rank of the explanatory variablemonotonic, nonlinear relationshipSpearman: 1; Pearson: 0.90

Part B: problems and reasoning (/50)

Exercise 6: What ranks cost

Rank tests demand less and give less. The practical question is exactly how much, and the answer depends on the shape of the distribution.

  • a) Under a normal distribution, the relative efficiency of Mann-Whitney with respect to the t test is 3π\dfrac{3}{\pi}. Compute it and translate it into a sample size.
  • b) What does this efficiency become if the distribution has heavy tails?
  • c) A researcher systematically uses rank tests “to be safe”. What do you tell them?
  • d) Is a rank test on 200 observations per group necessary?
  • e) What information does a rank test never provide, and how do you make up for it?

Type your answers, the page tells you right or wrong 0/11

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) 3π≈0.955\dfrac{3}{\pi}\approx 0.955, that is about 4.7%4.7\% more observations
  • b) It EXCEEDS 1: the rank test becomes more powerful than the t test
  • c) That caution has a low cost but changes the question: Mann-Whitney does not test the mean
  • d) No if the only worry is normality; yes if the median describes the distribution better
  • e) An estimate in the original unit; publish the difference of medians or the probability of superiority
a)

3π=33.14159≈0.955\dfrac{3}{\pi}=\dfrac{3}{3.14159}\approx 0.955. Translated into sample size: to reach the same power as the t test, you need about 10.955≈1.047\dfrac{1}{0.955}\approx 1.047 times as many observations, that is 4.7% more. With 100 subjects per group, you would need 105: the cost is almost nil, while the rank test requires no assumption of normality. That is remarkable value for money, and it is why many methodologists now recommend ranks by default.

b)

It EXCEEDS 1, often by a wide margin: for heavy-tailed distributions, where extreme values are frequent, the efficiency can reach 1.5 and more. In other words, the rank test becomes MORE powerful than the t test, because the mean and the standard deviation are themselves strongly disturbed by extreme values, whereas ranks absorb them. The parametric test is optimal only in the precise case for which it was built.

c)

That caution has a low cost but it is not free, and above all that it changes the question being asked. A t test compares MEANS; Mann-Whitney compares the tendency of one group to exceed the other, which amounts to comparing medians only if the two distributions have the same shape. On data where the mean is the quantity the decision maker cares about, a total income, an expense, you have to test the mean itself. The reasonable rule is: ranks when the variable is ordinal, when the samples are small, or when extremes dominate; otherwise, a parametric test with a check of the residuals.

d)

Generally not, if the only worry is normality: with 200 observations per group, the sampling distribution of the mean is normal by the central limit theorem, whatever the shape of the variable. The t test is then perfectly valid. A rank test remains useful for another reason: if the distribution is very skewed, the MEDIAN may be a much better description than the mean, and you then choose ranks out of relevance and not out of caution.

e)

A rank test never provides an ESTIMATE of the size of the effect in the original unit: it does not say by how many points the groups differ. You make up for it by reporting alongside a readable measure, the difference of medians with its confidence interval, obtained by the Hodges-Lehmann method, or a rank-based effect size, such as the probability that an observation from one group exceeds an observation from the other, which is read directly from UU. Without that, you publish a decision with no quantity, which is the same flaw as publishing a p-value alone.

0.955normal1uniform1.5heavy tailsefficiency of Mann-Whitney relative to the t test

Exercise 7: The sign test and the median

The simplest of the nonparametric tests uses only the SIGN of each difference. It assumes nothing at all, not even symmetry, and it is computed by hand with a binomial distribution.

Fifteen students are measured before and after a workshop: twelve improve, three get worse.

  • a) State the null hypothesis in terms of probability.
  • b) Under this hypothesis, what distribution does the number of improvements follow?
  • c) Given that the numbers of ways of obtaining 12, 13, 14 and 15 improvements are 455, 105, 15 and 1, compute the two-sided p-value.
  • d) Conclude at the 5% level.
  • e) Compare this test with Wilcoxon's on the same data.

Type your answers, the page tells you right or wrong 0/12

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) H0H_{0}: the probability of improving is 0.50.5, so the median of the differences is zero
  • b) A binomial distribution with parameters n=15n=15 and p=0.5p=0.5
  • c) 57632,768≈0.0176\dfrac{576}{32{,}768}\approx 0.0176 one-sided, so 0.03520.0352 two-sided
  • d) 0.0352<0.050.0352<0.05: reject; the conclusion concerns the DIRECTION, never the size
  • e) Wilcoxon adds the ranks of the sizes, so it gains power, at the price of the symmetry assumption
a)

H0H_{0}: the probability that a student improves is 0.50.5, in other words the median of the individual differences is zero and the direction of the change is a pure coin toss. The two-sided alternative hypothesis is that this probability differs from 0.5.

b)

The number of improvements follows a BINOMIAL distribution with parameters n=15n=15 and p=0.5p=0.5, since the fifteen students are independent and each has the same probability of improving under the null hypothesis.

c)

Total number of possible outcomes: 215=32,7682^{15}=32{,}768. Number of outcomes giving 12 improvements or more: 455+105+15+1=576455+105+15+1=576. One-sided probability: 57632,768≈0.017578\dfrac{576}{32{,}768}\approx 0.017578. By symmetry of the distribution for p=0.5p=0.5, the two-sided p-value is twice that: 2×0.017578≈0.0351562\times 0.017578\approx 0.035156.

d)

0.0352<0.050.0352<0.05: you REJECT the null hypothesis. The number of improvements is too high to be attributed to the luck of the direction of the changes, and you conclude that the median of the differences is positive. It must be made clear that the conclusion concerns the DIRECTION and not the size: the test completely ignores by how much each student improved.

e)

The sign test uses only twelve pluses and three minuses. Wilcoxon would also use the ranks of the sizes, extra information that makes it more powerful: on data where the improvements are large and the declines tiny, Wilcoxon will reject where the sign test hesitates. In return, Wilcoxon assumes SYMMETRY of the distribution of the differences, whereas the sign test assumes nothing. The choice therefore rests on that assumption: if symmetry is plausible, take Wilcoxon; if the distribution is clearly skewed, fall back on the sign test and accept the loss of power.

Exercise 8: Five statements to correct

Each of the following five statements is FALSE. Say why and give the correct statement.

  • 1) “Nonparametric tests assume nothing: you can therefore use them on any data.”
  • 2) “Our UU is 15 and the critical value is 6: since 15 exceeds 6, the result is significant.”
  • 3) “Spearman's coefficient is 1, so the relationship between the two variables is a perfect line.”
  • 4) “Ranks lose so much information that a nonparametric test is always markedly less powerful.”
  • 5) “Kruskal-Wallis rejects: the three groups therefore differ pairwise.”

Type your answers, the page tells you right or wrong 0/11

1)
2)
3)
4)
5)
Show the solution

Answers

  • 1) FALSE: independence is always required, and most tests assume identical shapes
  • 2) FALSE: the rule is reversed; 15>615>6, so you do NOT reject
  • 3) FALSE: Spearman measures monotonicity; it is 1 on an exponential where Pearson is 0.900.90
  • 4) FALSE: 3π≈0.955\dfrac{3}{\pi}\approx 0.955 under the normal, and the efficiency exceeds 1 for heavy tails
  • 5) FALSE: Kruskal-Wallis is omnibus; follow up with corrected pairwise comparisons
1)

FALSE. They all assume INDEPENDENCE of the observations, an assumption that is never negotiable. Most also assume equal SHAPES of the distributions compared, and Wilcoxon requires symmetry of the differences. Correct statement: they do without the assumption of NORMALITY, which is already a lot, but they do not do without every assumption.

2)

FALSE, the rule is reversed for the statistic UU. You reject when UU is LESS THAN OR EQUAL TO the critical value, because a small UU means that one group monopolizes the high ranks. With U=15U=15 against a critical value of 6, you do not reject. Correct statement: the data do not allow us to conclude that the two groups differ.

3)

FALSE. Spearman measures MONOTONICITY, not linearity: it equals 1 as soon as the relationship is strictly increasing, whether it is a line, an exponential or a logarithm. On the exponential scatter plot of the chapter, Spearman is 1 and Pearson about 0.90. Correct statement: the two rankings coincide perfectly, so the relationship is strictly increasing; its shape remains to be examined on the scatter plot.

4)

FALSE. Under a normal distribution, the efficiency of Mann-Whitney relative to the t test is 3π≈0.955\dfrac{3}{\pi}\approx 0.955, that is 4.7% more observations for the same power. And for heavy-tailed distributions, it EXCEEDS 1. Correct statement: the loss of power is very small in the case most favourable to the parametric test, and it becomes a gain as soon as extreme values are frequent.

5)

FALSE, exactly as for analysis of variance. Kruskal-Wallis is an OMNIBUS test: it indicates that at least one group stands out, without saying which. Correct statement: you must follow up with pairwise comparisons, Mann-Whitney tests with a corrected threshold, and it often happens that none is significant even though the overall test was.

Exercise 9: Problem: a Likert scale on two small groups

Two groups rate the clarity of a course on a scale from 1 to 7. Guided group, 7 students: 5, 6, 4, 7, 6, 5, 7. Self-directed group, 6 students: 3, 5, 4, 2, 4, 6.

  • a) Justify the choice of a nonparametric test.
  • b) Rank the thirteen values, handling the ties correctly.
  • c) Compute the rank sums and the two UU values.
  • d) The critical value for 7 and 6 is 6 at the two-sided 5% level. Conclude.
  • e) What effect size should be published alongside the test?

Type your answers, the page tells you right or wrong 0/19

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) Ordinal variable, sample sizes of 7 and 6, and bounding at 7 producing a mechanical skew
  • b) Average ranks: each 44 gets 44, each 55 gets 77, each 66 gets 1010, each 77 gets 12.512.5
  • c) RG=63R_{G}=63 and RS=28R_{S}=28; UG=35U_{G}=35 and US=7U_{S}=7, summing to 4242
  • d) U=7>6U=7>6: do not reject, but only just; the exact p-value is about 0.0620.062
  • e) Medians 66 and 44, and probability of superiority 3542≈0.833\dfrac{35}{42}\approx 0.833
a)

Three reasons add up. The variable is ORDINAL, a seven-level Likert scale: nothing guarantees that the gap between 4 and 5 equals the one between 6 and 7. The SAMPLE SIZES are very small, 7 and 6, so the central limit theorem does not apply. Finally the variable is BOUNDED at 7, which produces a mechanical skew as soon as responses bunch up toward the top, as they do in the guided group.

b)

Values sorted with their groups: 2 (S), 3 (S), 4 (G), 4 (S), 4 (S), 5 (G), 5 (G), 5 (S), 6 (G), 6 (G), 6 (S), 7 (G), 7 (G). The three 4s occupy positions 3, 4 and 5, so each receives the average rank 4. The three 5s occupy 6, 7 and 8, average rank 7. The three 6s occupy 9, 10 and 11, average rank 10. The two 7s occupy 12 and 13, average rank 12.5. Final ranks: 2 gets 1; 3 gets 2; each 4 gets 4; each 5 gets 7; each 6 gets 10; each 7 gets 12.5.

c)

Guided group: one 4, two 5s, two 6s, two 7s, that is 4+7+7+10+10+12.5+12.5=634+7+7+10+10+12.5+12.5=63. Self-directed group: one 2, one 3, two 4s, one 5, one 6, that is 1+2+4+4+7+10=281+2+4+4+7+10=28. Check: 63+28=91=13×14263+28=91=\dfrac{13\times 14}{2}. Then UG=63−7×82=63−28=35U_{G}=63-\dfrac{7\times 8}{2}=63-28=35 and US=28−6×72=28−21=7U_{S}=28-\dfrac{6\times 7}{2}=28-21=7. Check: 35+7=42=7×635+7=42=7\times 6.

d)

Keep U=7U=7. Since 7>67>6, you do NOT reject at the 5% level, but only just. The data strongly suggest that the guided group finds the course clearer, without thirteen observations being enough to establish it. The honest write-up is to give the exact p-value, here about 0.062 (exact permutation of the ranks, ties included), rather than flatly concluding there is no difference. The normal approximation corrected for ties gives 0.042 and would reject, but it is unreliable with 7 and 6 observations: the exact value is the one that counts.

e)

The MEDIAN of each group, here 6 for the guided group and 4 for the self-directed one, and above all the probability that an observation from the guided group exceeds an observation from the self-directed group, which is read directly from UU: UGnGnS=3542≈0.833\dfrac{U_{G}}{n_{G}n_{S}}=\dfrac{35}{42}\approx 0.833. In other words, in five pairs out of six, the guided student finds the course clearer. This measure, called the probability of superiority, is far more telling than the raw UU statistic and it does not depend on the sample sizes.

Exercise 10: Problem: reading a methods section

Excerpt: “Because the scores were not normally distributed (Shapiro-Wilk test, p=0.03p=0.03), we used nonparametric tests. The Mann-Whitney test indicates a significant difference between the two groups (U=812U=812; p=0.021p=0.021; n1=60n_{1}=60; n2=58n_{2}=58). The groups therefore differ on average.”

  • a) Does the rejection of normality justify switching to ranks, with 60 subjects per group?
  • b) Check that the reported UU is consistent with the sample sizes, and compute the probability of superiority.
  • c) “The groups therefore differ on average”: what is wrong with this?
  • d) What is missing from this paragraph for it to be publishable?
  • e) Rewrite it.

Type your answers, the page tells you right or wrong 0/12

a)
b)
c)
d)
e)
Show the solution

Answers

  • a) No: with 6060 per group the t test is valid; and a normality test is too powerful on 118118 observations
  • b) 60×58=3,48060\times 58=3{,}480, so 8123,480≈0.233\dfrac{812}{3{,}480}\approx 0.233, or 0.7670.767 the other way round
  • c) Mann-Whitney does not test means, and the author concludes about what had just been set aside
  • d) The medians and quartiles, an effect size, the real reason for the choice, and the direction of the test
  • e) Name the reason for the choice, conclude in the terms the test allows, and give a quantity
a)

No, not automatically. With 60 subjects per group, the sampling distribution of the mean is normal by the central limit theorem, whatever the shape of the variable: the t test would be valid. Moreover, a normality test becomes very powerful as nn grows and then detects departures of no practical importance: on 118 observations, a pp of 0.03 may correspond to a tiny deviation. The decision should therefore rest on a plot of the residuals and on the question being asked, not on a normality test. That said, if the variable is ordinal or very skewed, the choice of ranks remains defensible, for reasons other than the one given.

b)

The product n1n2=60×58=3,480n_{1}n_{2}=60\times 58=3{,}480, and UU must lie between 0 and 3,480: the value 812 is therefore plausible. The probability of superiority is 8123,480≈0.233\dfrac{812}{3{,}480}\approx 0.233, or its complement 2,6683,480≈0.767\dfrac{2{,}668}{3{,}480}\approx 0.767 depending on the direction chosen: in about three pairs out of four, a member of the second group exceeds a member of the first. This reading is far more informative than the p-value.

c)

Two criticisms. Mann-Whitney does NOT test means: it tests the tendency of one group to produce higher values, which translates into medians only if the two distributions have the same shape. And the author, who set the t test aside precisely because the distribution was not normal, comes back to conclude about the mean, which is contradictory. Correct statement: the values of the second group tend to exceed those of the first.

d)

It lacks the MEDIANS and quartiles of each group, so the reader knows the order of magnitude of the gap; an effect size, the probability of superiority or the difference of medians with its interval; the real justification for the choice of ranks, the nature of the variable rather than the result of a normality test; and the direction of the test, two-sided or one-sided. A p-value and a UU statistic alone allow neither judging nor reproducing.

e)

“Because the variable is an ordinal scale and its distribution is strongly skewed, we compared the two groups with a two-sided Mann-Whitney test. The values of group 2 tend to exceed those of group 1, U=812U=812; n1=60n_{1}=60; n2=58n_{2}=58; p=0.021p=0.021. The medians are 4 and 5 respectively, with interquartile ranges of 2 in both groups, and the probability that an observation from group 2 exceeds an observation from group 1 is 0.77.” The paragraph names the real reason for the choice, states the conclusion in the terms the test allows, and finally gives the reader a quantity.

Something missing from this set? A type of exercise your teacher gives, a problem you are stuck on, a mistake you spotted: tell me, I read every request.

Sending goes through your free space: that is how I can answer you and tell you when the exercise is added. An email is enough, no password. Create your space. Rather not create an account? Write to me directly.

What is it about?
I read every request myself, nobody else sees it. No need to write your name or your school.
When your request is dealt with, you hear about it by email and in your space.

By sending, you agree that I read your request to answer it. It is kept with your account, erased with it, and never published: privacy policy.

Previous chapter Multiple regression, 360-301 Next chapter Time series and forecasting, 360-301

© Ahmed Squalli Houssaini. Exercise set published at www.letuteurscientifique.ca/en/exercices/cegep-aqm-nonparametric-tests. Free for personal and classroom use; republishing it elsewhere requires written permission (legal notice).

See also

Looking for a statistics tutor in Montreal?

Get in touch for a first session. 360-301 arrives just as the end-of-program research project begins, and it is the course where a method error costs you the whole analysis chapter.

Site by Studio Squalli