Você está na página 1de 12

Department of Applied Mathematics

Chapter 5. Non-parametric tests

Marjorie Chiu, 2009 5-1
Chapter 5. on-parametric tests

Non-parametric test is used to analyze data when the basic assumptions, for example,
normality and equal variances, are violated. It is also known as distribution-free test because
there are no assumptions about the underlying distribution of the data. A set of observed data
is tested whether they come from certain distribution. The chi-square test makes no
assumptions about the underlying distribution of the random sample of data. The binomial
test assumes a binomial distribution. The Kolmogorov-Smirov test is used to test whether the
observed data comes from a normal, Poisson or uniform distribution. Another tests such as
sign test, Mann-Whitney test and Wilcoxon signed ranks test are non-parametric counterparts
of the z-test or t-test.

5.1. Chi-square test
The expected frequencies of each of the k categories are evaluated when the null
hypothesis is true. The test statistic composes of the differences between the observed
and expected frequencies, its formula is
( )

=
k
i i
i i
E
E O
1
2
2

where
i
O and
i
E are the observed and expected frequency for the i th category
respectively, and k is the total number of categories.
Remark: The expected frequency must be at least equal to 5.

Example 1: (equity)
One measure of the health of the banking industry is the return on equity. The
suggestion has been that for 1997 about 20% of the banks would have a return on
equity less than 10%, 30% would fall between 10% and 15%, 30% would be between
15% and 20%, and 20% would be above 20%. Test whether the following sample of
50 banks supports this suggestion at 1% level of significance.

1997 Return on equity - banks
<10% 10-15% 15-20% >20%
Frequency 9 21 14 6

Department of Applied Mathematics
Chapter 5. Non-parametric tests
Marjorie Chiu, 2009 5-2
Create the variable (equity) and label its value.
Create another variable (count) which contain the observed frequency of each
category.
Weight the categories
Data
Weight cases
Frequency variable: count
Perform chi-square test
Analyze
onparametric Tests
Legacy Dialogs
Chi-square
Test variable list: equity
Expected values: 10, 15, 15 and 10
The hypotheses become
0
H : Return of equity follows the suggestion
1
H : Return of equity does not follow the suggestion

Chi-Square Test
Frequencies

equity
9 10.0 -1.0
21 15.0 6.0
14 15.0 -1.0
6 10.0 -4.0
50
<10%
10-15%
15-20%
>20%
Total
Observed
N Expected N Residual
Department of Applied Mathematics
Chapter 5. Non-parametric tests
Marjorie Chiu, 2009 5-3

Since the asymptotic significance of the test statistic equals to 0.244, there is no
evidence to against the null hypothesis. The return of equity follows the suggestion.

5.2. Binomial Test
Binomial test is applied to test whether the data comes from a binomial distribution.
The expected frequencies are evaluated from the binomial distribution. The data
should be in binary, that is, 0 or 1. The hypotheses are
0
H : The observation follows a binomial distribution
1
H : The observation does not follow a binomial distribution

Example 2: (survey.sav)
The distribution of the number of female in the survey data can be tested using non-
parametric method. The variable sex has been recoded into another variable sex1
before.
Analyze
onparametric tests
Legacy Dialogs
Binomial
Test variable: sex1
Test proportion: 0.5
Define Dichotomy with cut point: 0

0
H : The number of female follows a binomial distribution with p=0.5
1
H : The number of female doesnt follow a binomial distribution
The value of sex1
less than or
equal to 0 will be
assigned to one
group and the
others form
another group.
Test Statistics
4.167
3
.244
Chi-Square
a
df
Asymp. Sig.
equity
0 cells (.0%) have expected frequencies less than 5.
The minimum expected cell frequency is 10.0.
a.
Department of Applied Mathematics
Chapter 5. Non-parametric tests
Marjorie Chiu, 2009 5-4
NPar Tests

The above results depict that the asymptotic significance is 0.155. It means that the
number of female follows a binomial distribution with p=0.5 at 5% level of
significance.

5.3. Runs Test
The randomness of a sequence of observations is tested by the runs test.
0
H : The order of the observations is random
1
H : The order of the observations is not random

Example 3: (survey.sav)
The randomness of the sequence of male and female in the survey data is tested using
the runs test.
Analyze
onparametric tests
Legacy Dialogs
Runs
Test variable list: sex1
Cut point (custom: 1)

Binomial Test
<= 0 15 .38 .50 .155
a
> 0 25 .63
40 1.00
Group 1
Group 2
Total
recode sex
Category N
Observed
Prop. Test Prop.
Asymp.
Sig.
(2-tailed)
Based on Z Approximation.
a.
The value of sex1 less than 1 will be
assigned to one group and the others
form another group.
Department of Applied Mathematics
Chapter 5. Non-parametric tests
Marjorie Chiu, 2009 5-5
NPar Tests

The result of the runs test shows that there is no evidence to against the null
hypothesis. The order of male and female in the survey data is in random.

5.4. Kolmogorov-Smirov Test
Other types of distribution such as Poisson and normal, are tested by the Kolmogorov-
Smirov test.

Example 4: (battery)
The following table shows the observed frequency of battery lives:
Class boundaries Class mark Observed frequency
1.45-1.95 1.7 2
1.95-2.45 2.2 1
2.45-2.95 2.7 4
2.95-3.45 3.2 15
3.45-3.95 3.7 10
3.95-4.45 4.2 5
4.45-4.95 4.7 3

Perform the goodness-of-fit to test whether the lifetime of batteries follows the normal
distribution.

0
H : The lifetime of batteries follows the normal distribution
1
H : The lifetime of batteries does not follow the normal distribution
Type in the class mark (class) and observed frequency (count) into the data editor
Weight the cases by the frequency
Runs Test
1
40
17
-.770
.441
Test Value
a
Total Cases
Number of Runs
Z
Asymp. Sig. (2-tailed)
recoded
sex
User-specified.
a.
Department of Applied Mathematics
Chapter 5. Non-parametric tests
Marjorie Chiu, 2009 5-6
Perform the test
Analyze
onparametric tests
Legacy Dialogs
1-sample KS
Test variable list: class
Test distribution: normal

NPar Tests

The above table lists out the mean and standard deviation of the sample data together
with the test statistic and the asymptotic significance. The sample data does not have
evidence to against the null hypothesis of normality at 5% level of significance.

5.5. Sign test
Parametric tests such as z-test and t-test, cannot be used for small sample if the
underlying distribution is non-normal, and sign test may be used instead. The sign test
is specifically designed for testing hypothesis about the median of any continuous
distribution.

One-tailed test
0
H :
0
=
1
H :
0
> or
1
H :
0
<
One-Sample Kolmogorov-Smirnov Test
40
3.412
.697
.205
.170
-.205
1.298
.069
N
Mean
Std. Deviation
Normal Parameters
a,b
Absolute
Positive
Negative
Most Extreme
Differences
Kolmogorov-Smirnov Z
Asymp. Sig. (2-tailed)
CLASS
Test distribution is Normal.
a.
Calculated from data.
b.
Department of Applied Mathematics
Chapter 5. Non-parametric tests
Marjorie Chiu, 2009 5-7
Test statistic for a single population is
S = number of sample observations greater than
0
or S = number of sample
observations less than
0

The observed significance level is p-value = ( ) S x P
Two-tailed test
0
H :
0
=
1
H :
0

Test statistic for a single population is
S = larger of S
1
, S
2

S
1
= number of sample observations greater than
0
and
S
2
= number of sample observations less than
0

The observed significance level is p-value = 2 ( ) S x P

Rejection region: Reject
0
H if p-value < .
Remark: x has a binomial distribution with parameters n and = 0.5.

For n 10, the test statistic of the sign test is
n
n S
z
5 . 0
5 . 0
=
The rejection region of the one-tailed test and two-tailed test are

z z > and
2

z z > respectively.

Example 5: (process time)
The following are the processing time (in minutes) at which every fifth assembly part
was timed: 46, 58, 60, 56, 70, 66, 48, 54, 62, 41, 39 and 52. Test the null hypothesis
of median=55 at the 0.05 level of significance.
Analyze
onparametric tests
Legacy Dialogs
Binomial
Test variable list: time
Department of Applied Mathematics
Chapter 5. Non-parametric tests
Marjorie Chiu, 2009 5-8
Cut point (custom: 55)

NPar Tests

Binomial Test

Category N Observed Prop. Test Prop.
Exact Sig. (2-
tailed)
processing time (minutes) Group 1 <= 55 6 .50 .50 1.000
Group 2 > 55 6 .50

Total

12 1.00

The asymptotic significance of the test statistic is 1.000, which is greater than the 0.05
level of significance. It means that there is no evidence to against the null hypothesis
that the median processing time equals to 55 minutes.

5.6. Mann-Whitney test
The Mann-Whitney test is an alternative test to compare the center of location of two
independent samples, when the normal distribution assumption cannot be fulfilled.
The Wilcoxon statistic, W, is calculated by ranking the pooled observations of the two
samples and obtaining the sum of the ranks of the population with the smaller sample
size. The Mann-Whitney statistic U is
( )
1
1 1
2 1
2
1
T
n n
n n U
+
+ =
where
1
n and
2
n are the sample sizes of the two groups, and
1
T is the sum of ranks of
one of the samples. The null hypothesis is
0
H :
1
D and
2
D are identical, and the
alternative hypothesis for the one-tailed test is
1
H :
1
D is shifted to the right of
2
D (or
1
H :
1
D is shifted to the left of
2
D ); and for the two-tailed test is
1
H :
1
D is shifted
either to the right or to the left of
2
D . (
1
D and
2
D represent the relative distribution
for population 1 and 2 respectively.)
For large samples (sample sizes at least 10), the test statistic is
Department of Applied Mathematics
Chapter 5. Non-parametric tests
Marjorie Chiu, 2009 5-9
( )
( )
12
1
2
1
2 1 2 1
1 1 2 1
1
+ +

+ +

=
n n n n
n n n n
T
z
the corresponding critical region for the one-tailed and two-tailed test are

z z > (or

z z < ) and
2

z z > respectively.

Example 6: (nano3.sav)
Analyze
onparametric tests
Legacy Dialogs
2 independent samples
Test variable list: weight
Group variable: fertilizer
Group 1: 0
Group 2: 1
Test type: Mann-Whitney U

NPar Tests
Mann-Whitney Test

Ranks
10 7.35 73.50
10 13.65 136.50
20
Fertilizer
No nitrogen
With nitrogen
Total
WEIGHT
N Mean Rank
Sum of
Ranks
Test Statistics
b
18.500
73.500
-2.386
.017
.015
a
Mann-Whitney U
Wilcoxon W
Z
Asymp. Sig. (2-tailed)
Exact Sig. [2*(1-tailed
Sig.)]
WEIGHT
Not corrected for ties.
a.
Grouping Variable: Fertilizer
b.
Department of Applied Mathematics
Chapter 5. Non-parametric tests
Marjorie Chiu, 2009 5-10

The Mann-Whitney U statistic is 18.5 while the Wilcoxon W statistic is 70, the
significance level of the test statistic is 0.017. The distribution of weight of stems is
different in adding fertilizer at 5% level of significance.

5.7. Wilcoxon signed ranks test
Wilcoxon signed ranks test is the non-parametric counterpart of the paired sample t-
test. Firstly, we assign ranks to the absolute values of the differences and then base
the comparison on the rank sums of the negative (

T ) and positive (
+
T ) differences.
Differences equal to zero are eliminated and the number of differences is adjusted.
Tied absolute differences have ranks equal to the average of the ranks they would
have if they are not tied. The null hypothesis is
0
H :
1
D and
2
D are identical, and the
alternative hypothesis for the one-tailed test is
1
H :
1
D is shifted to the right of
2
D (or
1
H :
1
D is shifted to the left of
2
D ); and for the two-tailed test is
1
H :
1
D is shifted
either to the right or to the left of
2
D . (
1
D and
2
D represent the relative distribution
for population 1 and 2 respectively.) The test statistic of the one-tailed test is

T (or
+
T ) with critical region
0
T T

(or
0
T T
+
) where
0
T is given in table. On the other
hand, the test statistic of the two-tailed test is T, the smaller of

T or
+
T , with critical
region
0
T T . In large sample (sample size at least 25), the test statistic
( ) [ ]
( )( ) 24 1 2 1
4 1
+ +
+
=
+
n n n
n n T
z is asymptotically normally distributed (
+
T is chosen
arbitrarily).

Example 7: (medical)
Analyze
onparametric tests
Legacy Dialogs
2 related samples
Test pair(s) list: after, before
Test type: Wilcoxon

Department of Applied Mathematics
Chapter 5. Non-parametric tests
Marjorie Chiu, 2009 5-11
NPar Tests
Wilcoxon Signed Ranks Test

The asymptotic significance level 0.107 is greater than the nominal significance level
0.05, therefore there is no evidence to against the null hypothesis that the distribution
of medical expenses before and after the implementation of lunchtime exercise are
identical.

Ranks
4
a
4.63 18.50
8
b
7.44 59.50
0
c
12
Negative Ranks
Positive Ranks
Ties
Total
BEFORE - AFTER
N Mean Rank
Sum of
Ranks
BEFORE < AFTER
a.
BEFORE > AFTER
b.
AFTER = BEFORE
c.
Test Statistics
b
-1.612
a
.107
Z
Asymp. Sig. (2-tailed)
BEFORE -
AFTER
Based on negative ranks.
a.
Wilcoxon Signed Ranks Test
b.
Department of Applied Mathematics
Chapter 5. Non-parametric tests
Marjorie Chiu, 2009 5-12
Exercise 5

Question 1. (defects)
The following frequency table shows the number of surface defects on rectangular steel
plates. Test whether the number of surface defects follows Poisson distribution at 5% level of
significance.

Number of surface defects Frequency
0 5
1 6
2 4
3 3
4 3
5 2
6 1
7 0
8 1

Question 2. (salary)
Assume that the normality assumption of Question 1 in Exercise 3 cannot be fulfilled, use the
non-parametric tests to test whether the median of annual income of all company president is
250 (in 10 thousands of dollars) at 5% level of significance.

Question 3. (account)
Using the data of Question 2 in Exercise 3 to test whether women are more effective at
generating new accounts than the men by the non-parametric test.

Question 4. (inkjet)
Repeat the hypothesis testing of Question 3 in Exercise 3, assuming that the normal
assumption cannot be fulfilled.