Lecture1 PDF
Lecture1 PDF
Nonparametric tests
Mikhail Zhelonkin
Erasmus University Rotterdam
Group 2 (Y)
3.1
8.0
5.6
4.0
6.5
6.1
Testing procedure
The null hypothesis together with other assumptions provide a known distribution. From this distribution we obtain the critical values for a given
level of significance .
The significance level (level of the test) is the probability that we reject the null hypothesis even if it
is true (type I error).
Reject
Not reject
t-Test
The test statistic is:
t=
X
r
sp n1x + n1y
where
v
u
2
u (nx 1)s2
+
(n
1)s
y
y
x
sp = t
nx + ny 2
P
P
= 1 nx Xi, Y
= 1 n y Yi .
is a pooled variance, and X
nx i=1
ny i=1
and Y
follow a normal disIf the random variables X
tribution then the test statistic follows a t-distribution
with nx + ny 2 degrees of freedom.
5
In our example
= 6, Y
= 5.55
X
2
s2
x = 0.544, sy = 3.123, nx = ny = 6
q
sp =
n
X
i=1
n
k
0.5n
Critical values:
The critical values are the tails at each end of the
distribution.
For the t-test we can find the critical values in the
table.
For the sign test we can calculate them ourselves.
For one-sided test we start from the bottom, i.e.
X > Y zero times, then 1 time, etc.. Or we can
start from above. We stop when the sum of probabilities is greater than .
For two-sided we start at both ends and move inwards. P (0) + P (n), then P (0) + P (1) + P (n 1) +
P (n), and so on until the probability is larger than
.
9
In our example
Group 1 (X)
5.1
6.3
6.2
5.5
7.2
5.7
Group 2 (Y)
3.1
8.0
5.6
4.0
6.5
6.1
sign
+
+
+
+
-
6
6
0.56 = 0.0156,
10
p(5) =
6
5
0.56 = 0.0938,
11
Example 2
The table below gives the reaction time of 9 people for
two experiments.
Person
1
2
3
4
5
6
7
8
9
Experiment 1
9.4
7.8
5.6
12.1
6.9
4.2
8.8
7.7
6.4
Experiment 2
10.3
8.9
4.1
14.7
8.7
7.1
11.3
5.2
7.8
12
13
Experiment 1
9.4
7.8
5.6
12.1
6.9
4.2
8.8
7.7
6.4
Experiment 2
10.3
8.9
4.1
14.7
8.7
7.1
11.3
5.2
7.8
Difference
+
+
-
Critical values
p(0) =
p(9) =
9
0
9
9
0.59 = 0.0019
0.59 = 0.0019
p(8) =
9
1
9
8
0.59 = 0.0175
0.59 = 0.0175
p(7) =
9
2
9
7
0.59 = 0.07
0.59 = 0.07
16
M n/2
z=
N (0, 1).
n/2
17
We can use additional information in the data, without making further assumptions about the distribution of the data - but we assume that the difference
have a symmetric distribution:
The difference between pairs of observations can be
positive or negative, but they can also be smaller
or larger.
We attribute no weight on the size of the difference but we simply observe that they are smaller or
larger.
18
If the distributions have the same location, the negative and positive differences should be of about the
same size.
The null hypothesis and the alternative are not altered but we have a different test statistic.
19
Group 2 (Y)
3.1
8.0
5.6
4.0
6.5
6.1
sign
+
+
+
+
-
abs.diff
2
1.7
0.6
1.5
0.7
0.4
rank
6
5
2
4
3
1
T + = 6 + 2 + 4 + 3 = 15, and T = 5 + 1 = 6
20
22
Group 2 (Y)
3.1
8.0
5.6
4.0
6.6
6.1
sign
+
+
+
+
-
abs.diff
2
1.7
0.6
1.5
0.6
0.4
rank
6
5
2.5
4
2.5
1
23
Ex 1
9.4
7.8
5.6
12.1
6.9
4.2
8.8
7.7
6.4
Ex 2
10.3
8.9
4.1
14.7
8.7
7.1
11.3
5.2
7.8
Sign
+
+
-
Abs.diff
0.9
1.1
1.5
2.6
1.8
2.9
2.5
2.5
1.4
rank
1
2
4
8
5
9
6.5
6.5
3
For large n:
If n is large, we can approximate the distribution of T
with the normal distribution:
n(n + 1)
,
E(T ) =
4
V ar(T ) =
n(n + 1)(2n + 1)
,
24
Hence
Z=q
T n(n + 1)/4
N (0, 1).
25
So the question is: What can we do when the observations are not in pairs?
If we have two populations with the same distribution, then the size of the observations should also
be equally distributed between the two populations.
26
28
Rank
1
2
3
4
5
6
7
8
9
10
11
12
Student
Y1
Y4
X1
X4
Y3
X6
Y6
X3
X2
Y5
X5
Y2
Grade
3.1
4.0
5.1
5.5
5.6
5.7
6.1
6.2
6.3
6.5
7.2
8.0
Critical values
We can calculate the critical values ourselves.
The Mann-Whitney U-test, which at face level is a different test from the Wilcoxon Rank-sum test, however,
we will show that the two tests are actually equivalent.
For the Mann-Whitney U-test we ask a different question: How many observations in the respective other
groups are of lower rank, i.e smaller?
If the population distributions have the same location,
then the ranks should be equal. A difference in the
ranks suggests that the location is not the same.
32
X1
X4
X6
X3
X2
X5
2
2
3
4
4
5
Y1
Y4
Y3
Y6
Y5
Y2
0
0
2
3
5
6
33
Test statistic.
What are the possible values for U ? 0, 1, 2, . . . , nxny .
The distribution of U is symmetric about nxny /2
For each c > 0 we have that
n n
n n
P (U 1 2 c) = P (U 1 2 + c)
2
2
Thus
P (U U0) = P (U n1n2 U0)
Quick check: If U0 = n12n2 c then
n1n2
c) = n1n2/2 + c
n1n2 U0 = n1n2 (
2
34
Critical values
rank
14
9.5
4
17
6
2
12
8
5
Ex 2
10.3
8.9
4.1
14.7
8.7
7.1
11.3
5.2
7.8
rank
15
13
1
18
11
7
16
3
9.5
Ui = 81 + 90/2 Wj =
32.5
48.5
38
exceeds
6
3.5
2
8
2
1
5
3
2
Ex 2
10.3
8.9
4.1
14.7
8.7
7.1
11.3
5.2
7.8
rank
8
7
0
9
6
4
8
1
5.5
What if n is large?
For large n we will use the approximation to the normal
distribution.
E(U ) = n1n2/2,
and
V ar(U ) = n1n2(n1 + n2 + 1)/12
Hence the standardized U-test statistic is
U n1n2/2
.
n1n2(n1 + n2 + 1)/12
Z=q
40