Professional Documents
Culture Documents
2 n1 n2 (2 n1 n2 n1 n2)
(n1 n2)
R 2
(n1 n2 1)
R
Runs Test: Large Sample Example
• Consider the following manufacturing example. A machine
produces parts that are occasionally flawed. When the machine is
working in adjustment, flaws still occur but seem to happen
randomly.
• A quality-control person randomly selects 50 of the parts produced
by the machine today and examines them one at a time in the
order that they were made. The result is 40 parts with no flaws and
10 parts with flaws. The sequence of no flaws (denoted by N) and
flaws (denoted by F ) is shown below.
NNN F NNNNNNN F NN FF NNNNNN F NNNN F NNNNNN FFFF
NNNNNNNNNNNN
• Using an alpha of .05, the quality controller tests to determine
whether the machine is producing randomly (the flaws are
occurring randomly).
Runs Test: Large Sample Example
H0: The observations in the sample are randomly generated.
Ha: The observations in the sample are not randomly generated.
= .05
n1 = 40
n2 = 10
If -1.96 Z 1.96, do not reject H0
Otherwise, reject H0.
1
1 2 3 4 5 6 7 8 9 0 11
NNN F NNNNNNN F NN FF NNNNNN F NNNN F NNNNN
12 13
FFFF NNNNNNNNNNNN R = 13
Runs Test: Large Sample Example
2 n1 n2 2 n1 n2 (2 n1 n2 n1 n2)
R 1
n1 n2 (n1 n2)
R 2
(n1 n2 1)
2(40)(10)
1 2(40)(10)[2(40)(10) (40) (10)]
40 10
(4010)
2
17 (40 10 1)
2.213
R
2.213
Mann-Whitney U Test
n1 (n1 1)
U1 n1n2 R1 R 1 Ranks from sample 1
2
n 2(n 2 1)
U 2 n1n2 R2 R2 Ranks from sample 2
2
• where n1 is the sample size from population 1 and n2 is
the sample size from population 2.
• The test statistic is the smallest of these two U values.
Mann-Whitney U Test:
Small Sample Example
• Is there a difference between health service workers and
educational service workers in the amount of compensation
employers pay them per hour?
• Suppose a random sample of seven health service workers is taken
along with a random sample of eight educational service workers
from different parts of the country. Each of their employers is
interviewed and figures are obtained on the amount paid per hour
for employee compensation for these workers. The data on the
following page indicate total compensation per hour.
• Use a Mann-Whitney U test to determine whether these two
populations are different in employee compensation.
Mann-Whitney U Test:
Small Sample Example
(7)(8)
(7)(8) 31 Let n1 = 7; n2 = 8.
2
53 Critical Value ( at α =0.05) = 10
n n 1 n n
U n1 n2 1 1
R1 U
1
2
2
2
where : n1 number in group 1 n n n n
1
U
1 2 1
12
2
n number in group 2
2
U
R sum or the ranks of Z U
1 U
values in group 1
Mann-Whitney U Test:
Example
• For example, the Mann-Whitney U test can be used
to determine whether there is a difference in the
average income of families who view PBS television
and families who do not view PBS television.
• Suppose a sample of 14 families that have identified
themselves as PBS television viewers and a sample of
13 families that have identified themselves as non-
PBS television viewers are selected randomly.
Mann-Whitney U Test:
Example PBS Non-PBS
24,500 41,000
39,400 32,500
Ho: The incomes for PBS viewers and 36,800 33,000
non-PBS viewers are identical 44,300 21,000
57,960 40,500
Ha: The incomes for PBS viewers and 32,000 32,400
non-PBS viewers are not 61,000 16,000
identical 34,000 21,500
43,500 39,500
55,000 27,600
n1 = 14
.05 39,000 43,500
62,500 51,900
If Z 1.96 or Z 1.96, reject Ho
n2 = 13 61,400 27,800
53,000
Mann-Whitney U Test:
Example
Income Rank Group Income Rank Group
16,000 1 Non-PBS 39,500 15 Non-PBS
21,000 2 Non-PBS 40,500 16 Non-PBS
21,500 3 Non-PBS 41,000 17 Non-PBS
24,500 4 PBS 43,000 18 PBS
27,600 5 Non-PBS 43,500 19.5 PBS
27,800 6 Non-PBS 43,500 19.5 Non-PBS
32,000 7 PBS 51,900 21 Non-PBS
32,400 8 Non-PBS 53,000 22 PBS
32,500 9 Non-PBS 55,000 23 PBS
33,000 10 Non-PBS 57,960 24 PBS
34,000 11 PBS 61,000 25 PBS
36,800 12 PBS 61,400 26 PBS
39,000 13 PBS 62,500 27 PBS
39,400 14 PBS
PBS and Non-PBS Viewers: Calculation
of U
R 4 7 11 12 13 14 18 19.5 22 23 24 25 26 27
1
245.5
U n n n n 1
1
R
1
1 2 1
2
1413
1415 245.5
2
41.5
PBS and Non-PBS Viewers: Conclusion
n n
U
Z U
U
1 2
2 U
1413 . 91
415
2 20.6
91 2.40
n n n n
1 Because this test is two-tailed with α= .05, the
U
1 2 1
12
2
critical values are z.025 = 1.96.
If the test statistic is greater than 1.96 or less
1413 28 than -1.96, the decision is to reject the null
12 hypothesis.
20.6
Z Cal
2.40 1.96, reject Ho
Wilcoxon Matched-Pairs
Signed Rank Test
A nonparametric alternative to the t test for
related samples
Before and After studies
Studies in which measures are taken on the
same person or object under different
conditions
Studies or twins or other relatives
Wilcoxon Matched-Pairs
Signed Rank Test
Differences of the scores of the two matched
samples
Differences are ranked, ignoring the sign
Ranks are given the sign of the difference
Positive ranks are summed
Negative ranks are summed
T is the smaller sum of ranks
Wilcoxon Matched-Pairs Signed Rank Test:
Sample Size Consideration
• n is the number of matched pairs
• If n > 15, T is approximately normally distributed, and a
Z test is used.
• If n 15, a special “small sample” procedure is
followed.
• Two assumptions underlie the use of this technique:
– The paired data are randomly selected.
– The underlying distributions are symmetrical.
Wilcoxon Matched-Pairs Signed Rank Test:
Small Sample Example
• As an example, consider the survey by American
Demographics that estimated the average annual household
spending on healthcare.
• The U.S. metropolitan average was $1,800. Suppose six
families in Pittsburgh, Pennsylvania, are matched
demographically with six families in Oakland, California, and
their amounts of household spending on healthcare for last
year are obtained.
• The data follow on the next page.
Wilcoxon Matched-Pairs Signed Rank Test:
Small Sample Example
H0: Md = 0 Family
Ha: Md 0
Pair Pittsburgh Oakland
n=6 1 1,950 1,760
=0.05
2 1,840 1,870
3 2,015 1,810
If Tobserved 1, reject H0.
4 1,580 1,660
5 1,790 1,340
6 1,925 1,765
Wilcoxon Matched-Pairs Signed Rank Test:
Small Sample Example
Family
Pair Pittsburgh Oakland d Rank
1 1,950 1,760 190 +4
2 1,840 1,870 -30 -1
3 2,015 1,810 205 +5
4 1,580 1,660 -80 -2
5 1,790 1,340 450 +6
6 1,925 1,765 160 +3
n n 1
T
4
nn 12n 1
T
24
T
Z T
T
T T 54 76.5
Z 107
.
T
211.
Three or
Two More
0.05 Partners Partners HMO
df k 1 3 1 2 13 24 26
15 16 22
2
5.991 20 19 31
.05, 2 18 22 27
If H 5.991, reject Ho. 23 25 28
14 33
17
Patients per Day Data:
Kruskal-Wallis Preliminary Calculations
Three or
Two More
Partners Partners HMO
Patients Rank Patients Rank Patients Rank
13 1 24 12 26 14
15 3 16 4 22 9.5
20 8 19 7 31 17
18 6 22 9.5 27 15
23 11 25 13 28 16
14 2 33 18
17 5
R1 = 29 R2 = 52.5 R3 = 89.5
n1 = 5 n2 = 7 n3 = 6
n = n1 + n2 + n3 = 5 + 7 + 6 = 18
Patients per Day Data: Kruskal-Wallis
Calculations and Conclusion
2
12 k
R j
3n 1
H
nn 1 j 1 n j
2 2 2
12 29 52 . 5 89 . 5 318 1
1818 1 5 7 6
12
1,897 318 1
1818 1
9.56
2
5.991
.05, 2
6 d
2
1
r s
n 1
n
2
Rank Rank:
Year Price of X Price of Y X Y d d2
1988 66.60 69.10 6 7 -1 1
1989 69.50 66.10 9 6 3 9
1990 74.60 55.50 13 2 11 121
1991 72.70 52.20 12 1 11 121
1992 71.30 59.50 10 3 7 49
1993 72.60 64.40 11 4 7 49
1994 66.70 65.60 7 5 2 4
1995 61.80 78.20 3 10 -7 49
1996 58.70 82.80 1 12 -11 121
1997 63.10 90.30 4 13 -9 81
1998 59.60 72.30 2 8 -6 36
1999 63.40 74.50 5 9 -4 16
2000 68.60 79.40 8 11 -3 9
666
17-50
Spearman’s Rank Correlation for Cattle and
Lamb Prices
6 d
2
r 1
n(n 1)
s 2
6 666
1
13(13 1)
2
.830
The Sign Test
• The sign test is a versatile nonparametric method for
hypothesis testing that uses the binomial distribution
with p .50 as the sampling distribution.
• Its name comes from the fact that it is based on the
direction of the plus or minus signs of observations
in a sample and not on their numerical magnitudes.
• The sign test may be one of the following two types:
– One sample sign test;
– Two sample sign test.
One Sample Sign Test
• The scores obtained by 10 students in a test is
given below:
• 64, 69, 40, 64, 65, 71, 82, 59, 64, 74
• Test whether the population median is equal
to 63
(n 1)
K (0.98) n
2
(10 1)
K (.98) 10 1.40
2
2.74
= 15 = .5(30)
Example: Peanut Butter Taste Test
• Rejection Rule
Using .05 level of significance,
Reject H0 if z < -1.96 or z > 1.96
• Test Statistic
z = (18 - 15)/2.74 = 3/2.74 = 1.095
• Conclusion
Do not reject H0. There is insufficient evidence in
the sample to conclude that a difference in preference
exists for the two brands of peanut butter.
Fewer than 10 or more than 20 individuals would
have to have a preference for a particular brand in order
for us to reject H0.