Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 117

Nonparametric

Statistical Methods
Definition
When the data is generated from process
(model) that is known except for finite
number of unknown parameters the model is
called a parametric model.

Otherwise, the model is called a non-


parametric model
Statistical techniques that assume a non-
parametric model are called non-parametric.
For example
If you assume that your data has come from a
normal distribution with mean m and standard
deviation s (both unknown) then the data is
generated from process (model) that is known
except for two of parameters.(m and s )

The model is called a parametric model.


Models that do not assume normality (or
some other distribution with a finite no. of
paramters) are non-parametric
We will consider two nonparametric tests
1. The sign test
2. Wilcoxon’s signed rank test
These are tests for the central location of a
population.
They are alternatives to the z-test and the t-
test for the mean of a normal population
x  0 x  0
z t
 n s n
Nonparametric
Statistical Methods
Single sample nonparametric tests for central
location
1. The sign test
2. Wilcoxon’s signed rank test

These are tests for the central location of a


population.
They are alternatives to the z-test and the t-
test for the mean of a normal population
x  0 x  0
z t
 n s n
Both the z-test and the t-test assumes the data
is coming from a normal population

If the data is not coming from a normal


population, properties of the z-test and the t-
test that require this assumption will no longer
be true.

The probability of a type I error may be


different than the desired value (0.05 or 0.01)
Single sample non parametric tests
If the data is not coming from a normal
population we should then use one of the two
nonparametric tests

1. The sign test


2. Wilcoxon’s signed tank test

These tests do not assume the data is coming


from a normal population
The sign test

A nonparametric test for the central


location of a distribution
We want to test:
H0: median = m0
against
HA: median ≠ m0

(or against a one-sided alternative)


The Sign test:
1. The test statistic:
S = the number of observations
that exceed m0
Comment: If H0: median = m0 is true
we would expect 50% of the
observations to be above m0, and 50%
of the observations to be below m0,
50%
50%

0
0 median = m0
If H 0 is true then S will have a binomial distribution
with p = 0.50, n = sample size.
m0 > median

p < 0.50

median m0
If H 0 is not true then S will still have a binomial
distribution. However p will not be equal to 0.50.
m0 < median

p > 0.50

m0 median
p = the probability that an observation is greater
than m0.
Summarizing: If H 0 is true then S will have a
binomial distribution with p = 0.50, n = sample size.
n = 10 0.3

x p(x) 0.25
0 0.0010
1 0.0098 0.2
2 0.0439
0.15
3 0.1172
4 0.2051 0.1
5 0.2461
6 0.2051 0.05
7 0.1172
8 0.0439 0
9 0.0098 0 1 2 3 4 5 6 7 8 9 10
10 0.0010
The critical and acceptance region:
n = 10
x p(x) 0.3000
0 0.0010
0.2500
1 0.0098
2 0.0439 0.2000
3 0.1172
4 0.2051 0.1500
5 0.2461
6 0.2051 0.1000
7 0.1172
0.0500
8 0.0439
9 0.0098 0.0000
10 0.0010
0 1 2 3 4 5 6 7 8 9 10
Choose the critical region so that a is close to 0.05 or 0.01.
e. g. If critical region is {0,1,9,10} then a = .0010 + .0098
+ .0098 +.0010 = .0216
e. g. If critical region is {0,1,2,8,9,10} then a = .0010 + .0098
+.0439+.0439+ .0098 +.0010 = .1094

n = 10
0.3000
x p(x)
0 0.0010 0.2500
1 0.0098
2 0.0439 0.2000
3 0.1172
0.1500
4 0.2051
5 0.2461 0.1000
6 0.2051
7 0.1172 0.0500
8 0.0439
9 0.0098 0.0000
10 0.0010 0 1 2 3 4 5 6 7 8 9 10
Example
Suppose that we are interested in determining
if a new drug is effective in reducing
cholesterol.
Hence we administer the drug to n = 10
patients with high cholesterol and measure the
reduction.
The data
Cholesterol
Case Initial Final Reduction
1 240 228 12
2 237 222 15
3 264 262 2
4 233 224 9
5 236 240 -4
6 234 237 -3
7 264 264 0
8 241 219 22
9 261 252 9
10 256 254 2
Suppose we want to test
H0: the drug is not effective
median reduction ≤ 0
against
HA: the drug is effective
median reduction > 0

The Sign test


S = the no. of positive obs
The Sign test
The test statistic
S = the no. of positive obs = 8
We will use the p-value approach
p-value = P[S ≥ 8]
= 0.0439 + 0.0098 + 0.0010
= 0.0547
Since p-value > 0.05 we cannot reject H0
Summarizing: To carry out Sign Test

We
1. Compute S = The # of observations greater than m0
2. Let sobserved = the observed value of S.
3. Compute the p-value = P[S ≥ sobserved]
(2 P[S ≥ sobserved] for a two-tailed test).
Use the table for the binomial dist’n (p = ½ , n = sample size)
4. Conclude HA (Reject H0) if p-value is less than 0.05
(or 0.01).
Sign Test for Large Samples
If n is large we can use the Normal approximation
to the Binomial.
Namely S has a Binomial distribution with p = ½
and n = sample size.
Hence for large n, S has approximately a Normal
distribution with
n
mean  S  np 
and 2
standard deviation
 1  1  n
 S  npq  n   
 2  2  2
Hence for large n,use as the test statistic (in
place of S) n
S
S  S 2
z 
S n
2
Choose the critical region for z from the
Standard Normal distribution.

i.e. Reject H0 if z < -za/2 or z > za/2

two tailed ( a one tailed test can also be set up.


Nonparametric

Confidence Intervals
Assume that the data, x1, x2, x3, … xn is a sample
from an unknown distribution.

Now arrange the data x1, x2, x3, … xn in increasing


order

x(1) < x(2) < x(3) < … < x(n)

Hence
x(1) = the smallest observation
x(2) = the 2nd smallest observation

x(n) = the largest observation


Consider the kth smallest observation and the kth
largest observation in the data x1, x2, x3, … xn
x(k) and x(n – k + 1)
Hence P[x(k) < median < x(n – k + 1) ]
= P[at least k observations lie below the
median and at least k observations lie
above the median ]
If at least k observations lie below the median than
x(k) < median
If at least k observations lie above the median than
median < x(n – k + 1)
Thus P[x(k) < median < x(n – k + 1) ]
= P[at least k observations lie below the
median and at least k observations lie
above the median ]
= P[The number of observations below the
median is at least k and at most n-k]
= P[k ≤ S ≤ n-k]
where S = the number of observations below the
median
S has a binomial distribution with
n = the sample size and p =1/2.
Hence P[x(k) < median < x(n – k + 1) ]
= P[k ≤ S ≤ n-k]
= p(k) + p(k + 1) + … + p(n-k) = P
where p(i)’s are binomial probabilities with
n = the sample size and p =1/2.

This means that x(k) to x(n – k + 1) is a P100%


confidence interval for the median
Summarizing

x(k) to x(n – k + 1)
is a P100% confidence interval for the
median

where P = p(k) + p(k + 1) + … + p(n-k)

and p(i)’s are binomial probabilities with


n = the sample size and p =1/2.
Example: n = 10 and k =2
Binomial probabilities
0.3000
x p(x)
0 0.0010 0.2500
1 0.0098
2 0.0439 0.2000
3 0.1172
4 0.2051 0.1500
5 0.2461
0.1000
6 0.2051
7 0.1172 0.0500
8 0.0439
9 0.0098 0.0000
10 0.0010 0 1 2 3 4 5 6 7 8 9 10

P = p(2) + p(3) + p(4) + p(5) + p(6) + p(7) + p(8)= .9784


Hence x(2) to x(9) is a 97.84% confidence interval for the
median
Example
Suppose that we are interested in determining
if a new drug is effective in reducing
cholesterol.
Hence we administer the drug to n = 10
patients with high cholesterol and measure the
reduction.
The data
Cholesterol
Case Initial Final Reduction
1 240 228 12
2 237 222 15
3 264 262 2
4 233 224 9
5 236 240 -4
6 234 237 -3
7 264 264 0
8 241 219 22
9 261 252 9
10 256 254 2
The data arranged in order

k x (k )
1 -4 x(2) = -3 to x(9) =15 is a
2 -3
97.84% confidence interval
3 0 for the median
4 2
5 2
6 9
7 9
8 12
9 15
10 22
Example
In the previous example to repeat the study
with n = 20 patients with high cholesterol.
The Case Initial
Cholesterol
Final Reduction

data 1
2
231
241
212
235
19
6
3 270 268 2
4 264 255 9
5 256 252 4
6 240 234 6
7 269 256 13
8 242 243 -1
9 269 264 5
10 230 221 9
11 234 220 14
12 266 267 -1
13 253 252 1
14 267 242 25
15 248 248 0
16 238 239 -1
17 266 268 -2
18 266 240 26
19 244 247 -3
20 249 250 -1
The binomial distribution with n = 20, p = 0.5
x p (x )
0 0.0000 Note:
1 0.0000
2 0.0002 p(6) + p(7) + p(8) + p(9) + p(10) +
3 0.0011
4 0.0046 p(11) + p(12) + p(13) + p(14)
5 0.0148
6 0.0370 = 0.037 + 0.0739 + 0.1201 + 0.1602
7
8
0.0739
0.1201
+ 0.1762 + 0.1602 + 0.1201 + 0.0739
9 0.1602 + 0.037 = 0.9586
10 0.1762
11 0.1602
12 0.1201
13 0.0739 Hence
14 0.0370
15 0.0148 x(6) to x(15) is a 95.86% confidence
16 0.0046
17 0.0011
interval for the median reduction in
18 0.0002 cholesterol
19 0.0000
20 0.0000
The data arranged in order
k x (k )
1 -3
2 -2
3 -1
4 -1
5 -1
6
7
-1
0
x(6) = -1 to x(15) = 9 is a
8
9
1
2
95.86% confidence interval
10 4 for the median
11 5
12 6
13 6
14 9
15 9
16 13
17 14
18 19
19 25
20 26
For large values of n one can use the normal
approximation to the Binomial to find the value of k so
that x(k) to x(n – k + 1) is a 95% confidence interval for the
median.
i.e. we want to find k so that
 n n
S  k 
 2k  n 
PS  k   P  2  2   P Z    0.025
 n n   n 
 2 2 
but PZ  1.960  0.025
2k  n n  1.96 n
hence  1.960 or k 
n 2
n  1.96 n
Using k 
2

n k
20 5.6
40 13.8
100 40.2
200 86.1
Next we will consider:
1. The Wilcoxon signed rank test
The Wilcoxon signed rank test is an
alternative to the Sign test, a test for the
central location of a single population
The sign test

A nonparametric test for the central


location of a distribution
We want to test:
H0: median = m0
against
HA: median ≠ m0

(or against a one-sided alternative)


The Sign test:
1. The test statistic:
S = the number of observations
that exceed m0
Comment: If H0: median = m0 is true
then
• The distribution of S is binomial
- n = sample size,
- p = 0.50
To carry out the The Sign test:
1. Compute the test statistic:
S = the number of observations
that exceed m0 = sobserved
2. Compute the p-value of test
statistic, sobserved :
p-value = P [S ≥ sobserved ]
( = 2 P [S ≥ sobserved ] for 2-tailed test)
where S is binomial, n = sample size, p = 0.50

3. Reject H0 if p-value low (< 0.05)


Non-parametric confidence intervals for the median
of a population
x(k) to x(n – k + 1)
is a (1 – a)100% = P100% confidence interval
for the median
where
x(k) = kth smallest xi and
x(n – k + 1) = kth largest xi
P = p(k) + p(k + 1) + … + p(n-k)
and p(i)’s are binomial probabilities with
n = the sample size and p =1/2.
The Wilcoxon Signed Rank Test

An Alternative to the sign test


Situation
• A sample of size n , (x1 , x2 , … , xn) from an
unknown distribution and we want to test

H0 : the centre of the distribution, m = m0 , against


HA : m ≠ m0 ,
• For the sign test we would count S, the number
of positive values of (x1 – m0 , x2 – m0 , … , xn –
m0).
• We would reject H0 if S was not close to n/2
• For Wicoxon’s signed-Rank test we would
assign ranks to the absolute values of (x1 – m0 , x2
– m0 , … , xn – m0).
• A rank of 1 to the value of xi – m0 which is
smallest in absolute value.
• A rank of n to the value of xi – m0 which is
largest in absolute value.
W+ = the sum of the ranks associated with
positive values of xi – m0.
W- = the sum of the ranks associated with
negative values of xi – m0.
Note: W+ + W- = 1 + 2+ 3+ …n = n(n + 1)/2

 W-  n(n + 1)/4
If H0 is true then W+ 

If H0 is not true then either


1. W+ will be small (W- large) or
2. W+ will be large (W- small)
m0 > True median

True m0
median
W- large W+ small
m0 < True median

m0 True
median
W- small W+ large
Note: It is possible to work out the sampling
distribution of W+ ( and W-) when H0 is true.

Note: We use the fact that if H0 is true that there is


an equal probability (1/2) that the sign attached to
any rank is plus (+) or minus (-).
Example: n = 4.
ranks
1 2 3 4 W+ W- Prob
- - - - 0 10 1/16
+ - - - 1 9 1/16
- + - - 2 8 1/16
- - + - 3 7 1/16
- - - + 4 6 1/16
+ + - - 3 7 1/16
+ - + - 4 6 1/16
+ - - + 5 5 1/16
- + + - 5 5 1/16
- + - + 6 4 1/16
- - + +- 7 3 1/16
+ + + - 6 4 1/16
+ + - + 7 3 1/16
+ - + + 8 2 1/16
- + + + 9 1 1/16
+ + + + 10 0 1/16
The distribution of W+ and W- : n = 4.
W+ Prob W- Prob
0 1/16 0 1/16
1 1/16 1 1/16
2 1/16 2 1/16
3 2/16 3 2/16
4 2/16 4 2/16
5 2/16 5 2/16
6 2/16 6 2/16
7 216 7 216
8 1/16 8 1/16
9 1/16 9 1/16
10 1/16 10 1/16
If T = W+ or W- : n = 4.
T P[T = t] P[T ≤ t]
0 1/16 0.0625
1 1/16 0.1250 These are the values
2 1/16 0.1875 found in the table A.6
in the textbook
3 2/16 0.3125
4 2/16 0.4375
5 2/16 0.5625
6 2/16 0.6875
7 2/16 0.8125
8 1/16 0.8750
9 1/16 0.9375
10 1/16 1.000
table A.6 Page A- 15
Distribution of the test statistic for Wilcoxon signed-rank test
Sample Size
T 2 3 4 5 6
1 0.5000 0.2500 0.1250 0.0625 0.0313
2 0.3750 0.1875 0.0938 0.0469
3 0.6250 0.3125 0.1563 0.0782
4 0.4375 0.2188 0.1094
5 0.5625 0.3125 0.1563

6 0.4063 0.2188
7 0.5000 0.2813
8 0.3438
9 0.4219
10 0.5000
table A.6 Page A- 15
Only goes up to n = sample size = 12

For sample sizes, n > 12 we can use the fact that T (W+ or W-)
has approximately a normal distribution with

nn  1
mean T 
4

nn  12n  1
standard deviation  T 
24
 T  T t  T   t  T 
and PT  t   P     P Z  
 T T   T 
12

PT  t 
1 0.0005 0.0014
2 0.0008 0.0019
3 0.0013 0.0024
4 0.0018 0.0030
5 0.0025 0.0038

6 0.0035 0.0048
7 0.0047 0.0060
8 0.0062 0.0075
9 0.0081 0.0093
10 0.0105 0.0115

11 0.0135 0.0140
12 0.0171 0.0171
13 0.0213 0.0207
14 0.0262 0.0249  t  T 
15 0.0320 0.0299  P Z  
 T 
Exact Values Normal
Approximation
Example
• In this example we are interested in the
quantity FVC (Forced Vital Capacity) in
patients with cystic fibrosis
• FVC (Forced Vital Capacity) = the volume of
air that a person can expel from the lungs in a
6 sec period.
• This will be reduced with time for cystic
fibrosis patients
The research question: Will this reduction be
less when a new experimental drug is
administered?
The Experimental Design
• The design will be a matched pair design
• Pairs of patients are matched (Using initial FVC
readings)
• One member of the pair is given the new drug the
other member is given a placebo
• We measure the reduction in FVC for each member
and compute the difference
– xi = Reduction in FVC (placebo) – Reduction in FVC
(drug)
These values will be generally positive if the drug is
effective in minimizing the deterioration in Forced
Vital Capacity (FVC).
W+ will be large (W- will be small)
Table: Reduction in forced vital capacity (FVC) for a
matched pair sample of patients with cystic fibrosis
Reduction in FVC
Placebo Drug xi
Subject Difference Rank Signed Rank
1 224 213 11 1 1
2 8 95 -15 2 -2
3 75 33 42 3 3
4 541 440 101 4 4
5 74 -32 106 5 5
6 85 -28 113 6 6
7 293 445 -152 7 -7
8 -23 -178 155 8 8
9 525 367 158 9 9
10 -38 140 -179 10 -10
11 508 323 185 11 11
12 255 10 245 12 12
13 525 65 460 13 13
14 1023 343 680 14 14
W+ = 86 W- = 19
We have to judge if
W+ = 86 is large (or W- = 19 is small)
nn  1 1415
W     52.5
4 4
nn  12n  1 141529 
W     15.92953
24 24
 
 52.5 19  52.5 

P W  19  P  
W
 
 15.92953 15.92953 
 PZ  2.10  0.0179  p - value
Since the p-value is small (< 0.05) we conclude the
drug is effective in reducing the deterioration of FVC
Summarizing: To carry out Wilcoxon’s signed rank test

We
1. Compute T = W+ or W- (usually it would be the smaller
of the two)
2. Let tobserved = the observed value of T.
3. Compute the p-value = P[T ≤ tobserved] (2 P[T ≤ tobserved] for
a two-tailed test).
i. For n ≤ 12 use the table.
ii. For n > 12 use the Normal approximation.
4. Conclude HA (Reject H0) if p-value is less than 0.05 (or
0.01).
Alternative tests for this example

1. The t – test
x  0 x
test statistic t  
s s
n n

2. The sign test

test statistic S  # of positive xi


Comments
1. The t – test
i. This test requires the assumption of normality.
ii. If the data is not normally distributed the test is invalid
• The probability of a type I error may not be equal to its desired value
(0.05 or 0.01)
iii. If the data is normally distributed, the t-test commits type II errors
with a smaller probability than any other test (In particular
Wilcoxon’s signed rank test or the sign test)
2. The sign test
i. This test does not require the assumption of normality (true also
for Wilcoxon’s signed rank test).
ii. This test ignores the magnitude of the observations completely.
Wilcoxon’s test takes the magnitude into account by ranking them
Nonparametric
Statistical Methods
Summary
Single sample nonparametric tests for central
location
1. The sign test
2. Wilcoxon’s signed rank test

These are tests for the central location of a


population.
They are alternatives to the z-test and the t-
test for the mean of a normal population
x  0 x  0
z t
 n s n
Comments
1. The t – test
i. This test requires the assumption of normality.
ii. If the data is not normally distributed the test is invalid
• The probability of a type I error may not be equal to its desired value
(0.05 or 0.01)
iii. If the data is normally distributed, the t-test commits type II errors
with a smaller probability than any other test (In particular
Wilcoxon’s signed rank test or the sign test)
2. The sign test
i. This test does not require the assumption of normality (true also
for Wilcoxon’s signed rank test).
ii. This test ignores the magnitude of the observations completely.
Wilcoxon’s test takes the magnitude into account by ranking them
The Sign test
Summarizing: To carry out Sign Test

We
1. Compute S = The # of observations greater than m0
2. Let sobserved = the observed value of S.
3. Compute the p-value = P[S ≤ sobserved]
(2 P[S ≤ sobserved] for a two-tailed test).
Use the table for the binomial dist’n (p = ½ , n = sample size)
Use the Normal approximation to binonial if n is large.
4. Conclude HA (Reject H0) if p-value is less than 0.05
(or 0.01).
m0 = True median

True = m0
median

S ≈ n/2
m0 > True median

True m0
median

S small (close to 0)
m0 < True median

m0 True
median

S large (close to n)
Wilcoxon’s signed-Rank test
• For Wilcoxon’s signed-Rank test we would
assign ranks to the absolute values of (x1 – m0 , x2
– m0 , … , xn – m0).
• A rank of 1 to the value of xi – m0 which is
smallest in absolute value.
• A rank of n to the value of xi – m0 which is
largest in absolute value.
W+ = the sum of the ranks associated with
positive values of xi – m0.
W- = the sum of the ranks associated with
negative values of xi – m0.
Note: W+ + W- = 1 + 2+ 3+ …n = n(n + 1)/2

 W-  n(n + 1)/4
If H0 is true then W+ 

If H0 is not true then either


1. W+ will be small (W- large) or
2. W+ will be large (W- small)
m0 = True median

True = m0
median

W+ ≈ W- ≈ n(n + 1)/4
m0 > True median

True m0
median
W- large W+ small
m0 > True median

True m0
median
W- large W+ small
m0 < True median

m0 True
median
W- small W+ large
Summarizing: To carry out Wilcoxon’s signed rank test

We
1. Compute T = W+ or W- (usually it would be the smaller
of the two)
2. Let tobserved = the observed value of T.
3. Compute the p-value = P[T ≤ tobserved] (2 P[T ≤ tobserved] for
a two-tailed test).
i. For n ≤ 12 use the table.
ii. For n > 12 use the Normal approximation.
4. Conclude HA (Reject H0) if p-value is less than 0.05 (or
0.01).
Nonparametric
Statistical Methods
Single sample nonparametric tests for central
location
1. The sign test
2. Wilcoxon’s signed rank test

These are tests for the central location of a


population.
They are alternatives to the z-test and the t-
test for the mean of a normal population
x  0 x  0
z t
 n s n
The Sign test
Summarizing: To carry out Sign Test

We
1. Compute S = The # of observations greater than m0
2. Let sobserved = the observed value of S.
3. Compute the p-value = P[S ≤ sobserved]
(2 P[S ≤ sobserved] for a two-tailed test).
Use the table for the binomial dist’n (p = ½ , n = sample size)
Use the Normal approximation to binonial if n is large.
4. Conclude HA (Reject H0) if p-value is less than 0.05
(or 0.01).
Wilcoxon’s signed-Rank test
• For Wilcoxon’s signed-Rank test we would
assign ranks to the absolute values of (x1 – m0 , x2
– m0 , … , xn – m0).
• A rank of 1 to the value of xi – m0 which is
smallest in absolute value.
• A rank of n to the value of xi – m0 which is
largest in absolute value.
W+ = the sum of the ranks associated with
positive values of xi – m0.
W- = the sum of the ranks associated with
negative values of xi – m0.
Summarizing: To carry out Wilcoxon’s signed rank test

We
1. Compute T = W+ or W- (usually it would be the smaller
of the two)
2. Let tobserved = the observed value of T.
3. Compute the p-value = P[T ≤ tobserved] (2 P[T ≤ tobserved] for
a two-tailed test).
i. For n ≤ 12 use the table.
ii. For n > 12 use the Normal approximation.
4. Conclude HA (Reject H0) if p-value is less than 0.05 (or
0.01).
Two-sample – Non-parametic
tests
Mann-Whitney Test

A non-parametric two sample test for


comparison of central location
The Mann-Whitney Test
• This is a non parametric alternative to the two
sample t test (or z test) for independent samples.
• These tests (t and z) assume the data is normal
• The Mann- Whitney test does not make this
assumption.
• Sample of n from population 1
x1, x2, x3, … , xn
• Sample of m from population 2
y1, y2, y3, … , ym
The Mann-Whitney test statistic U1 counts the
number of times an observation in sample 1
precedes an observation in sample 2.

An Equivalent statistic U2 that counts the number


of times an observation in sample 2 precedes an
observation in sample 1 can also be computed
Example

n = m = 4 measurements of bacteria counts per


unit volume were made for two type of cultures.
The n = 4 measurements for culture 1 were
27, 31, 26, 25
The m = 4 measurements for culture 2 were
32, 29, 35, 28
To compute the Mann-Whitney test statistics U1 and
U2, arrange the observations from the two samples
combined in increasing order (retaining sample
membership).
25(1), 26(1), 27(1) , 28(2) , 29(2), 31(1), 32(2) , 35(2)
For each observation in sample 2 let ui demote the
number of observations in sample 1 that precede that
value.
u1 = 3, u2 = 3, u3 = 4, u4 = 4,
Then U1 = u1 + u2 + u3 + u4 = 3 + 3 + 4 + 4 =14
To compute U2, repeat the process for the second
sample

25(1), 26(1), 27(1) , 28(2) , 29(2), 31(1), 32(2) , 35(2)


For each observation in sample 1 let vi denote the
number of observations in sample 2 that precede that
value.
v1 = 0, v2 = 0, v3 = 0, v4 = 2,
Then U2 = v1 + v2 + v3 + v4 = 0 + 0 + 0 + 2 =2
Note: U1 + U2 = mn = 16.

This is true in general


For each pair (xi,yj) either xi < yj or xi > yj (Assume no
ties)

In one case U1 will be increased by 1 while in the other


case U2 will be increased by 1.

There are mn such pairs.


An Alternative way of computing the Mann-Whitney
test statistic U
Arrange the observations from the two samples
combined in increasing order (retaining sample
membership) and assign ranks to the observations.
25(1) 26(1) 27(1) 28(2) 29(2) 31(1) 32(2) 35(2)
1 2 3 4 5 6 7 8
Let W1 = the sum of the ranks for sample 1.
= 1 + 2 + 3 + 6 = 12
Let W2 = the sum of the ranks for sample 2.
= 4 + 5 + 7 + 8 = 24
It can be shown that
n  n  1
U1  nm   W1
2
m  m  1
and U 2  nm   W2
2
Note: W  W  1  2  3     n  m    n  m  n  m  1
1 2
2
n  n  1 m  m  1  n  m  n  m  1
U1  U 2  2nm   
2 2 2
4nm  n  n  1  m  m  1   n  m  n  m  1

2
4nm  n  n  m  m   n 2  2nm  m 2  n  m 
2 2

  nm
2
• The distribution function of U (U1 or U2) has
been tabled for various values of n and m (<n)
when the two observations are coming from
the same distribution.
• These tables can be used to set up critical
regions for the Mann-Whitney U test.
Example
A researcher was interested in comparing “brightness” of
paper prepared by two different processes
A measure of brightness in paper was made for n = m = 9
samples drawn randomly from each of the two processes. The
data is presented below:
Process A 6.1 9.2 8.7 8.9 7.6 7.1 9.5 8.3 9.0
Process B 9.1 8.2 8.6 6.9 7.5 7.9 8.3 7.8 8.9
Process A Process B Ranks averaged
xi rank yj rank because
observations are
6.1 1 9.1 16 tied

9.2 17 8.2 8
8.7 12 8.6 11
8.9 13.5 6.9 2
WA = 94
7.6 5 7.5 4
7.1 3 7.9 7
WB = 77
9.5 18 8.3 9.5
8.3 9.5 7.8 6
9.0 15 8.9 13.5
It can be shown that
n  n  1 9 10 
U A  nm   WA  9 9    94  32
2 2
and
m  m  1 9 10 
U B  nm   WA  9 9    77  49
2 2
From table for n = m = 9
P U i  18  .025
Hence we will reject H0 if either UA or UB ≤ 18.

Thus H0 is accepted
The Mann-Whitney test for large
samples
For large samples (n > 10 and m >10) the
statistics U1 and U2 have approximately a
Normal distribution with mean and standard
nm
deviation U i 
2
nm  n  m  1
 Ui 
12
Thus we can convert Ui to a standard normal
statistic
nm
U i  U i Ui 
z  2
 Ui nm  n  m  1
12

And reject H0 if z < -za/2 or z > za/2 (for a two


tailed test)
The Kruskal Wallis Test

• Comparing the central location for k


populations
• An nonparametric alternative to the one-way
ANOVA F-test
Situation:

Data is collected from k populations.


The sample size from population i is ni.
The data from population i is:
xi1 , xi 2 ,  , xini i  1, 2,  .k
The computation of The Kruskal-Wallis statistic
We group the N = n1 + n2 + … + nk observation from k
populations together and rank these observations from
1 to N.

Let rij be the rank associated with with the observation


xij.

Handling of “tied” observations


If a group of observations are equal the ranks that
would have been assigned to those observations are
averaged
The computation of The Kruskal-Wallis statistic
Let
ri1  ri 2    rini
ri   the average rank for the i th sample
ni
r  the average rank for all the observations.
1 2  3   N N 1
 
N 2

Note: If the k populations do not differ in


central location the
r1 , r2 , , rk should be approximately equal
and close to r .
The Kruskal-Wallis statistic
12 k

 ni  ri  r 
2
K
N  N  1 i 1

3  N  1
2 2
12 k
U
 
N  N  1 i 1 ni
i

 N  1
ni
where U i   rij  ri1    rini
j 1

= the sum of the ranks for the ith


sample
The Kruskal-Wallis test

Reject
H0: the k populations have same
central location

if K  2 with d . f .  k  1
Example
In this example we are measuring an enzyme
level in three groups of patients who have
received “open heart” surgery. The three groups
of patients differ in age:
1. Age 30 – 45
2. Age 46 – 60
3. Age 61+
The data

Age Group
30 - 45 46 - 60 61+
218.3 166.1 197.9
140.8 124.1 120.6
268.4 84.3 81.1
201 124.2 181.6
70.2 118.9
70.7
Computation of the Kruskal-Wallis
statistic
The raw data The data ranked
Age Group Age Group
30 - 45 46 - 60 61+ 30 - 45 46 - 60 61+
218.3 166.1 197.9 14 10 12
140.8 124.1 120.6 9 7 6
268.4 84.3 81.1 15 4 3
201 124.2 181.6 13 8 11
70.2 118.9 1 5
70.7 2
ri 12.75 5.33 7.40
Ui 51 32 37
3
U i2 512 322 37 2

i 1 ni

4

6

5
 1094.717
The Kruskal-Wallis statistic
3  N  1
2 2
12 k
U
K  i

N  N  1 i 1 ni

 N  1
3 16 
2
12
 1094.717    7.698
15 14  14
2
since K   0.05  5.99 for df  k  1  2

H0 is rejected.
There are significant differences in the central
enzyme levels between the three age groups

You might also like