Sie sind auf Seite 1von 19

Kruskal Wallis Test

{
If we have three or
more populations to
compare we use

Kruskal Wallis
Test

Independent Samples
One-way ANOVA for a completely randomized design is based on the
assumption of normality and equality of variance.
The nonparametric alternative not relying on these assumptions is
called the Kruskal-Wallis Test.
Like the Mann-Whitney/Wilcoxon Rank Sum Test we use the sum of
the ranks assigned to each group when considering the combined
sample as the basis for our test statistic.

Kruskal-Wallis Test
Kruskal-Wallis Test
Basic Idea:
1) Looking at all observations together,
rank them.
2) Let R1, R2, ,Rk be the sum of the ranks
of each group
3) If some Ris are much larger than
others,
it indicates the response values in
different groups come from different
populations.
Kruskal-Wallis Test

The test statistic is

12 k
Ri N 1
H
ni
N ( N 1) i 1 ni 2

~ k 1
2

where,
N = total sample size = n1 + n2 + ... + nk
Ri
average rank for group i
ni
N 1
average overall rank
2
Kruskal-Wallis Test
The test statistic is
12 k
Ri N 1
H
ni
N ( N 1) i 1 ni 2

~ k 1
2

Under the null hypothesis, this has an


approximate chi-square distribution
with k 1
2
df = k -1, i.e. .
The approximation is OK when each
group contains at least 5 observations.
N = total sample size = n1 + n2 + ... + nk
Test Statistic for KruskalWallis Test
12 1 ni(N + 1)
H = --------------
N(N + 1)
--- Ri -
ni
------------
2

A computational formula for the test statistic is

12 R1 R2 Rk
H = ------------- ----- + ----- + + ------- - 3(N + 1)
N(N + 1) n1 n2 nk

where
Ri is the sum of the ranks of the ith sample
R1 is the sum of the ranks squared for the first sample
R2 is the sum of the ranks squared for the second sample, and so on
n1 is the number of observations in the first sample
n2 is the number of observations in the second sample, and so on
N is the total number of observations (N = n1 + n2 + + nk)
k is the number of populations being compared.
Chi-squared Distribution and p-
value

k21

Area = p-value

2
A clinical trial evaluating the fever reducing
effects of aspirin, ibuprofen, and
acetaminophen was conducted. Study subjects
were adults seen in an ER with diagnoses of flu
with body temperatures between 100o F and
100.9o F. Subjects were randomly assigned to
treatment. Changes in body temperature were
recorded
2 hrs. after administration of treatments.

Example: Kruskal-Wallis
Test
Example: Kruskal-Wallis
Test Resulting Data: Temperature Decrease (deg. F)

Aspirin Rank Ibuprofen Rank Acetaminophen Rank


.95 8 .39 5 .19 4

1.48 14 .44 6 1.02 9

1.33 12 1.31 11 .07 3

1.28 10 2.48 15 .01 2

1.39 13 .62 7

-.39 1
(i.e. temp increase)

N = 15 R1 = 44 R2 = 50 R3 = 26
n1 = 4 n2 = 5 n3 = 6
N = 15 R1 = 44 H
12

k
R = 50
R N 1
ni i 2
R3 = 26
N ( N 1) i 1 ni 2
n1 = 4 12 44
n =5
15 21 50 15 1 26 15 1
n3 = 6
4 5 6
15(15 1) 4 2 5 2 6 2
6.833 ~ 22 i.e. chi - square distributi on with df 2

Example: Kruskal-Wallis
Test
Chi-squared Distribution and p-
value

6.833

Area = .033

2
2
Analyze > Fit Y by X

RESULTS
R1 = 44 n1 = 4
R2 = 50 n2 = 5
Kruskal-Wallis inR =JMP
26 n = 6
3 3

(Demo)
H = 6.833 df = 2
p = .033
Using the Kruskal-Wallis test have evidence to
suggest that the temperature changes after
taking the different drugs are not the same (p =
.033).

Now we might like to know which drugs


significantly differ from one another.

Decision/Conclusion
The Kruskal-Wallis test
ANOVA is based on the assumption of normality
There is a non-parametric alternative not relying this
assumption:
Looking at all observations together, rank them
Let R1, R2, ,RK be the sums of ranks of each group
If some Rs are much larger than others, it indicates the numbers
in different groups come from different populations
The Kruskal-Wallis test
The test statistic is

12 K
Ri2
W
n(n 1) i 1 ni
3(n 1)

Under the null hypothesis, this has an approximate


distribution.

K2 1

The approximation is OK when each group contains at least 5


observations.
Doctor A Doctor B Doctor C
24 (rank 1) 29 (rank 6.5) 29 (rank 6.5)
(We really have
26 (rank 2.5) 31 (rank 9.5) 27 (rank 4.5) too few
observations
31 (rank 9.5) 30 (rank 8) 34 (rank 12) for this test!)
27 (rank 4.5) 36 (rank 13) 26 (rank 2.5)
33 (rank 11)
Example:
R =48 previous
R1=17.5 2R =25.5 data 3
Use Analyze=>Nonparametric tests=>K
independent samples
For our data, we get

Ranks Test Statisticsa, b

VAR00002 N Mean Rank VAR00001


VAR00001 1 4 4,38 Chi-Square 4,195
2 5 9,60 df 2

Kruskal-Wallis in SPSS
3
Total
4
13
6,38 Asymp. Sig. ,123
a. Kruskal Wallis Tes t
b. Grouping Variable: VAR00002

Das könnte Ihnen auch gefallen