You are on page 1of 6

Non Parametric Tests

Rohit Vishal Kumar


April 24, 2008

Contents ordinal data. We shall study some of the com-


mon non-parametric test.
1 Introduction 1

2 Mann-Whitney U Test 1 2 Mann-Whitney U Test


2.1 Steps in Computation . . . . . . . 1
2.2 Example . . . . . . . . . . . . . . . 2 This is is normally used when the measure-
2.3 Remarks . . . . . . . . . . . . . . . 2 ment is ordinal and is from two independe-
nt samples. This test is used to determine
3 Kruskal Wallis H Test 3 whether the samples are from the same pop-
ulation or not. It is a relatively powerful
4 The Sign Test 3 non-parametric test and is an alternative to
4.1 Sign test for small samples . . . . 3 “Student’s - T” test, especially so when the
4.2 Sign test for large samples . . . . 4 data cannot meet the assumptions of T test.
4.3 Remarks . . . . . . . . . . . . . . . 4 Both one-tailed or two-tailed test can be per-
formed.
5 Wilcoxon Rank Sum T Test 5
2.1 Steps in Computation
6 Wald Wolfowitz Run Test 5
Step 1 Combine all sample values in an ar-
7 Run Test for Randomness 6 ray from the smallest to the largest and as-
sign ranks to all these values. If two or more
8 Advantages of Non-Parametric Test 6 sample values are identical (i.e. there is a
tie), the sample values are each assigned a
9 Disadvantages of Non-Parametric rank equal to the mean of the ranks that
Test 6 would otherwise be assigned. For example,
if a value xi occupies rank 12 and 13 in the
array, then the rank assigned to them each
1 Introduction would be 21 (12 + 13) = 12.5.

Most of the testing of hypothesis considered


Step 2 Find the sum of the ranks for each of
in statistics is based on the assumption that
the samples. Denote these sums by R1 and R2
the population follows a particular probabil-
corresponding to the sample sizes N1 and N2
ity distribution. Situations arise in practise
respectively. For convenience choose N1 as
in which such assumptions may not be justi-
the smaller size if they are unequal, so that
fied or in which there is doubt that they ap-
N1 ≤ N2 . A significant difference between the
ply, as in the case where the population may
rank sums R1 and R2 implies a significant dif-
be highly skewed. Because of this statisti-
ference between the samples.
cians have devised several tests and methods
that are independent of population distribu-
tion and associated parameters. These are Step 3 To test the difference between the
called non-parametric tests. rank sums, corresponding to sample 1, use
Non-parametric tests can be used as a the following statistic:
shortcut replacement for more complicated
tests. They are specially valuable in dealing N1 (N1 + 1)
with non-numeric data specially nominal and U = N1 N2 + − R1 follows N(0,1)
2

1
Alloy I Rank
18.3 12
NOTE: The assumption of normality is only 16.4 10
valid when both n1 , n2 > 8 22.7 16
17.8 11
18.9 13
Step 4 The sampling distribution of U is 25.3 18
symmetrical and has a mean and variance 16.1 9
given respectively by the formula µU = N1 N2 /2 24.2 17
2
and σU = N1 N2 (N1 + N2 + 1)/12 which needs to Total 106
be calculated.
Computing the sum of ranks for Alloy II we
have
Step 5 We compute the Z value by convert- Alloy II: Rank
ing as follows Z = (U − µU )/σU and then com- 12.6 3
pare it with the relevant Z table and draw the 14.1 5
conclusion. 20.5 15
10.7 1
15.9 8
2.2 Example 19.6 14
12.9 4
Given the following data about the strength 15.2 7
of the cables made from two different alloys, I 11.8 2
and II, determine using Mann-Whitney U Test 14.7 6
whether there is a significant difference be- Total 65
tween the strength of the cables made from
alloy I and alloy II? Since the alloy I samples have the smaller
Alloy I Alloy II sample size N1 = 8 we assign R1 = 106 and
18.3 12.6 R2 = 65 then we have:
16.4 14.1
22.7 20.5
17.8 10.7 8(8 + 1)
U = (8)(10) + − 106
18.9 15.9 2
25.3 19.6 = 10
16.1 12.9
24.2 15.2 We now compute the mean as µU =
11.8 N1 N2 /2 = (8)(10)/2 = 40 and the variance as
14.7 2
σU = N1 N2 (N1 + N2 + 1)/12 = (8)(10)(8 + 10 +
1)/12 √= 126.67. Then the standard deviation
σU = 126.67 = 11.25.
Solution We organise the data into an array Now computing the Z statistic we have Z =
starting from the smallest to the largest and (U − µ )/σ = (10 − 40)/11.25 = −2.67.
U U
give ranks from 1 to 18 as follows:

Data Rank Data Rank Conclusion Now because the value of


10.7 1 16.4 10 Zcalc = −2.67 > Z0.05 = −1.96 we reject the
11.8 2 17.8 11 null hypothesis (i.e. that there is no differ-
12.6 3 18.3 12 ence in the strength of the two alloys) and
12.9 4 18.9 13 conclude that there is significant difference
14.1 5 19.6 14 between the strength of two alloys.
14.7 6 20.5 15
15.2 7 22.7 16
15.9 8 24.2 17 2.3 Remarks
16.1 9 25.3 18
1. To test the difference between the rank
Computing the sum of ranks for Alloy I we sums, corresponding to sample 2, use the
have following statistic:

2
taken over all the observations. If there are
no ties then T = 0 and C reduces to 1, so that
N2 (N2 + 1)
U = N1 N2 + − R1 no correction is needed. In practise, the cor-
2
rection is usually negligible (i.e. not enough
follows N(0,1) to warrant a change in the decision).
The sampling distribution of U is sym- The H test provides a non parametric
metrical and has a mean and variance method in the analysis of variance for one
given respectively by the formula µU = way classification, or one-factor experiments
2 and generalisations can be made.
N1 N2 /2 and σU = N1 N2 (N1 + N2 + 1)/12.
2. Mann Whitney U test should be avoided
if N1 or N2 is ≤ 8. Under such a situation
it is better to use T-test.
4 The Sign Test
3. U1 + U2 = N1 N2 and R1 + R2 = (N1 +
N2 )(N1 + N2 + 1)/2. These provide a check
for the correctness of the calculation. 4.1 Sign test for small samples

The sign test is the simplest of all the non


3 Kruskal Wallis H Test parametric test. It names comes from the fact
that it is based on the direction (or signs for
The U test is a non parametric test for de- pluses and minuses) of a pair of observations
ciding whether or not two samples come from and not on their numerical magnitude. In any
the same population. A generalisation of this problem of sign test we count (a) the number
for k samples is provided by the Kruskal - of (+)ve signs (b) the number of (−)ve signs (c)
Wallis H Test. This test may be described number of 0’s (zeros) i.e. which cannot be in-
as follows: Suppose that we have k samples cluded either as positive or negative. In case
of size N1 , N2 , N3 , · · · Nk , with the total sizethere is a tie i.e. both the values are same,
of all samples taken together being given by thereby giving zero as the difference, the con-
N = N1 + N2 + N3 + · · · + Nk . Suppose fur- vention is that we drop that particular pair of
ther that the data from all the samples are observation(s) and work with the remaining.
taken together and ranked and that the sum
It is hypothesised that if the difference in
of ranks for the k samples are R1 , R2 , R3 , · · · Rk
signs are purely due to chance then the prob-
respectively. Then the statistic
ability of a (+)ve sign is 1/2 and that of a
(−)ve sign is 1/2. If S is the number of times
k
X Rj 2 the less frequent sign occurs, then S has a
12
H = − 3(N + 1) binomial distribution with p = 1/2. We take
N (N + 1) j=1 Nj
H0 : p = 0.5 as the null hypothesis.
can be shown to follow χ2 distribution with The critical value for a two sided test at
(k-1) degrees of freedom provided that Nk ’s α = 0.05 can be conveniently found by the ex-
are all at least ≥ 5 and that there are no ties pression:
in rank.
In case there are too many ties amongst the
observations in the sample data, the value of n−1 √
H is smaller than it should be. The corrected K = − (0.98) n
2
value of H, denoted by HC is obtained by di-
viding the value of H by the correction factor
(C) i.e. The null hypothesis H0 is rejected if S ≤ K.

HC = H/C
P 3
(T − T ) Example Use the sign test to see if there is
where C = 1− a difference between the number of days until
N3 − N
the collection of account receivable before and
where T is the number of ties correspond- after a new collection policy is implemented.
ing to each observation and where the sum is Use the 0.05 level of significance.

3
Before After (1st - 2nd) Example The following data relates to the
Calculated daily production of cement (in million tons) of
30 32 − a cement plant for 30 days. Use sign test to
28 29 − test the null hypothesis that the plants daily
34 33 + average production of cement is 11.2 million
35 32 + tom against the alternative hypothesis that it
40 37 + is less than 11.2 million tons at the 0.05 level
42 43 − of significance:
33 40 −
38 41 − 11.5 10.0 11.2 10.0 12.3
34 37 − 11.1 10.2 9.6 8.7 9.3
45 44 + 9.3 10.7 11.3 10.4 11.4
28 27 + 12.3 11.4 10.2 11.6 9.5
27 33 − 10.8 11.9 12.4 9.6 10.5
25 30 − 11.6 8.3 9.3 10.4 11.5
41 38 +
36 36 0 Solution Putting + or − signs after compar-
ing with 11.2 we have:
Solution The number of plus and minus
signs for each pair is shown along with the + − 0 − +
raw data in the figure above − − − − −
− − + − +
From the above we see that there are 8
+ + − + −
(−)ve signs, 6 (+)ve sings and 1 zero. As per
− + + − −
the convention we drop the pair giving rise to
+ − − − +
zero. Then n = 15 − 1 = 14 and S = 6 as the
(+)ve sing is less frequent. Calculating the
The number of plus signs: 11
value of K we have:
The number of minus signs: 18
Number of zeros: 1
14 − 1 √ Total Sample Size: 30
K = − (0.98) 14
2
= 6.50 − 3.67 Hence we have the following: X = 11, n = 29
and p = 1/2. Substituting the values in the
= 2.83
formula we have:

Since S > K the null hypothesis is accepted 11 − 29(0.5)


Z = p
and we may conclude that there is no signifi- 29(0.5)(1 − (0.5))
cant difference in the number of days between 11 − 14.5
an accounts receiveable before and after the = √
7.25
introduction of a new policy. −3.5
= √
7.25
4.2 Sign test for large samples = −1.2998

For large samples, generally considered for


n > 25 the normal approximation to the bino- Since |Zcalc = −1.299| ≤ |Ztab,0.05 = −1.645|
mial may be used, correcting for continuity. we cannot reject the null hypothesis and con-
The actual value of Z can be calculated using clude that the plants average production of
the formula: cement may be equal to 11.2 million tons per
day.
(X − np)
Z =
4.3 Remarks
p
np(1 − p)
1. The sign test is used for observations that
where X is the number of times the less fre- have been randomly selected in pairs, us-
quent sign occurs. ing a paired difference experiment.

4
2. It is one of the few test that can be em- 6 Wald Wolfowitz Run Test
ployed when the only information avail-
able is that one observation exceeds an- Wald Wolfowitz Run test is a non-parametric
other or vice versa. test for testing the null hypothesis that the
distribution functions of two continuous
3. According to some statisticians, sign test populations are the same.
should always be used with caution, as Suppose x1 , x2 , x3 . . . , xn1 is an ordered sam-
the rejection or non-rejection depends ple from a population with the density func-
random pairing. Or in other words the tion f1 (.) and let y1 , y2 , y3 . . . , yn2 be an inde-
one set of pairing of the same data may pendent ordered sample from another popu-
lead to rejection whereas another may lation with density function f2 (.). What we
lead to acceptance. want to test is whether the samples have been
drawn from the same population or from pop-
ulations with the same density functions i.e.
5 Wilcoxon Rank Sum T f1 (.) = f2 (.). Let us combine the two samples
Test and arrange the observations in order of mag-
nitude to give the combined ordered sample
This test is used for testing dependent sam- as x1 x2 x3 y1 y2 y3 y4 x4 x5 . . ..
ples in which data is collected in matched A Run is defined as a sequence of letters of
pairs. This test takes into account both the any kind surrounded by sequence of letters of
direction of differences within a pair of obser- the other kind and the number of elements in
vations and the relative magnitude of differ- a run is usually referred to as the length (l)
ences. It gives more weight to the pairs show- of the run. In the above example we have, in
ing large differences; than to pairs showing order, a run of x (l = 3), a run of y (l = 4), a
small differences. To use this test, measure- run of x (l = 2) etc.
ment must at least be ordinally scaled within If both the samples come from the same
pairs. population then there would be a thorough
For the Wilcoxon Rank Sum Test, the basic mingling of x’s and y’s and consequently
idea is that if the sample’s are from the same the number of runs in the combined sam-
population. If this assumption is true then it ple would be large. On the other hand if
can be assumed that the difference between the samples come from two different popu-
the pairs (either + or -) should be symmetri- lations so that their ranges do not overlap
cally distributed around a central value. then there would be only two runs of type
x1 , x2 , x3 . . . , xn1 and y1 , y2 , y3 . . . , yn2 .
Assume that there are N pairs of values
In order to test the Null Hypothesis H0 :
(x1 , y1 ), (x2 , y2 ), . . . , (xN , yN ). Let the HO be
f1 (.) = f2 (.) i.e. the samples have come from
that the N pairs of observations have been
the same population, we count the number
drawn from identical (or same) population.
of runs (’U ’) in the combined ordered sample.
Compute the list of differences δj = (xj − yj ).
Null Hypothesis is rejected if U < u0 where the
Next, sort the absolute values of differences
value of u0 is determined from considering the
{|δj |} into ascending order. Add up the ranks
distribution of U under H0 .
assigned to the positive differences and call it
W +. Similarly find the sum of the ranks as- Given that n1 , n2 are the number of obser-
signed to the negative differences and call it vations of x, y respectively under the null hy-
W −. pothesis we have:
For N > 25 the following test statistic is ap-
plicable: 2n1 n2
E(U ) = +1
(n1 + n2 )
T − µT 2n1 n2 (2n1 n2 − n1 − n2 )
z = follows N(0,1) V ar(U ) =
σT (n1 + n2 )2 (n1 + n2 − 1)
N (N + 1)
where µT =
r 4 and we can use the normal test
N (N + 1)(2N + 1)
σT = U − E(U )
24 Z = p
T = min{W +, W −} V ar(U )

5
follows N (0, 1) asymptotically. parametric methods are readily applica-
This approximation is a fairly good repre- ble.
sentation if n1 , n2 ≥ 10. Since the alternative
hypothesis is ’too few runs’ the test is ordi- 4. Since the socio-economic data are not, in
narily one tailed with only negative values. general, normally distributed, non para-
The test has a very low power; its relative ef- metric test have found application in var-
ficiency compared to the traditional t test for ious social sciences like — Psychometry,
equal variances is zero. Furthermore, it has Sociology and Educational Statistics etc.
the least power compared to other nonpara- 5. Non Parametric tests are available to deal
metric tests applied to the same data. with data which are given in ranks or
grades.
7 Run Test for Randomness
9 Disadvantages of Non-
Another application of the ’run’ test is in the
testing of randomness of a given set of ob- Parametric Test
servations. Let x1 , x2 , x3 . . . , xn be the set of
observations arranged in the order in which 1. Non Parametric test can be used only if
they occur i.e. xi is the ith observation in the measurement are nominal or ordi-
the outcome of an experiment. Then, for nal. Even in that cases, if parametric test
each of the observations, we see if it is be- exists they are more powerful than non
low or above the value of the median of the parametric test.
observations and we write A if the observa- 2. Non Parametric tests are designed to test
tion is above the median and B if the ob- statistical hypothesis only and not for es-
servation is below the median value. Thus timating parameter.
we get a sequence of A’s and B’s of the type
A A A B A B B B B A B A B say. 3. So far, no Non Parametric test is available
Then, under the Null Hypothesis, H0 that for testing interactions in ANOVA model
the set of observations is random the number unless specific assumptions are made
of runs, denoted by U is a random variable about the additivity of the the model.
with

n+2 This document can be obtained from:


E(U ) =
2 Rohit Vishal Kumar
n (n − 2) Reader - (Department of Marketing)
V ar(U ) = Xavier Institute of Social Service
4 (n − 1)
P.O. Box No: 7, Purulia Road
Ranchi - 834 001, Jharkhand, India
Phone: (91-651) 2241-8694 / 8695 Ext. 405
For large n (say > 25), U may be regarded Email: rohitvishalkumar@yahoo.com
as asymptotically normal and we may use the Website: www.iiswbm.edu
normal test. Final Print on: April 24, 2008

8 Advantages of Non-
Parametric Test
1. Non Parametric tests are readily compre-
hensible, easy to apply and do not require
complicated sample theory.

2. No assumption is made about the form of


frequency function of the parent popula-
tion from which sampling is done.

3. No parametric will apply to the data


which are mere classifications, while non

You might also like