Nonparametric Tests: Larson/Farber 4th Ed
Nonparametric Tests: Larson/Farber 4th Ed
Nonparametric Tests
Larson/Farber 4th ed 1
Chapter Outline
Larson/Farber 4th ed 2
Section 11.1
Larson/Farber 4th ed 3
Section 11.1 Objectives
Larson/Farber 4th ed 4
Nonparametric Test
Nonparametric test
• A hypothesis test that does not require any specific
conditions concerning the shape of the population or
the value of any population parameters.
• Generally easier to perform than parametric tests.
• Usually less efficient than parametric tests (stronger
evidence is required to reject the null hypothesis).
Larson/Farber 4th ed 5
Sign Test for a Population
Median
Sign Test
• A nonparametric test that can be used to test a
population median against a hypothesized value k.
• Left-tailed test:
H0: median k and Ha: median < k
• Right-tailed test:
H0: median k and Ha: median > k
• Two-tailed test:
H0: median = k and Ha: median k
Larson/Farber 4th ed 6
Sign Test for a Population
Median
• To use the sign test, each entry is compared with the
hypothesized median k.
If the entry is below the median, a sign is
assigned.
If the entry is above the median, a + sign is
assigned.
If the entry is equal to the median, 0 is assigned.
• Compare the number of + and – signs.
Larson/Farber 4th ed 7
Sign Test for a Population
Median
Test Statistic for the Sign Test
• When n 25, the test statistic x for the sign test is the
smaller number of + or signs.
• When n > 25, the test statistic for the sign test is
(x 0.5) 0.5n
z
n
2
where x is the smaller number of + or signs and n is
the sample size (the total number of + or signs).
Larson/Farber 4th ed 8
Performing a Sign Test for a
Population Median
In Words In Symbols
1. State the claim. Identify the State H0 and Ha.
null and alternative hypotheses.
2. Specify the level of Identify .
significance.
3. Determine the sample size n by n = total number
assigning + signs and – signs to of + and – signs
the sample data.
4. Determine the critical value. If n 25, use Table 8.
If n > 25, use Table 4.
Larson/Farber 4th ed 9
Performing a Sign Test for a
Population Median
In Words In Symbols
5. Calculate the test statistic. If n 25, use x.
If n > 25, use
(x 0.5) 0.5n
z
n
2
6. Make a decision to reject or If the test statistic is
fail to reject the null less than or equal to
hypothesis. the critical value,
reject H0. Otherwise,
7. Interpret the decision in the
fail to reject H0.
context of the original claim.
Larson/Farber 4th ed 10
Example: Using the Sign Test
A bank manager claims that the median number of
customers per day is no more than 750. A teller doubts the
accuracy of this claim. The number of bank customers per
day for 16 randomly selected days are listed below. At α =
0.05, can the teller reject the bank manager’s claim?
775 765 801 742
754 753 739 751
745 750 777 769
756 760 782 789
Larson/Farber 4th ed 11
Solution: Using the Sign Test
Critical value is 3
Larson/Farber 4th ed 13
Solution: Using the Sign Test
• Test Statistic:
x = 3 (n ≤ 25; use smaller number of + or – signs)
• Decision: Reject H0
At the 5% level of significance, the teller can reject
the bank manager’s claim that the median number
of customers per day is no more than 750.
Larson/Farber 4th ed 14
Example: Using the Sign Test
A car dealership claims to give customers a median
trade-in offer of at least $6000. A random sample of 103
transactions revealed that the trade-in offer for 60
automobiles was less than $6000 and the trade-in offer
for 40 automobiles was more than $6000. At α = 0.01,
can you reject the dealership’s claim?
Larson/Farber 4th ed 15
Solution: Using the Sign Test
• H0: median ≥ 6000 • Test Statistic:
• Ha: median < 6000 There are 60 – signs
and 40 + signs.
• α = 0.01
n = 60 + 40 = 100
• Critical value: n > 25 x = 40
(40 0.5) 0.5(100)
z 1.9
0.01 100
2
z
-2.33 0 • Decision: Fail to Reject H0
-1.9 At the 1% level of
significance you cannot
reject the dealership’s claim.
Larson/Farber 4th ed 16
The Paired-Sample Sign Test
Paired-sample sign test
• Used to test the difference between two population medians
when the populations are not normally distributed.
• For the paired-sample sign test to be used, the following
must be true.
1. A sample must be randomly selected from each
population.
2. The samples must be dependent (paired).
• The difference between corresponding data entries is found
and the sign of the difference is recorded.
Larson/Farber 4th ed 17
Performing The Paired-Sample Sign Test
In Words In Symbols
1. State the claim. Identify the null State H0 and Ha.
and alternative hypotheses.
2. Specify the level of significance. Identify .
3. Determine the sample size n by n = total number
finding the difference for each of + and – signs
data pair. Assign a + sign for a
positive difference, a – sign for a
negative difference, and a 0 for
no difference.
Larson/Farber 4th ed 18
Performing The Paired-Sample Sign Test
In Words In Symbols
4. Determine the critical value. Use Table 8 in
Appendix B.
5. Find the test statistic. x = lesser number
of + and – signs
6. Make a decision to reject or If the test statistic is
fail to reject the null less than or equal to
hypothesis. the critical value,
reject H0.
7. Interpret the decision in the
context of the original claim. Otherwise, fail to
reject H0.
Larson/Farber 4th ed 19
Example: Paired-Sample Sign Test
Larson/Farber 4th ed 20
Example: Paired-Sample Sign Test
Prison 1 2 3 4 5 6 7 8 9 10
Before 21 34 9 45 30 54 37 36 33 40
After 19 22 16 31 21 30 22 18 17 21
Sign + + – + + + + + + +
Solution:
• H0: The number of repeat offenders will not
decrease.
• Ha: The number of repeat offenders will decrease.
• Determine the sign of the difference between the
“before” and “after” data.
Larson/Farber 4th ed 21
Solution: Paired-Sample Sign Test
Sign + + – + + + + + + +
• α = 0.025 (one-tailed)
• n = 1 + 9 = 10
• Critical value:
Critical value is 1
Larson/Farber 4th ed 22
Solution: Paired-Sample Sign Test
Sign + + – + + + + + + +
• Test Statistic:
x = 1 (the smaller number of + or – signs)
• Decision: Reject H0
At the 2.5% level of significance, you can support
the psychologist’s claim that the number of repeat
offenders will decrease.
Larson/Farber 4th ed 23
Section 11.1 Summary
Larson/Farber 4th ed 24
Section 11.2
Larson/Farber 4th ed 25
Section 11.2 Objectives
Larson/Farber 4th ed 26
The Wilcoxon Signed-Rank Test
Larson/Farber 4th ed 27
Performing The Wilcoxon Signed-Rank
Test
In Words In Symbols
1. State the claim. Identify the null State H0 and Ha.
and alternative hypotheses.
2. Specify the level of significance. Identify .
3. Determine the sample size n,
which is the number of pairs of
data for which the difference is
not 0.
4. Determine the critical value. Use Table 9 in
Appendix B.
Larson/Farber 4th ed 28
Performing The Wilcoxon Signed-Rank
Test
In Words In Symbols
5. Calculate the test statistic ws. Headers: Sample 1,
Sample 2,
a. Complete a table using the Difference,
headers listed at the right. Absolute value,
b. Find the sum of the positive Rank, and Signed
ranks and the sum of the rank. Signed rank
negative ranks. takes on the same
sign as its
c. Select the smaller of absolute corresponding
values of the sums. difference.
Larson/Farber 4th ed 29
Performing The Wilcoxon Signed-Rank
Test
In Words In Symbols
6. Make a decision to reject or If ws is less than or
fail to reject the null equal to the critical
hypothesis. value, reject H0.
Otherwise, fail to
reject H0.
7. Interpret the decision in the
context of the original claim.
Larson/Farber 4th ed 30
Example: Wilcoxon Signed-Rank Test
Larson/Farber 4th ed 31
Solution: Wilcoxon Signed-Rank Test
• H0: There is no difference in the length of the
athletes’ workout sessions.
• Ha: There is a difference in the length of the
athletes’ workout sessions.
0.05 (two-tailed test)
• α=
10 (the difference between each data pair is not 0)
• n=
Larson/Farber 4th ed 32
Solution: Wilcoxon Signed-Rank Test
• Critical Value
Table 9
Critical value is 8
Larson/Farber 4th ed 33
Solution: Wilcoxon Signed-Rank Test
• Test Statistic:
With Without Absolute Signed
Difference Rank
music music value rank
45 38 7 7 7.5 7
38 40 -2 2 2 -2
28 33 -5 5 4.5 -4.5
39 36 3 3 3 3
41 42 -1 1 1 -1
47 41 6 6 6 6
62 54 8 8 9 9
54 47 7 7 7.5 7.5
33 28 5 5 4.5 4.5
44 35 9 9 10 10
Larson/Farber 4th ed 34
Solution: Wilcoxon Signed-Rank Test
• Test Statistic:
The sum of the negative ranks is:
-1 + (-2) + (-4.5) = -7.5
The sum of the positive ranks is:
(+3) + (+4.5) + (+6) + (+7.5) + (+7.5) + (+9) + (+10)
= 47.5
ws = 7.5 (the smaller of the absolute value of these
two sums: |-7.5| < |47.5|)
Larson/Farber 4th ed 35
Solution: Wilcoxon Signed-Rank Test
• Decision: Reject H0
At the 5% level of significance, you have enough
evidence to support the claim that music makes a
difference in the length of athletes’ workout sessions.
Larson/Farber 4th ed 36
The Wilcoxon Rank Sum Test
Wilcoxon Rank Sum Test
• A nonparametric test that can be used to determine
whether two independent samples were selected from
populations having the same distribution.
• A requirement for the Wilcoxon rank sum test is that the
sample size of both samples must be at least 10.
• n1 represents the size of the smaller sample and n2
represents the size of the larger sample.
• When calculating the sum of the ranks R, use the ranks
for the smaller of the two samples.
Larson/Farber 4th ed 37
Test Statistic for The Wilcoxon Rank Sum
Test
• Given two independent samples, the test statistic z
for the Wilcoxon rank sum test is
R R
z
R
where
R = sum of the ranks for the smaller sample,
n1 n1 n2 1 n1n2 n1 n2 1
R and R
2 12
Larson/Farber 4th ed 38
Performing The Wilcoxon Rank Sum Test
In Words In Symbols
1. State the claim. Identify the null State H0 and Ha.
and alternative hypotheses.
2. Specify the level of significance. Identify .
3. Determine the critical value(s). Use Table 4 in
Appendix B.
Larson/Farber 4th ed 39
Performing The Wilcoxon Rank Sum Test
In Words In Symbols
5. Find the sum of the ranks for the R
smaller sample.
a. List the combined data in
ascending order.
b. Rank the combined data.
c. Add the sum of the ranks for
the smaller sample.
Larson/Farber 4th ed 40
Performing The Wilcoxon Rank Sum Test
In Words In Symbols
6. Calculate the test statistic. R R
z
R
Male 58 73 94 81 78 74 66 75 97 79
Female 66 57 81 73 65 78 71 67 64 77 80 70
Larson/Farber 4th ed 42
Solution: Wilcoxon Rank Sum Test
• H0: There is no difference between the males’ and
the females’ earnings.
• Ha: There is a difference between the males’ and
the females’ earnings.
• α = 0.10 (two-tailed test)
• Rejection Region:
0.05 0.05
Z
-1. 645 0 1.645
Larson/Farber 4th ed 43
Solution: Wilcoxon Rank Sum Test
To find the values of R, μR, andR, construct a table that
shows the combined data in ascending order and the
corresponding ranks.
Ordered Sample Rank Ordered Sample Rank
data data
57 F 1 74 M 12
58 M 2 75 M 13
64 F 3 77 F 14
65 F 4 78 M 15.5
66 M 5.5 78 F 15.5
66 F 5.5 79 M 17
67 F 7 80 F 18
70 F 8 81 M 19.5
71 F 9 81 F 19.5
73 F 10.5 94 M 21
73 F 10.5 97 M 22
Larson/Farber 4th ed 44
Solution: Wilcoxon Rank Sum Test
• Because the smaller sample is the sample of males, R
is the sum of the male rankings.
R = 2 + 5.5 + 10.5 + 12 + 13 + 15.5 + 17 + 19.5 +21 + 22
= 138
• Using n1 = 10 and n2 = 12, we can find μR, andR.
n1 n1 n2 1 10 10 12 1
R 115
2 2
n1n2 n1 n2 1 (10)(12) 10 12 1
σR 15.17
12 12
Larson/Farber 4th ed 45
Solution: Wilcoxon Rank Sum Test
• H0: no difference in • Test
earnings. Statistic
R R 138 115
z
• Ha: difference in R 15.17
earnings.
• α = 0.10 1.52
Larson/Farber 4th ed 47
Section 11.3
Larson/Farber 4th ed 48
Section 11.3 Objectives
Larson/Farber 4th ed 49
The Kruskal-Wallis Test
Kruskal-Wallis test
• A nonparametric test that can be used to determine
whether three or more independent samples were
selected from populations having the same
distribution.
• The null and alternative hypotheses for the Kruskal-
Wallis test are as follows.
H0: There is no difference in the distribution of the
populations.
Ha: There is a difference in the distribution of the
populations.
Larson/Farber 4th ed 50
The Kruskal-Wallis Test
Larson/Farber 4th ed 51
The Kruskal-Wallis Test
In Words In Symbols
1. State the claim. Identify the State H0 and Ha.
null and alternative
hypotheses.
2. Specify the level of Identify .
significance.
3. Identify the degrees of d.f. = k – 1
freedom
4. Determine the critical value Use Table 6 in
and the rejection region. Appendix B.
Larson/Farber 4th ed 53
Performing a Kruskal-Wallis Test
In Words In Symbols
5. Find the sum of the ranks
for each sample.
a. List the combined data
in ascending order.
b. Rank the combined data.
12 R12 R22 Rk2
6. Calculate the test statistic. H ...
N (N 1) n1 n2 nk
3(N 1)
Larson/Farber 4th ed 54
Performing a Kruskal-Wallis Test
In Words In Symbols
7. Make a decision to reject If H is in the
or fail to reject the null rejection region,
hypothesis. reject H0.
Otherwise, fail to
reject H0.
8. Interpret the decision in
the context of the original
claim.
Larson/Farber 4th ed 55
Example: Kruskal-Wallis Test
Larson/Farber 4th ed 56
Example: Kruskal-Wallis Test
Sample Hourly Pay Rates
CA IN MD
(Sample 1) (Sample 2) (Sample 3)
40.50 33.45 49.68
44.98 40.12 44.94
47.78 38.65 48.80
43.20 35.98 49.20
37.10 35.97 40.37
49.88 4570 48.79
42.05 42.05 53.82
52.94 35.97 45.35
41.70 38.25 53.25
43.85 43.57
Larson/Farber 4th ed 57
Solution: Kruskal-Wallis Test
• H0: There is no difference in the hourly pay rates in the
three states.
• Ha: There is a difference in the hourly pay rates in the
three states.
• α = 0.01
• d.f. = k – 1 = 3 – 1 = 2
• Rejection Region:
0.01
0 χ2
9.210
Larson/Farber 4th ed 58
Solution: Kruskal-Wallis Test
The table shows the combined data listed in ascending
order and the corresponding ranks.
Ordered Ordered Ordered
Data Sample Rank Data Sample Rank Data Sample Rank
33.45 IN 1 41.70 CA 11 47.78 CA 21
35.97 IN 2.5 42.05 IN 12.5 48.79 MD 22
35.97 IN 2.5 42.05 CA 12.5 48.80 MD 23
35.98 IN 4 43.20 CA 14 49.20 MD 24
37.10 CA 5 43.57 MD 15 49.68 MD 25
38.25 IN 6 43,85 CA 16 49.88 CA 26
38.65 IN 7 44.94 MD 17 52.94 CA 27
40.12 IN 8 44.98 CA 18 53.25 MD 28
40.37 MD 9 45.35 MD 19 53.82 MD 29
40.50 CA 10 45.70 IN 20
Larson/Farber 4th ed 59
Solution: Kruskal-Wallis Test
The sum of the ranks for each sample is as follows.
R1 = 5 + 10 + 11 + 12.5 + 14 + 16 + 18 + 21 + 26 + 27
= 160.5
R2 = 1 + 2.5 + 2.5 +4 + 6 + 7 + 8 + 12.5 + 20
= 63.5
R3 = 9 + 15 + 17 + 19 + 22 + 23 + 24 + 25 + 28 + 29
= 211
12 2
R1 R2 2
R 2
H ... 3(N 1)
k
N (N 1) n1 n2 nk
Larson/Farber 4th ed 62
Section 11.4
Rank Correlation
Larson/Farber 4th ed 63
Section 11.4 Objectives
Larson/Farber 4th ed 64
The Spearman Rank Correlation
Coefficient
Spearman Rank Correlation Coefficient
• A measure of the strength of the relationship between
two variables.
• Nonparametric equivalent to the Pearson correlation
coefficient.
• Calculated using the ranks of paired sample data
entries.
• Denoted rs
Larson/Farber 4th ed 65
The Spearman Rank Correlation
Coefficient
Spearman rank correlation coefficient rs
• The formula for the Spearman rank correlation
coefficient is
6d2
rs 1
n(n 2 1)
where n is the number of paired data entries
d is the difference between the ranks of a
paired data entry.
Larson/Farber 4th ed 66
The Spearman Rank Correlation
Coefficient
• The values of rs range from -1 to 1, inclusive.
If the ranks of corresponding data pairs are
identical, rs is equal to +1.
If the ranks are in “reverse” order, rs is equal to -1.
If there is no relationship, rs is equal to 0.
• To determine whether the correlation between
variables is significant, you can perform a hypothesis
test for the population correlation coefficient ρs.
Larson/Farber 4th ed 67
The Spearman Rank Correlation
Coefficient
• The null and alternative hypotheses for this test are as
follows.
H0: ρs = 0 (There is no correlation between the
variables.)
Ha: ρs 0 (There is a significant correlation between
the variables.)
Larson/Farber 4th ed 68
Testing the Significance of the Spearman
Rank Correlation Coefficient
In Words In Symbols
1. State the null and alternative State H0 and Ha.
hypotheses.
2. Specify the level of Identify .
significance.
3. Determine the critical value. Use Table 10 in
Appendix B.
6d2
4. Find the test statistic. rs 1
n(n 2 1)
Larson/Farber 4th ed 69
Testing the Significance of the Spearman
Rank Correlation Coefficient
In Words In Symbols
5. Make a decision to reject or If |rs| is greater
fail to reject the null than the critical
hypothesis. value, reject H0.
Otherwise, fail to
reject H0.
6. Interpret the decision in the
context of the original
claim.
Larson/Farber 4th ed 70
Example: The Spearman Rank
Correlation Coefficient
The table shows the prices (in Year Beef Lamb
dollars per 100 pounds) received 1999 63.4 74.5
by U.S. farmers for beef and lamb
2000 68.6 79.8
from 1999 to 2005. At α = 0.05,
2001 71.3 66.9
can you conclude that there is a
2002 66.5 74.1
correlation between the beef and
lamb prices? (Source: U.S. 2003 79.7 94.4
Department of Agriculture) 2004 85.8 101.0
2005 89.7 110.0
Larson/Farber 4th ed 71
Solution: The Spearman Rank
Correlation Coefficient
• H0: ρs = 0 (no correlation between beef and lamb prices)
• Ha: ρs ≠ 0 (correlation between beef and lamb prices)
• α = 0.05
• n=7
• Critical value:
Table 10
Larson/Farber 4th ed 72
Solution: The Spearman Rank
Correlation Coefficient
Larson/Farber 4th ed 73
Solution: The Spearman Rank
Correlation Coefficient
• H0: ρs = 0 • Test
2
Statistic 6 d
• Ha: ρs ≠ 0 rs 1
n(n 2 1)
• α = 0.05
6(14)
• n=7 1 2 0.75
7(7 1)
• Critical value:
• Decision: Fail to Reject H0
The critical value
At the 5% level of significance,
is 0.786
you cannot conclude that there
is a significant correlation
between beef and lamb prices
between 1999 and 2005.
Larson/Farber 4th ed 74
Section 11.4 Summary
Larson/Farber 4th ed 75
Section 11.5
Larson/Farber 4th ed 76
Section 11.5 Objectives
Larson/Farber 4th ed 77
The Runs Test for Randomness
Larson/Farber 4th ed 78
Example: Finding the Number of Runs
A liquid-dispensing machine has been designed to fill
one-liter bottles. A quality control inspector decides
whether each bottle is filled to an acceptable level and
passes inspection (P) or fails inspection (F). Determine
the number of runs for the sequence and find the length
of each run.
PPFFFFPFFFPPPPPP
Solution: There are 5 runs.
Length PP FFFF P FFF PPPPPP
of run: 2 4 1 3 6
Larson/Farber 4th ed 79
Runs Test for Randomness
Larson/Farber 4th ed 80
Test Statistic for the Runs Test
• When n1 20 and n2 20, the test statistic for the runs test is G, the number of runs.
Larson/Farber 4th ed 81
Performing a Runs Test for Randomness
In Words In Symbols
1. State the claim. Identify null State H0 and Ha.
and alternative hypotheses.
2. Specify the level of Identify .
significance. (Use α = 0.05
for the runs test.)
3. Determine the number of Determine n1, n2, and
data that have each G.
characteristic and the
number of runs.
Larson/Farber 4th ed 82
Performing a Runs Test for Randomness
In Words In Symbols
4. Determine the critical If n1 20 and n2 20,
values. use Table 12.
If n1 > 20 or n2 > 20, use
Table 4.
5. Calculate the test statistic. If n1 20 and n2 20,
use G.
If n1 > 20 or n2 > 20, use
G G
z .
G
Larson/Farber 4th ed 83
Performing a Runs Test for Randomness
In Words In Symbols
6. Make a decision to reject or If G the lower
fail to reject the null critical value, or if
hypothesis. G the upper critical
value, reject H0.
Otherwise, fail to
reject H0.
7. Interpret the decision in the
context of the original
claim.
Larson/Farber 4th ed 84
Example: Using the Runs Test
Larson/Farber 4th ed 85
Solution: Using the Runs Test
Larson/Farber 4th ed 86
Solution: Using the Runs Test
• Critical value:
• n1 = 5 n2 = 7 G = 6
The lower
critical value is
3 and the upper
critical value is
11.
Larson/Farber 4th ed 87
Solution: Using the Runs Test
Larson/Farber 4th ed 89
Solution: Using the Runs Test
• n1 = number of Fs = 14
• n2 = number of Ms = 22
• G = number of runs = 11
Larson/Farber 4th ed 90
Solution: Using the Runs Test
• H0: random • Test Statistic:
• Ha: not random
• n1 = 14 n2 = 22
• G = 11
• α = 0.05 • Decision:
• Critical value:
n2 > 20, use Table 4
0.025 0.025
Z
-1.96 0 1.96
Larson/Farber 4th ed 91
Solution: Using the Runs Test
2n1n2
G 1 = 2(14)(22) 1 18.11
n1 n2 14 22
2n1n2(2n1n2 n1 n2) 1
G
(n1 n2) 2(n1 n2 1) n
2(14)(22)[2(14)(22) 14 22)
2 2.81
(14 22) (14 22 1)
G G 11 18.11
z 2.53
G 2.81
Larson/Farber 4th ed 92
Solution: Using the Runs Test
• H0: random • Test Statistic:
• Ha: not random z = -2.53
• n1 = 14 n2 = 22
• G = 11 • Decision: Reject H0
You have enough evidence at
• α = 0.05 the 5% level of significance
• Critical value: to support the claim that the
selection of employees with
respect to gender is not
0.025 0.025 random.
Z
-1.96 0 1.96
-2.53
Larson/Farber 4th ed 93
Section 11.5 Summary
Larson/Farber 4th ed 94