1. Kruskal-Wallis test
Friedman test
Spearmanās Correlation
Dr. S. A. Rizwan, M.D.,
Public Health Specialist,
Saudi Board of Preventive Medicine,
Riyadh, Kingdom of Saudi Arabia.
With thanks to Dr. Tajali Nazir Shora
2. Checklist of four questions
ā¢ Q1. What scales of measurement has been used?
ā¢ Q2. Which hypothesis has been tested?
ā¢ Q3. If the hypothesis of difference has been
tested, are the samples independent or
dependent?
ā¢ Q4. How many sets of measures are involved?
2
4. KW test
ā¢ The Kruskal-Wallis test is a nonparametric
test that can be used to determine whether
three or more independent samples were
selected from populations having the same
distribution.
H0: There is no difference in the group medians
Ha: There is a difference in the group medians
4
5. KW test
ā¢ This test is appropriate for use under the
following circumstances:
ā we have three or more conditions that you want to
compare;
ā each condition is performed by a different group of
participants;
ā the data do not meet the requirements for a
parametric test.
5
6. Requirements
ā¢ The data:
ā not normally distributed;
ā if the variances for the different conditions are
markedly different;
ā if the data are measurements on an ordinal scale.
ā¢ If the data meet the requirements for a
parametric test, it is better to use a one-way
independent-measures Analysis of Variance
(ANOVA)
6
7. Given three or more independent samples, the test statistic H
for the Kruskal-Wallis test is
Where: N represents the number of participants,
Tc is the rank total for each group
nc is the number of participants in each group
Reject the null hypothesis when H is greater than the critical number.
(always use a right tail test.)
KW test
7
8. Procedure
1
ā¢ Combine the observations of the various groups
2
ā¢ Arrange them in order of magnitude from lowest to highest
3
ā¢ Assign ranks to each of the observations and replace them in each of the
groups
4
ā¢ Original ratio data has therefore been converted into ordinal or ranked
data
5
ā¢ Ranks are summed in each group and the test statistic, H is computed
6
ā¢ Ranks assigned to observations in each of the groups are added
separately to give rank sums
8
9. Example
ā¢ Does physical exercise alleviate depression?
ā We find some depressed people and check that they
are all equivalently depressed to begin with. Then we
allocate each person randomly to one of three
groups:
ā¢ no exercise;
ā¢ 20 minutes of jogging per day; or
ā¢ 60 minutes of jogging per day.
ā At the end of a month, we ask each participant to
rate how depressed they now feel, on a Likert scale
that runs from 1 ("totally miserable") through to 100
(ecstatically happy"). 9
10. Appropriate test?
ā¢ We have three separate groups of participants.
ā¢ In each group each participant gives us a single
score on a rating scale.
(Ratings are examples of an ordinal scale of
measurement, and so the data are not suitable
for a parametric test)
10
11. KW test
The Kruskal-Wallis test will tell us if the
differences between the groups are so large that
they are unlikely to have occurred by chance.
11
15. Step 2: Find "Tc", the total of the ranks for each group. Just add
together all of the ranks for each group in turn.
ā¢ Tc1 (the rank total for the "no exercise" group)
is 76.5.
ā¢ Tc2 (the rank total for the "20 minutes" group)
is 79.5.
ā¢ Tc3 (the rank total for the "60 minutes" group)
is 144.
15
19. Step 4: Calculate the degrees of freedom
ā¢ The degrees of freedom is the number of
groups minus one.
Degrees of Freedom = Number of Groups - 1
ā¢ Here we have three groups, and so we have 2
d.f.
19
20. Step 5: Assess the significance of H
ā¢ Assessing the significance of H depends on
ā the number of participants and
ā the number of groups.
20
21. KW test
ā¢ Three groups, with ā¤ 5 participants in each
group, then use the special table for small
sample sizes.
ā¢ For more than five participants per group, treat
H as Chi-Square.
21
24. KW test
ā¢ H is statistically significant if it is equal to or
larger than the critical value of Chi-Square for
particular df
ā¢ Here, we have 8 participants per group, and so
we treat H as Chi-Square.
ā¢ H is 7.27, with 2 df
24
25. KW test
ā¢ Look along the row that corresponds to number
of degrees of freedom.
ā¢ We look along the row for 2 df
ā¢ We compare our obtained value of H to each of
the critical values in that row of the table,
starting on the left hand side and stopping once
our value of H is no longer equal to or larger
than the critical value.
25
26. KW test
ā¢ So here, we start by comparing our H of 7.27 to
5.99. With 2 degrees of freedom, a value of Chi-
Square as large as 5.99 is likely to occur by
chance only 5 times in a hundred: i.e. it has a p
of .05.
ā¢ Our obtained value of 7.27 is even larger than
this, and so this tells us that our value of H is
even less likely to occur by chance.
ā¢ Our H will occur by chance with a probability
of less than 0.05. 26
27. KW test
ā¢ Move on, and compare our H to the next value
in the row, 9.21. 9.21 will occur by chance one
time in a hundred, i.e. with a p of .01. However,
our H of 7.27 is less than 9.21, not bigger than
it.
ā¢ This tells us that our value of H is not so large
that it is likely to occur with a probability of
0.01.
27
28. KW test
ā¢ The likelihood of obtaining a value of H as
large as the one we've found, purely by chance,
is somewhere between 0.05 and 0.01 - i.e. pretty
unlikely, and so we would conclude that there is
a difference of some kind between our three
groups.
28
29. KW test
ā¢ Note that the Kruskal-Wallis test merely tells you that
the groups differ in some way: you need to inspect the
group means or medians
ā¢ However in this particular case, the interpretation
seems fairly straightforward: exercise does seem to
reduce self-reported depression, but only in the case of
participants who are doing 60 minutes.
ā¢ There seems to be no difference between those
participants who took 20 minutes of exercise per day,
and those who did not exercise at all.
29
30. KW test
ā¢ We could write this up as follows:
ā¢ "A Kruskal-Wallis test revealed that there was a
significant effect of exercise on depression
levels (H (2) = 7.27, p < .05).
ā¢ Inspection of the group means suggests that
compared to the "no exercise" control
condition, depression was significantly reduced
by 60 minutes of daily exercise, but not by 20
minutes of exercise".
30
31. KW test
ā¢ The post hoc test for a significant KW is called
Dunnās test with Bonferroni correction for
multiple testing
31
33. Friedman Test
ā¢ This is similar to the Wilcoxon singed rank test,
except that we can use it with three or more
conditions.
ā¢ Each subject participates in all of the different
conditions of the experiment.
33
34. FT
ā¢ Does background music affect the
performance of Laboratory workers?
ā¢ We take a group of five workers, and measure
each worker's productivity (in terms of the
number of Stool Microscopies per hour) thrice
ā once while the worker is listening to āEasy-
listening musicā,
ā once while the worker is listening to āMarching
Band music,ā and
ā once while the same worker is working in āSilence.ā34
35. Step 1:
Rank each subject's scores individually
Worker No Music Easy Listening Marching Band
Raw
Score
Ranked
Score
Raw
Score
Ranked
Score
Raw
Score
Ranked
Score
1 4 1 5 2 6 3
2 2 1 7 2.5 7 2.5
3 6 1.5 6 1.5 8 3
4 3 1 7 3 5 2
5 3 1 8 2 9 3
35
36. Step 2:
Find the rank total for each condition
Worker No Music Easy Listening Marching Band
Raw
Score
Ranked
Score
Raw
Score
Ranked
Score
Raw
Score
Ranked
Score
1 4 1 5 2 6 3
2 2 1 7 2.5 7 2.5
3 6 1.5 6 1.5 8 3
4 3 1 7 3 5 2
5 3 1 8 2 9 3
Total 5.5 11 13.5
36
37. Step 3:
Work out Ļr2
ā¢ Where :
ā C is the number of conditions,
ā N is the number of subjects
ā Ī£Tc2 is the sum of the squared rank totals for
each condition.
37
38. FT
ā¢ To get Ī£Tc2:
ā¢ Take each rank total and square it.
Worker No Music Easy Listening Marching Band
Raw
Score
Ranked
Score
Raw
Score
Ranked
Score
Raw
Score
Ranked
Score
1 4 1 5 2 6 3
2 2 1 7 2.5 7 2.5
3 6 1.5 6 1.5 8 3
4 3 1 7 3 5 2
5 3 1 8 2 9 3
Total 5.5 11 13.5
Square of
Rank Total
30.25 121 182.25
38
40. Step 4: Calculate degrees of
freedom
ā¢ The degrees of freedom are given by the
number of conditions minus one.
C - 1 = 3 - 1 = 2.
40
41. Step 5:
Assess the statistical significance of Xr2
ā¢ It depends on the number of subjects and the
number of groups.
ā more than 9 subjects, we can use a Chi-Square table.
ā less than nine subjects, special tables of critical
values are available.
ā¢ Compare obtained Xr2 value to the critical value
of Chi-Square for df
41
43. FT
ā¢ If your obtained value of Xr2 is bigger than the
critical Chi-Square value, the difference between
conditions is statistically significant.
ā¢ As with the Kruskal- Wallis test, Friedman's test
only tells you that some kind of difference
exists;
ā¢ Inspection of the median score for each
condition will usually be enough
ā¢ Post hoc test for FT is called Dunnās test
43
45. Types of correlation
ā¢ Pearsonās
ā¢ Spearmanās
ā¢ Hoeffdingās D
ā¢ Distance correlation
ā¢ Mutual Information and the Maximal
Information Coefficient
45
46. Correlation coefficient
ā¢ A correlation coefficient is a succinct (single-
number) measure of the strength of association
between two variables.
ā¢ There are various types of correlation
coefficient for different purposes.
ā¢ Commonly used correlation coeff. are
ā Pearson's r
ā Spearman's rho
46
47. Difference between Pearsonās r
and Spearmanās rho
ā¢ Spearmanās rho makes fewer assumptions about the
nature of the data on which the correlation is to be
performed
ā¢ The data need only be measured on an ordinal scale
ā¢ Pearsonās ārā is a measure of the strength of the
linear relationship between two variables
ā¢ Spearmanās rho is a measure of the strength of the
monotonic relationship between them.
47
48. Difference between Pearsonās r
and Spearmanās rho
ā¢ If a monotonic relationship exists, it simply means that
one of the variables increases (or decreases) by some
amount when the value of the other variable changes.
ā¢ A linear relationship is thus a special case of a
monotonic relationship.
ā¢ Thus, if there is a monotonic but non-linear
relationship between two variables, itās better to use
Spearmanās rho because Pearsonās ārā will tend to
underestimate the strength of the relationship.
48
49. Difference between Pearsonās r
and Spearmanās rho
ā¢ Spearmanās rho wonāt be āfooledā by the fact
that the relationship isnāt a linear one.
49
51. Monotonic and non-monotonic
ā¢ Monotonic variables
increase (or decrease)
in the same direction,
but not always at the
same rate.
ā¢ Linear variables
increase (or decrease)
in the same direction
at the same rate.
51
52. How to decide a correlation test?
ā¢ Before running a test, you should make a scatter plot first to
view the overall pattern of your data.
ā¢ The strength and direction of a monotonic relationship between
two variables can be measured by the Spearman Rank-Order
Correlation.
ā¢ If your variables are monotonic and linear, a more appropriate
test might be Pearsonās Correlation as long as the assumptions
for Pearsonās are met. for example, if your data is highly skewed,
has high kurtosis, or is heteroscedastic, you cannot use Pearsonās.
You can, however, still use Spearmanās, which is a non-
parametric test.
52
53. Example for Spearmanās rho
ā¢ Vitamin treatment enhances the memory of
people who take it
ā¢ If there is a correlation between the number of
vitamin treatments that a subject has had, and
their performance on some memory test. We
would have two scores for each subject: number
of vitamin treatments, and that personās
memory-test score.
53
56. Problems In Interpreting Correlations
ā¢ Correlation does not imply causality
ā¢ Factors affecting the size of the correlation
ā The smaller the sample, the more likely it is to show
sampling variation, and the more variable the
correlation can be.
ā Thus, when a correlation coefficient is calculated, it
does not represent the one-and-only correlation
between those two variables for that population.
ā Different samples might produce higher or lower
correlations.
56
57. Sample and population
correlations
Here are the limits within which 80% of sample rās will
fall, when the true correlation (i.e., in the population) is
zero
57
59. Linearity of the relationship
ā¢ Pearsonās r is a measure of the linear relationship between two
variables and Spearmanās rho is a measure of the monotonic
relationship between them.
ā¢ Two variables may have a very strong relationship to each other,
but of a non-linear or non-monotonic kind (for example they
might have a curvilinear relationship).
ā¢ If so, the correlation coefficient will underestimate the strength
of the relationship between the two variables.
ā¢ This is why you should always make a scatterplot of the data, so
that you can look at the trend before calculating a correlation.
59
60. Homoscedasticity
ā¢ Homoscedasticity (equal variability): For
Pearsonsā r to be valid, scores should have a
reasonably constant amount of variability at all
points in their distribution
60
62. Take home messages
ā¢ KW test NP equivalent of One Way ANOVA, >2
independent groups
ā¢ FT test NP equivalent of Repeated Measures ANOVA, >2
paired groups
ā¢ Spearmanās rank order correlation NP equivalent of
Pearsonās correlation for monotonic relationships
62