Biostatistics, statistical software VII.
Non-parametric tests: Wilcoxon’s signed rank test, Mann-Whitney U-test, Kruskal-Wallis test, Spearman’ rank correlation.
Krisztina Boda PhD
Department of Medical Informatics, University of Szeged
INTERREG 2Krisztina Boda
Parametric tests
Parameter: a parameter is a number characterizing an aspect of a population (such as the mean of some variable for the population), or that characterizes a theoretical distribution shape.
Usually, population parameters cannot be known exactly; in many cases we make assumptions about them.
INTERREG 3Krisztina Boda
Parameters of the normal distribution: , Parameter of the binomial distribution: n, p Parameter of the Poisson distribution:
INTERREG 4Krisztina Boda
Normal distributions N(, )
Probability Density Function
y=normal(x;1;1)
-3 -2 -1 0 1 2 30.0
0.1
0.2
0.3
0.4
0.5
0.6
-3 -2 -1 0 1 2 30.0
0.2
0.4
0.6
0.8
1.0
Probability Density Function
y=normal(x;0;2)
-3 -2 -1 0 1 2 30.0
0.1
0.2
0.3
0.4
0.5
0.6
-3 -2 -1 0 1 2 30.0
0.2
0.4
0.6
0.8
1.0
N(0,1) N(1,1)
N(0,2)
, : parameters (a parameter is a number that describes the distribution)
INTERREG 5Krisztina Boda
Binomial distributions
1. Each trial results in one of two possible, mutually exclusive outcome. (success, failure)
2. The probability of a success, p, remains constant from trial to trial 3. The trials are independent. We are interested in being able to compute the probability of k successes in n
trials. The binomial distribution is useful for describing distributions of binomial events,
such as the number of males and females in a random sample of companies, or the number of defective components in samples of 20 units taken from a production process. The binomial distribution is defined as:
p is the probability that the respective event will occur q is equal to 1-p n is the maximum number of independent trials.
P P X kn
kp q k nkk n k
( ) , , ,...,0 1
n
k
n
k n kn n
!
!( )!, ! ...1 2
INTERREG 6Krisztina Boda
Example
Suppose that it is known that 30% of a certain population are immune to some disease. If a random sample of size n=10 is selected from this population, what is the probability that it will contain exactly k=4 immune persons?
0.2001210.1176490081.0210
7.03.0!6!4!10
7.03.04
10)4( 6464
XP
INTERREG 7Krisztina Boda
Number of SuccessProbabilty distribution Distribution function
Probabilty of "success"
0 0.028247525 0.028247525 0.31 0.121060821 0.1493083462 0.233474441 0.3827827863 0.266827932 0.6496107184 0.200120949 0.8497316675 0.102919345 0.9526510136 0.036756909 0.9894079227 0.009001692 0.9984096148 0.001446701 0.9998563149 0.000137781 0.999994095
10 5.9049E-06 1Összesen 1
Binomial distribution n=10, p can be changfed, k=0,1,…,10
Probabilty distribution
0
0.2
0.4
0.6
0.8
1
0 1 2 3 4 5 6 7 8 9 10 11
Distribution function
0
0.2
0.4
0.6
0.8
1
0 1 2 3 4 5 6 7 8 9 10 11
INTERREG 8Krisztina Boda
Poisson distribution
The Poisson distribution is also sometimes referred to as the distribution of rare events. Examples of Poisson distributed variables are number of accidents per person, number of sweepstakes won per person, or the number of catastrophic defects found in a production process.
If n tends to infinity, but at the same time np= is kept constant the binomial distribution approaches a fixed distribution
lim lim ( )!n
kn
k n kk
Pn
kp q f k
ke
INTERREG 9Krisztina Boda
Example. In a certain disease the number of new occurrences in a month is 3 in average. Assuming that the number of new occurrences follows a Poisson distribution, what is the probability that Nobody becomes ill (0.0498) There are exactly 2 new occurrences (0.224)
Number of events Probability Distribution functionAverage number of
events
0 0.049787068 0.049787068 31 0.149361205 0.1991482732 0.224041808 0.4231900813 0.224041808 0.6472318894 0.168031356 0.8152632455 0.100818813 0.9160820586 0.050409407 0.9664914657 0.021604031 0.9880954968 0.008101512 0.9961970089 0.002700504 0.998897512
10 0.000810151 0.999707663Total 0.999707663
Probability
0
0.2
0.4
0.6
0.8
1
0 1 2 3 4 5 6 7 8 9 10 11
Distribution function
0
0.2
0.4
0.6
0.8
1
0 1 2 3 4 5 6 7 8 9 10 11
INTERREG 10Krisztina Boda
Parametric tests
The null hypothesis contains a parameter of a distribution. The assumptions of the tests are that the samples are drawn from a normally distributed population.
One sample t-test: H0: =c, Two sample t-test: H0: 1=2,assumptions:
1=2
INTERREG 11Krisztina Boda
Nonparametric tests
We do not need to make specific assumptions about the distribution of data.
They can be used when The distribution is not normal The shape of the distribution is not evident Data are measured on an ordinal scale (low-
normal-high, passed – acceptable – good – very good)
INTERREG 12Krisztina Boda
Ranking data
Nonparametric tests can't use the estimations of population parameters. They use ranks instead. Instead of the original sample data we have to use its rank.
To show the ranking procedure suppose we have the following sample of measurements: 199, 126, 81, 68, 112, 112.
Sort the data in ascending order: 68, 81,112,112,126,199 Give ranks from 1 to n: 1, 2, 3, 4, 5, 6 Cases 5 and 6 are equal, they are assigned a rank of 3.5,
the average rank of 3 and 4. We say that case 5 and 6 are tied.
Ranks corrected for ties: 1, 2, 3.5, 3.5, 5, 6
INTERREG 13Krisztina Boda
Result of ranking data
Case Data Rank Ranks corrected for ties
4 68 1 1
3 81 2 2
5 112 3 3.5
6 112 4 3.5
2 126 5 5
1 199 6 6
The sum of all ranks must be
Using this formula we can check our computations. Now the sum of ranks is 21, and 6(7)/2=21.
rn n
ii
n
( )1
21
INTERREG 14Krisztina Boda
Nonparametric tests for paired data(nonparametric alternatives of paired t-test)
Sign test Wilcoxon’s matched pairs test Null hypothesis: the paired samples are
drawn from the same population
INTERREG 15Krisztina Boda
The sign test Example: 13 students
were measured in reading speed and comprehension at a course ending and after 1 month. Suppose we have reason to believe that the two distributions of reading scores are not normal.
Number of positive signs: 6
Number of negative signs: 5
Cases with no change are omitted
Student Score Score Difference Sign at course after
ending 1 month 1 50 52 -2 -2 48 51 -3 -3 46 46 04 50 49 1 +5 62 50 2 +6 80 70 10 +7 23 21 2 +8 30 33 -3 -9 45 46 -1 -10 53 53 011 49 48 1 +12 51 48 3 +13 46 48 -2 -
INTERREG 16Krisztina Boda
Table of the sign test
The table contains the acceptance region for given sample size and
INTERREG 17Krisztina Boda
Decision based on table
If the distributions of the two variables are the same (If the null hypothesis is true), the numbers of positive and negative differences should be similar.
The null hypothesis is accepted if both numbers lie in the interval given it table for the sign test
Number of positive signs: 6 Number of negative signs: 5 For n=11 and =0.05, this interval is 1-10. As both 5 and 6 lies in the interval 1-10, we accept the
null hypothesis at 5% level.
INTERREG 18Krisztina Boda
The Wilcoxon signed rank test Example: 13 students
were measured in reading speed and comprehension at a course ending and after 1 month. Suppose we have reason to believe that the two distributions of reading scores are not normal.
Sum of ranks belonging to positive signs: R+=40.5
Sum of ranks belonging to negative signs: R-=25.5
Cases with no change are omitted
Student Score Score Difference Rank at course after ignoring
ending 1 month signs1 50 52 -2 5.52 48 51 -3 93 46 46 04 50 49 1 25 62 50 2 5.56 80 70 10 117 23 21 2 8 30 33 -3 99 45 46 -1 210 53 53 011 49 48 1 212 51 48 3 913 46 48 -2 5.5
INTERREG 19Krisztina Boda
Table of the Wilcoxon signed rank test
The table contains the acceptance region for given sample size and
INTERREG 20Krisztina Boda
Decision based on table
If the distributions of the two variables are the same (If the null hypothesis is true), the sum of positive and negative ranks should be similar.
The null hypothesis is accepted if both numbers lie in the interval given it table for the test
Sum of ranks belonging to positive signs: R+=40.5 Sum of ranks belonging to negative signs: R-=25.5 For n=11 and =0.05, this interval is 10-56. As both rank sums are in this interval, we do not reject the null
hypothesis and claim that the difference is not significant at 5% level.
INTERREG 21Krisztina Boda
The case of large samples
When the sample size is large, we can count the mean and standard deviation of the ranks and use the normal distribution to get the p-value. Computer packages use this normal approximation also in case of small sample size
)1,0(~)24/)12)(1((
4/)1(
1
2
1 Nnnn
nnR
R
RRz
n
ii
n
ii
INTERREG 22Krisztina Boda
Nonparametric test for data in independent groups(nonparametric alternatives of two sample t-test)
Mann-Whitney U test
Null hypothesis: the samples are drawn from the same population
INTERREG 23Krisztina Boda
Hypothetical example
The change of body weight are compared in two groups: patients having a special diet and control patients.
Null hypothesis: the diet is not effective, data are drawn from the same population.
The original data are ranked and the sum of ranks in each group is computed. If the null hypothesis is true, the sum of ranks in the two groups are similar.
INTERREG 24Krisztina Boda
Patient Change in body weight (kg)
Group Rank Rank corrected for ties
1. -1 Diet 3 3 2. 5 Diet 16 16.5 3. 3 Diet 12 13 4. 10 Diet 21 21 5. 6 Diet 18 19 6. 4 Diet 15 15 7. 0 Diet 4 5.5 8. 1 Diet 8 9 9. 6 Diet 19 19
10. 6 Diet 20 19 Sum of ranks, R1 140
11. 2 Control 11 11 12. 0 Control 5 5.5 13. 1 Control 9 9 14. 0 Control 6 5.5 15. 3 Control 13 13 16. 1 Control 10 9 17. 5 Control 17 16.5 18. 0 Control 7 5.5 19 -2 Control 1 1.5 20. -2 Control 2 1.5 21. 3 Control 14 13
Sum of ranks R2 91
INTERREG 25Krisztina Boda
Table of the Mann-Whitney U test
INTERREG 26Krisztina Boda
Decision based on table
If the distributions of the two variables are the same (If the null hypothesis is true), the sum of ranks in the two groups should be similar.
The test statistic T is the sum of the ranks in the smaller group. The null hypothesis is accepted T lies in the interval given it table for the test
Sum of ranks in the first group (n=10): R1=140 Sum of ranks in the second group (n=11): R2=91 The test statistic T is the sum of the ranks in the smaller group. T=140. For n1=10 and n2=11 and =0.05, this interval is 81-139. As T lies outside of this interval, we reject the null hypothesis and
claim that the difference is significant at 5% level.
INTERREG 27Krisztina Boda
An alternative test statistic The statistic U (due to Mann Whitney) is the
number of all possible pairs of observations comprising one from each sample, say xi and yi , for which xi<yi. This if the sample sizes are n1 and n2, the U/n1n2 is the proportion of all such pairs, and so is also the estimated probability that a new observation from the first population will be less than a new observation sampled from the second population.
TnnnnU )1(2
11121
INTERREG 28Krisztina Boda
The case of large samples
When the sample size is large, T test statistic T has an approximately Normal distribution And we can calculate the test statistic z according to the following formula: (ns and nL are the sample sizes in the smaller and larger group respectively).
Computer packages use this normal approximation also in case of small sample size
)1,0(~
12
)1(
2/)1(N
nnnn
nnnRz
LsLs
Lsss
INTERREG 29Krisztina Boda
Comparing several independent groups: the Kruskal-Wallis test
It is also called nonparametric one-way ANOVA It tests whether k independent samples that are defined
by a grouping variable are from the same population. This test assumes that there is no a priori ordering of the
k populations from which the samples are drawn. As a result, it gives one p-value. If the null hypothesis is rejected, further tests are
required to make pairwise comparisons. These pairwise comparisons are generally not available in standard statistical packages. Pairwise comparisons can be performed by Mann Whitney U tests and p-values can be corrected by Bonferroni correction.
INTERREG 30Krisztina Boda
Comparison of several related samples: the Friedman test
The Friedman test is the nonparametric equivalent of a one-sample repeated measures design or a two-way analysis of variance with one observation per cell.
Friedman tests the null hypothesis that k related variables come from the same population. For each case, the k variables are ranked from 1 to k. The test statistic is based on these ranks.
As a result, it gives one p-value. If the null hypothesis is rejected, further tests are required to make
pairwise comparisons. These pairwise comparisons are generally not available in standard statistical packages. Pairwise comparisons can be performed by Wilxocon signed rank tests and p-values can be corrected by Bonferroni correction.
INTERREG 31Krisztina Boda
Review questions and exercises
Problems to be solved by hand-calculations ..\Handouts\Problems hand VII.doc
Solutions ..\Handouts\Problems hand VII solutions.doc
Problems to be solved using computer - none
INTERREG 32Krisztina Boda
Useful WEB pages
http://www-stat.stanford.edu/~naras/jsm http://www.ruf.rice.edu/~lane/rvls.html http://my.execpc.com/~helberg/statistics.html http://www.math.csusb.edu/faculty/stanton/m26
2/index.html