Chapter 11
Nonparametric Tests
1Larson/Farber 4th ed
Chapter Outline
• 11.1 The Sign Test
• 11.2 The Wilcoxon Tests
• 11.3 The Kruskal-Wallis Test
• 11.4 Rank Correlation
• 11.5 The Runs Test
2Larson/Farber 4th ed
Section 11.1
The Sign Test
3Larson/Farber 4th ed
Section 11.1 Objectives
• Use the sign test to test a population median
• Use the paired-sample sign test to test the difference between two population medians (dependent samples)
4Larson/Farber 4th ed
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).
5Larson/Farber 4th ed
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
6Larson/Farber 4th ed
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.
7Larson/Farber 4th ed
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
where x is the smaller number of + or signs and n is the sample size (the total number of + or signs).
( 0.5) 0.5
2
x nzn
8Larson/Farber 4th ed
Performing a Sign Test for a Population Median
1. State the claim. Identify the null and alternative hypotheses.
2. Specify the level of significance.
3. Determine the sample size n by assigning + signs and – signs to the sample data.
4. Determine the critical value.
State H0 and Ha.
Identify .
If n 25, use Table 8. If n > 25, use Table 4.
n = total number of + and – signs
In Words In Symbols
9Larson/Farber 4th ed
Performing a Sign Test for a Population Median
( 0.5) 0.5
2
x nzn
If the test statistic is less than or equal to the critical value, reject H0. Otherwise, fail to reject H0.
5. Calculate the test statistic. If n 25, use x.If n > 25, use
In Words In Symbols
6. Make a decision to reject or fail to reject the null hypothesis.
7. Interpret the decision in the context of the original claim.
10Larson/Farber 4th ed
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
11Larson/Farber 4th ed
Solution: Using the Sign Test
• H0:
• Ha:
775 765 801 742
754 753 739 751
745 750 777 769
756 760 782 789
median ≤ 750median > 750
• Compare each data entry with the hypothesized median 750
+ + + –
+ + – +
– 0 + +
+ + + +
• There are 3 – signs and 12 + signsn = 12 + 3 = 15
12Larson/Farber 4th ed
Solution: Using the Sign Test
• α =
• Critical Value: Use Table 8 (n ≤ 25)
0.05
Critical value is 3
13Larson/Farber 4th ed
Solution: Using the Sign Test
• 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.
• Test Statistic: x = 3 (n ≤ 25; use smaller number of + or – signs)
14Larson/Farber 4th ed
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?
15Larson/Farber 4th ed
Solution: Using the Sign Test
• H0:
• Ha:
• α =
• Critical value:
median ≥ 6000median < 60000.01
n > 25
z0-2.33
0.01
• Test Statistic:
• Decision:
There are 60 – signs and 40 + signs.n = 60 + 40 = 100x = 40
(40 0.5) 0.5(100)1.9
1002
z
At the 1% level of significance you cannot reject the dealership’s claim.
Fail to Reject H0
-1.9-2.33
16Larson/Farber 4th ed
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.
17Larson/Farber 4th ed
Performing The Paired-Sample Sign Test
1. State the claim. Identify the null and alternative hypotheses.
2. Specify the level of significance.
3. Determine the sample size n by finding the difference for each data pair. Assign a + sign for a positive difference, a – sign for a negative difference, and a 0 for no difference.
State H0 and Ha.
Identify .
n = total number of + and – signs
In Words In Symbols
18Larson/Farber 4th ed
Performing The Paired-Sample Sign Test
If the test statistic is less than or equal to the critical value, reject H0. Otherwise, fail to reject H0.
4. Determine the critical value.
5. Find the test statistic. x = lesser number of + and – signs
Use Table 8 inAppendix B.
In Words In Symbols
6. Make a decision to reject or fail to reject the null hypothesis.
7. Interpret the decision in the context of the original claim.
19Larson/Farber 4th ed
Example: Paired-Sample Sign Test
A psychologist claims that the number of repeat offenders will decrease if first-time offenders complete a particular rehabilitation course. You randomly select 10 prisons and record the number of repeat offenders during a two-year period. Then, after first-time offenders complete the course, you record the number of repeat offenders at each prison for another two-year period. The results are shown on the next slide. Atα = 0.025, can you support the psychologist’s claim?
20Larson/Farber 4th ed
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
Solution:• H0:
• Ha:
The number of repeat offenders will not decrease.
The number of repeat offenders will decrease.
Sign + + – + + + + + + +
• Determine the sign of the difference between the “before” and “after” data.
21Larson/Farber 4th ed
Solution: Paired-Sample Sign Test
• α =
• n =
• Critical value:
Sign + + – + + + + + + +
1 + 9 = 100.025 (one-tailed)
Critical value is 1
22Larson/Farber 4th ed
Solution: Paired-Sample Sign Test
• Test Statistic:
• Decision:
Sign + + – + + + + + + +
x = 1 (the smaller number of + or – signs)
Reject H0
At the 2.5% level of significance, you can support the psychologist’s claim that the number of repeat offenders will decrease.
23Larson/Farber 4th ed
Section 11.1 Summary
• Used the sign test to test a population median
• Used the paired-sample sign test to test the difference between two population medians (dependent samples)
24Larson/Farber 4th ed
Section 11.2
The Wilcoxon Tests
25Larson/Farber 4th ed
Section 11.2 Objectives
• Use the Wilcoxon signed-rank test to determine if two dependent samples are selected from populations having the same distribution
• Use the Wilcoxon rank sum test to determine if two independent samples are selected from populations having the same distribution.
26Larson/Farber 4th ed
The Wilcoxon Signed-Rank Test
Wilcoxon Signed-Rank Test
• A nonparametric test that can be used to determine whether two dependent samples were selected from populations having the same distribution.
• Unlike the sign test, it considers the magnitude, or size, of the data entries.
27Larson/Farber 4th ed
Performing The Wilcoxon Signed-Rank Test
1. State the claim. Identify the null and alternative hypotheses.
2. Specify the level of significance.
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.
State H0 and Ha.
Identify .
In Words In Symbols
Use Table 9 in Appendix B.
28Larson/Farber 4th ed
Performing The Wilcoxon Signed-Rank Test
5. Calculate the test statistic ws.
a. Complete a table using the headers listed at the right.
b. Find the sum of the positive ranks and the sum of the negative ranks.
c. Select the smaller of absolute values of the sums.
Headers: Sample 1, Sample 2, Difference, Absolute value, Rank, and Signed rank. Signed rank takes on the same sign as its corresponding difference.
In Words In Symbols
29Larson/Farber 4th ed
Performing The Wilcoxon Signed-Rank Test
6. Make a decision to reject or fail to reject the null hypothesis.
7. Interpret the decision in the context of the original claim.
If ws is less than or equal to the critical value, reject H0. Otherwise, fail to reject H0.
In Words In Symbols
30Larson/Farber 4th ed
Example: Wilcoxon Signed-Rank Test
A sports psychologist believes that listening to music affects the length of athletes’ workout sessions. The length of time (in minutes) of 10 athletes’ workout sessions, while listening to music and while not listening to music, are shown in the table. At α = 0.05, can you support the sports psychologist’s claim?
With music
45 38 28 39 41 47 62 54 33 44
Without music
38 40 33 36 42 41 54 47 28 35
31Larson/Farber 4th ed
Solution: Wilcoxon Signed-Rank Test
• H0:
• Ha:
• α =
• n =
There is no difference in the length of the athletes’ workout sessions.
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)
32Larson/Farber 4th ed
Solution: Wilcoxon Signed-Rank Test
• Critical ValueTable 9
Critical value is 8
33Larson/Farber 4th ed
Solution: Wilcoxon Signed-Rank Test
With music
Without music
DifferenceAbsolute
valueRank
Signed rank
45 38
38 40
28 33
39 36
41 42
47 41
62 54
54 47
33 28
44 35
• Test Statistic:
7
-2
3
-1
6
8
7
5
9
-5
1
2
3
5
5
6
7
8
9
7
1
2
3
4.5
4.5
6
7.5
9
7.5
10
-1
-2
3
-4.5
4.5
6
7
9
7.5
10
34Larson/Farber 4th ed
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.5ws = 7.5 (the smaller of the absolute value of these
two sums: |-7.5| < |47.5|)
35Larson/Farber 4th ed
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.
36Larson/Farber 4th ed
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.
37Larson/Farber 4th ed
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
Rz
1 1 2 12R
n n n 1 2 1 2 112R
n n n n
where
R = sum of the ranks for the smaller sample,
and
38Larson/Farber 4th ed
Performing The Wilcoxon Rank Sum Test
1. State the claim. Identify the null and alternative hypotheses.
2. Specify the level of significance.
3. Determine the critical value(s).
4. Determine the sample sizes.
State H0 and Ha.
Identify .
In Words In Symbols
Use Table 4 in Appendix B.
n1 ≤ n2
39Larson/Farber 4th ed
Performing The Wilcoxon Rank Sum Test
5. Find the sum of the ranks for the 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.
R
In Words In Symbols
40Larson/Farber 4th ed
Performing The Wilcoxon Rank Sum Test
6. Calculate the test statistic.
7. Make a decision to reject or fail to reject the null hypothesis.
8. Interpret the decision in the context of the original claim.
In Words In Symbols
If z is in the rejection region, reject H0. Otherwise, fail to reject H0.
R
R
Rz
41Larson/Farber 4th ed
Example: Wilcoxon Rank Sum Test
The table shows the earnings (in thousands of dollars) of a random sample of 10 male and 12 female pharmaceutical sales representatives. At α = 0.10, can you conclude that there is a difference between the males’ and females’ earnings?
Male 58 73 94 81 78 74 66 75 97 79
Female 66 57 81 73 65 78 71 67 64 77 80 70
42Larson/Farber 4th ed
Solution: Wilcoxon Rank Sum Test
• H0:
• Ha:
There is no difference between the males’ and the females’ earnings.
There is a difference between the males’ and the females’ earnings.0.10 (two-tailed test)• α =
• Rejection Region:
Z0-1. 645
0.05
1.645
0.05
43Larson/Farber 4th ed
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 data
Sample Rank
57 F 158 M 264 F 365 F 466 M 5.566 F 5.567 F 770 F 871 F 973 F 10.573 F 10.5
Ordered data
Sample Rank
74 M 1275 M 1377 F 1478 M 15.578 F 15.579 M 1780 F 1881 M 19.581 F 19.594 M 2197 M 22
44Larson/Farber 4th ed
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.
1 1 2 1 10 10 12 1115
2 2Rn n n
1 2 1 2 1 (10)(12) 10 12 115.17
n n n n 12 12Rσ
45Larson/Farber 4th ed
• α =
• Rejection Region:
Solution: Wilcoxon Rank Sum Test
• H0:
• Ha:
no difference in earnings.
difference in earnings.0.10
Z0-1. 645
0.05
1.645
0.05
138 115
15.17
1.52
R
R
Rz
• Decision:At the 10% level of significance, you cannot conclude that there is a difference between the males’ and females’ earnings.
• Test Statistic
Fail to reject H0
1.52
46Larson/Farber 4th ed
Section 11.2 Summary
• Used the Wilcoxon signed-rank test to determine if two dependent samples are selected from populations having the same distribution
• Used the Wilcoxon rank sum test to determine if two independent samples are selected from populations having the same distribution.
47Larson/Farber 4th ed
Section 11.3
The Kruskal-Wallis Test
48Larson/Farber 4th ed
Section 11.3 Objectives
• Use the Kruskal-Wallis test to determine whether three or more samples were selected from populations having the same distribution.
49Larson/Farber 4th ed
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. 50Larson/Farber 4th ed
The Kruskal-Wallis Test
• Two conditions for using the Kruskal-Wallis test are • Each sample must be randomly selected • The size of each sample must be at least 5.
• If these conditions are met, the test is approximated by a chi-square distribution with k – 1 degrees of freedom where k is the number of samples.
51Larson/Farber 4th ed
The Kruskal-Wallis Test
Test Statistic for the Kruskal-Wallis Test
• Given three or more independent samples, the test statistic H for the Kruskal-Wallis test is
22 21 2
1 2
12 ... 3( 1)( 1)
k
k
RR RH N
N N n n n
where
k represent the number of samples, ni is the size of the ith sample, N is the sum of the sample sizes,Ri is the sum of the ranks of the ith sample.
52Larson/Farber 4th ed
Performing a Kruskal-Wallis Test
1. State the claim. Identify the null and alternative hypotheses.
2. Specify the level of significance.
3. Identify the degrees of freedom
4. Determine the critical value and the rejection region.
State H0 and Ha.
Identify .
In Words In Symbols
Use Table 6 in Appendix B.
d.f. = k – 1
53Larson/Farber 4th ed
Performing a Kruskal-Wallis Test
5. Find the sum of the ranks for each sample.
a. List the combined data in ascending order.
b. Rank the combined data.
6. Calculate the test statistic.
In Words In Symbols
22 21 2
1 2
12 ...( 1)
3( 1)
k
k
RR RH
N N n n n
N
54Larson/Farber 4th ed
Performing a Kruskal-Wallis Test
7. Make a decision to reject or fail to reject the null hypothesis.
8. Interpret the decision in the context of the original claim.
In Words In Symbols
If H is in the rejection region, reject H0. Otherwise, fail to reject H0.
55Larson/Farber 4th ed
Example: Kruskal-Wallis Test
You want to compare the hourly pay rates of actuaries who work in California, Indiana, and Maryland. To do so, you randomly select several actuaries in each state and record their hourly pay rate. The hourly pay rates are shown on the next slide. At α = 0.01, can you conclude that the distributions of actuaries’ hourly pay rates in these three states are different? (Adapted from U.S. Bureau of Labor Statistics)
56Larson/Farber 4th ed
Example: Kruskal-Wallis Test
Sample Hourly Pay Rates
CA(Sample 1)
IN(Sample 2)
MD(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
57Larson/Farber 4th ed
• α =
• d.f. =
• Rejection Region:
Solution: Kruskal-Wallis Test
• H0:
• Ha:
There is no difference in the hourly pay rates in the three states.
There is a difference in the hourly pay rates in the three states.
0.01
k – 1 = 3 – 1 = 2
0 χ2
9.210
0.01
58Larson/Farber 4th ed
Solution: Kruskal-Wallis Test
Ordered Data Sample Rank
33.45 IN 1
35.97 IN 2.5
35.97 IN 2.5
35.98 IN 4
37.10 CA 5
38.25 IN 6
38.65 IN 7
40.12 IN 8
40.37 MD 9
40.50 CA 10
Ordered Data Sample Rank
41.70 CA 11
42.05 IN 12.5
42.05 CA 12.5
43.20 CA 14
43.57 MD 15
43,85 CA 16
44.94 MD 17
44.98 CA 18
45.35 MD 19
45.70 IN 20
Ordered Data Sample Rank
47.78 CA 21
48.79 MD 22
48.80 MD 23
49.20 MD 24
49.68 MD 25
49.88 CA 26
52.94 CA 27
53.25 MD 28
53.82 MD 29
The table shows the combined data listed in ascending order and the corresponding ranks.
59Larson/Farber 4th ed
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
22 2
2
1 2
2
2
2
1
12 160.5 63.5 211 3(29 1) 13.1229
12 ..
(29 1) 10 9 10
. 3( 1)( 1)
k
k
RR RH N
N N n n n
60Larson/Farber 4th ed
Solution: Kruskal-Wallis Test
• H0:
• Ha:
no difference in hourly pay rates
difference in hourly pay rates.
0.01• α =
• d.f. =
• Rejection Region:
3 – 1 = 2
0 χ2
9.210
0.01
• Decision:At the 1% level of significance, you can conclude that there is a difference in actuaries’ hourly pay rates in California, Indiana, and Maryland.
• Test Statistic
Reject H0
H ≈ 13.12
13.1261Larson/Farber 4th ed
Section 11.3 Summary
• Used the Kruskal-Wallis test to determine whether three or more samples were selected from populations having the same distribution.
62Larson/Farber 4th ed
Section 11.4
Rank Correlation
63Larson/Farber 4th ed
Section 11.4 Objectives
• Use the Spearman rank correlation coefficient to determine whether the correlation between two variables is significant.
64Larson/Farber 4th ed
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
65Larson/Farber 4th ed
The Spearman Rank Correlation Coefficient
Spearman rank correlation coefficient rs
• The formula for the Spearman rank correlation coefficient is
where n is the number of paired data entries
d is the difference between the ranks of a paired data entry.
2
261( 1)s
drn n
66Larson/Farber 4th ed
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.
67Larson/Farber 4th ed
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.)
68Larson/Farber 4th ed
Testing the Significance of the Spearman Rank Correlation Coefficient
1. State the null and alternative hypotheses.
2. Specify the level of significance.
3. Determine the critical value.
4. Find the test statistic.
State H0 and Ha.
Identify .
In Words In Symbols
Use Table 10 in Appendix B.
2
261( 1)s
drn n
69Larson/Farber 4th ed
Testing the Significance of the Spearman Rank Correlation Coefficient
5. Make a decision to reject or fail to reject the null hypothesis.
6. Interpret the decision in the context of the original claim.
In Words In Symbols
If |rs| is greater than the critical value, reject H0. Otherwise, fail to reject H0.
70Larson/Farber 4th ed
Example: The Spearman Rank Correlation Coefficient
The table shows the prices (in dollars per 100 pounds) received by U.S. farmers for beef and lamb from 1999 to 2005. At α = 0.05, can you conclude that there is a correlation between the beef and lamb prices? (Source: U.S. Department of Agriculture)
Year Beef Lamb
1999 63.4 74.5
2000 68.6 79.8
2001 71.3 66.9
2002 66.5 74.1
2003 79.7 94.4
2004 85.8 101.0
2005 89.7 110.0
71Larson/Farber 4th ed
• α =
• n =
• Critical value:
Solution: The Spearman Rank Correlation Coefficient
• H0:
• Ha:
ρs = 0 (no correlation between beef and lamb prices)
ρs ≠ 0 (correlation between beef and lamb prices)
0.05
Table 10
7
The critical value is 0.786
72Larson/Farber 4th ed
Beef Rank Lamb Rank d d2
63.4 74.5
68.6 79.8
71.3 66.9
66.5 74.1
79.7 94.4
85.8 101.0
89.7 110.0
Solution: The Spearman Rank Correlation Coefficient
1
3
4
2
5
6
7
3
4
1
2
5
6
7
-2
-1
3
0
0
0
0
4
1
9
0
0
0
0
Σd2 = 14
73Larson/Farber 4th ed
• α =
• n =
• Critical value:
Solution: The Spearman Rank Correlation Coefficient
• H0:
• Ha:
ρs = 0
ρs ≠ 0
0.05
7
The critical value is 0.786
• Decision:At the 5% level of significance, you cannot conclude that there is a significant correlation between beef and lamb prices between 1999 and 2005.
• Test Statistic
Fail to Reject H0
2
2
2
61( 1)
6(14)1 0.757(7 1)
sdr
n n
74Larson/Farber 4th ed
Section 11.4 Summary
• Used the Spearman rank correlation coefficient to determine whether the correlation between two variables is significant.
75Larson/Farber 4th ed
Section 11.5
The Runs Test
76Larson/Farber 4th ed
Section 11.5 Objectives
• Use the runs test to determine whether a data set is random.
77Larson/Farber 4th ed
The Runs Test for Randomness
• A run is a sequence of data having the same characteristic.
• Each run is preceded by and followed by data with a different characteristic or by no data at all.
• The number of data in a run is called the length of the run.
78Larson/Farber 4th ed
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.
P P F F F F P F F F P P P P P P
P P F F F F P F F F P P P P P PLength of run:
There are 5 runs.
2 4 1 3 6
Solution:
79Larson/Farber 4th ed
Runs Test for Randomness
Runs Test for Randomness
• A nonparametric test that can be used to determine whether a sequence of sample data is random.
• The null and alternative hypotheses for this test are as follows.
H0: The sequence of data is random.
Ha: The sequence of data is not random.
80Larson/Farber 4th ed
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.
G
G
Gz
1 2 1 2 1 2 1 22
1 2 1 2 1 2
2 2 (2 ) 1
( ) ( 1)and G G
n n n n n n n nn n n n n n
• When n1 > 20 or n2 > 20, the test statistic for the runs test is
where
81Larson/Farber 4th ed
Performing a Runs Test for Randomness
Determine n1, n2, and G.
1. State the claim. Identify null and alternative hypotheses.
2. Specify the level of significance. (Use α = 0.05 for the runs test.)
3. Determine the number of data that have each characteristic and the number of runs.
State H0 and Ha.
Identify .
In Words In Symbols
82Larson/Farber 4th ed
Performing a Runs Test for Randomness
4. Determine the critical values.
5. Calculate the test statistic.
.G
G
Gz
If n1 20 and n2 20, use G.
If n1 > 20 or n2 > 20, use
In Words In Symbols
If n1 20 and n2 20, use Table 12. If n1 > 20 or n2 > 20, use Table 4.
83Larson/Farber 4th ed
Performing a Runs Test for Randomness
6. Make a decision to reject or fail to reject the null hypothesis.
7. Interpret the decision in the context of the original claim.
If G the lower critical value, or if G the upper critical value, reject H0. Otherwise, fail to reject H0.
In Words In Symbols
84Larson/Farber 4th ed
Example: Using the Runs Test
A foreman for a construction company records injuries reported by workers during his shift. The following sequence shows whether any injuries were reported during each month in a recent year. I represents a month in which at least one injury was reported and N represents a month in which no injuries were reported. At α = 0.05, can you conclude that the occurrence of injuries each month is not random?
I I N N N I N I I N N N
85Larson/Farber 4th ed
Solution: Using the Runs Test
I I N N N I N I I N N N
• H0:
• Ha:
The occurrence of injuries is random.
The occurrence of injuries is not random.
• n1 = number of Is =
• n2 = number of Ns =
• G = number of runs =
• α =
• Critical value:
5
6
7
0.05
Because n1 ≤ 20, n2 ≤ 20, use Table 12
86Larson/Farber 4th ed
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.
87Larson/Farber 4th ed
Solution: Using the Runs Test
• H0:
• Ha:
random
not random
• n1 = n2 =
• G =
• α =
• Critical value:
5
6
7
0.05
lower critical value = 3 upper critical value =11
• Decision:At the 5% level of significance, you do not have enough evidence to support the claim that the occurrence of injuries is not random. So, it appears that the injuries reported by workers during the foreman’s shift occur randomly.
• Test Statistic:
Fail to Reject H0
G = 6
88Larson/Farber 4th ed
Example: Using the Runs Test
You want to determine whether the selection of recently hired employees in a large company is random with respect to gender. The genders of 36 recently hired employees are shown below. At α = 0.05, can you conclude that the selection is not random?
M M F F F F M M M M M M
F F F F F M M M M M M M
F F F M M M M F M M F M
89Larson/Farber 4th ed
Solution: Using the Runs Test
M M F F F F M M M M M M
F F F F F M M M M M M M
F F F M M M M F M M F M
• H0:
• Ha:
The selection of employees is random.
The selection of employees is not random.
• n1 = number of Fs =
• n2 = number of Ms =
• G = number of runs =
14
11
22
90Larson/Farber 4th ed
Solution: Using the Runs Test
• H0:
• Ha:
random
not random
• n1 = n2 =
• G =
• α =
• Critical value:
14
11
22
0.05 • Decision:
• Test Statistic:
n2 > 20, use Table 4
Z0-1.96
0.025
1.96
0.025
91Larson/Farber 4th ed
Solution: Using the Runs Test
G
G
Gz
1 2
1 2
2 1 =G
n nn n
1 2 1 2 1 22
1 2 1 2
2 (2 ) 1( ) ( 1)Gn n n n n n
nn n n n
2(14)(22) 1 18.1114 22
22(14)(22)[2(14)(22) 14 22) 2.81
(14 22) (14 22 1)
11 18.11 2.532.81
92Larson/Farber 4th ed
Solution: Using the Runs Test
• H0:
• Ha:
random
not random
• n1 = n2 =
• G =
• α =
• Critical value:
14
11
22
0.05
• Decision:
• Test Statistic:
Z0-1.96
0.025
1.96
0.025
z = -2.53
-2.53
You have enough evidence at the 5% level of significance to support the claim that the selection of employees with respect to gender is not random.
Reject H0
93Larson/Farber 4th ed
Section 11.5 Summary
• Used the runs test to determine whether a data set is random.
94Larson/Farber 4th ed