nonparametric statistics

32
Nonparametr ic Statistics

Upload: madonna-holman

Post on 03-Jan-2016

49 views

Category:

Documents


1 download

DESCRIPTION

Nonparametric Statistics. In previous testing, we assumed that our samples were drawn from normally distributed populations. This chapter introduces some techniques that do not make that assumption. These methods are called distribution-free or nonparametric tests. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Nonparametric Statistics

Nonparametric Statistics

Page 2: Nonparametric Statistics

In previous testing, we assumed that our samples were drawn from normally distributed populations.

This chapter introduces some techniques that do not make that assumption.

These methods are called distribution-free or nonparametric tests.

In situations where the normal assumption is appropriate, nonparametric tests are less efficient than traditional parametric methods.

Nonparametric tests frequently make use only of the order of the observations and not the actual values.

Page 3: Nonparametric Statistics

In this section, we will discuss four nonparametric tests:

the Wilcoxon Rank Sum Test (or Mann-Whitney U test),

the Wilcoxon Signed Ranks Test,

the Kruskal-Wallis Test, and

the one sample test of runs.

Page 4: Nonparametric Statistics

The Wilcoxon Rank Sum Testor Mann-Whitney U Test

This test is used to test whether 2 independent samples have been drawn from populations with the same median.

It is a nonparametric substitute for the t-test on the difference between two means.

Page 5: Nonparametric Statistics

Based on the following samples from two universities, test at the 10% level whether graduates from the two schools have the same average grade on an aptitude test.

Wilcoxon Rank Sum Test Example:

university

A B

50 70

52 73

56 77

60 80

64 83

68 85

71 87

74 88

89 96

95 99

Page 6: Nonparametric Statistics

university

A B

50 70

52 73

56 77

60 80

64 83

68 85

71 87

74 88

89 96

95 99

First merge and rank the grades.Sum the ranks for each sample.

rank grade university

1 50 A

2 52 A

3 56 A

4 60 A

5 64 A

6 68 A

7 70 B

8 71 A

9 73 B

10 74 A

11 77 B

12 80 B

13 83 B

14 85 B

15 87 B

16 88 B

17 89 A

18 95 A

19 96 B

20 99 B

rank sum for university A: 74rank sum for university B: 136

Note: If there are ties, each value gets the average rank. For example, if 2 values tie for 3th and 4th place, both are ranked 3.5. If three differences would be ranked 7, 8, and 9, rank them all 8.

Page 7: Nonparametric Statistics

sample. 1 theas samples 2

theofsmaller thedesignate size,in differ samples When the

sample.1st theconsidered isA university from group theHere,

st

1

1 1 21 T

n (n 1)The mean of T is ,

2

n

1

1 2 1 2T

n n (n 1)and the standard deviation is .

12

n

1 2 1If n and n are each at least 10, T is approximately normal.

1

1

1 T

T

T - So, Z has a standard normal distribution.

st1Define T sum of the ranks for 1 sample .

well.)as used sometimes ision approximat Z thesizes, sample small(For

Page 8: Nonparametric Statistics

1For our example, T 74.

1

1T

( 1) 10(20 1)105

2 2

n n

1

1 2T

n n (n 1) (10)(10)(20 1) 13.229

12 12

1

1

1 T

T

T - 74 - 105Z -2.343.

13.229

-1.645 0 1.645 Z

.45.45.05 .05

critical region

critical region

Since the critical values for a 2-tailed Z test at the 10% level are 1.645 and -1.645, we reject H0 that the medians are the same and accept H1 that the medians are different.

Page 9: Nonparametric Statistics

For small sample sizes, you can use Table E.6 in your textbook, which provides the lower and upper critical values for the Wilcoxon Rank Sum Test.

That table shows that for our 10% 2-tailed test, the lower critical value is 82 and the upper critical value is 128.

Since our smaller sample’s rank sum is 74, which is outside the interval (82, 128) indicated in the table, we reject the null hypothesis that the medians are the same and conclude that they are different.

Equivalently, since the larger sample’s rank sum is 136, which is also outside the interval (82, 128), we again reject the null hypothesis that the medians are the same and conclude that they are different.

Page 10: Nonparametric Statistics

The Wilcoxon Signed Rank Test

This test is used to test whether 2 dependent samples have been drawn from populations with the same median.

It is a nonparametric substitute for the paired t-test on the difference between two means.

Page 11: Nonparametric Statistics

Wilcoxon Signed Rank Test Procedure1. Calculate the differences in the paired values (Di=X1i – X2i)2. Take absolute values of the differences and rank them (Discard

all differences that equal 0.)

3. Assign ranks Ri with the smallest rank equal to 1. As in the rank sum test, if two or more of the differences are

equal, each difference gets the average rank. (That is, if two differences would be ranked 3 and 4, rank them both 3.5. If three differences would be ranked 7, 8, and 9, rank them all 8.)

4. Assign the symbol + to positive differences and – to negative differences.

5. Calculate the Wilcoxon statistic W as the sum of the positive ranks. So,

iW R

Page 12: Nonparametric Statistics

Wilcoxon Signed Rank Test Procedure (cont’d)

is W statistic Wilcoxon theofmean The4

)1(

nnW

is W statistic Wilcoxon theofdeviation standard The

24

)12)(1(

nnnW

:have weSo normal.ely approximat is W statistic test the20,least at isn If

W

WW

Z

well.)as used sometimes ision approximat Z thesizes, sample small(For

s.difference zero-non ofnumber the torefersn following, In the

Page 13: Nonparametric Statistics

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

95 97 72 68

76 76 78 94

82 75 58 55

48 54 73 75

27 31 71 70

34 39 69 66

58 61 57 62

98 97 84 92

45 45 91 81

77 94 83 90

27 36 67 73

Example

Suppose we have a class with 22 students, each of whom has two exam grades.

We want to test at the 5% level whether there is a difference in the median grade for the two exams.

Page 14: Nonparametric Statistics

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

95 97 2 72 68 -4

76 76 0 78 94 16

82 75 -7 58 55 -3

48 54 6 73 75 2

27 31 4 71 70 -1

34 39 5 69 66 -3

58 61 3 57 62 5

98 97 -1 84 92 8

45 45 0 91 81 -10

77 94 17 83 90 7

27 36 9 67 73 6

We calculate the difference between the

exam grades: diff = exam2 – exam 1.

Page 15: Nonparametric Statistics

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

95 97 2 72 68 -4

76 76 0 78 94 16

82 75 -7 58 55 -3

48 54 6 73 75 2

27 31 4 71 70 -1 1.5

34 39 5 69 66 -3

58 61 3 57 62 5

98 97 -1 1.5 84 92 8

45 45 0 91 81 -10

77 94 17 83 90 7

27 36 9 67 73 6

Then we rank the absolute values of the differences from smallest to largest, omitting the two zero differences.

The smallest non-zero |differences| are the two |-1|’s. Since they are tied for ranks 1 and 2, we rank them both 1.5.

Since the differences were negative, we put the ranks in the negative column.

Page 16: Nonparametric Statistics

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

95 97 2 3.5 72 68 -4

76 76 0 78 94 16

82 75 -7 58 55 -3

48 54 6 73 75 2 3.5

27 31 4 71 70 -1 1.5

34 39 5 69 66 -3

58 61 3 57 62 5

98 97 -1 1.5 84 92 8

45 45 0 91 81 -10

77 94 17 83 90 7

27 36 9 67 73 6

The next smallest non-zero |differences| are the two |2|’s. Since they are tied for ranks 3 and 4, we rank them both 3.5.

Since the differences were positive, we put the ranks in the positive column.

Page 17: Nonparametric Statistics

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

95 97 2 3.5 72 68 -4

76 76 0 78 94 16

82 75 -7 58 55 -3 6

48 54 6 73 75 2 3.5

27 31 4 71 70 -1 1.5

34 39 5 69 66 -3 6

58 61 3 6 57 62 5

98 97 -1 1.5 84 92 8

45 45 0 91 81 -10

77 94 17 83 90 7

27 36 9 67 73 6

The next smallest non-zero |differences| are the two |-3|’s and the |3|. Since they are tied for ranks 5, 6, and 7, we rank them all 6.

Then we put the ranks in the appropriately signed columns.

Page 18: Nonparametric Statistics

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

95 97 2 3.5 72 68 -4 8.5

76 76 0 78 94 16 19

82 75 -7 14.5 58 55 -3 6

48 54 6 12.5 73 75 2 3.5

27 31 4 8.5 71 70 -1 1.5

34 39 5 10.5 69 66 -3 6

58 61 3 6 57 62 5 10.5

98 97 -1 1.5 84 92 8 16

45 45 0 91 81 -10 18

77 94 17 20 83 90 7 14.5

27 36 9 17 67 73 6 12.5

We continue until we have ranked all the non-zero |differences| .

Page 19: Nonparametric Statistics

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

exam1 exam2diff

(ex2-ex1)rank (+)

rank (-)

95 97 2 3.5 72 68 -4 8.5

76 76 0 78 94 16 19

82 75 -7 14.5 58 55 -3 6

48 54 6 12.5 73 75 2 3.5

27 31 4 8.5 71 70 -1 1.5

34 39 5 10.5 69 66 -3 6

58 61 3 6 57 62 5 10.5

98 97 -1 1.5 84 92 8 16

45 45 0 91 81 -10 18

77 94 17 20 83 90 7 14.5

27 36 9 17 67 73 6 12.5

154 56

Then we total the signed ranks. We get 154 for the sum of the positive ranks and 56 for the sum of the negative ranks.

The Wilcoxon test statistic is the sum of the positive ranks. So W = 154.

Page 20: Nonparametric Statistics

Since we had 22 students and 2 zero differences, the number of non-zero differences n = 20.

is W ofmean that theRecall 1054

)21)(20(

4

)1(

nnW

is W ofdeviation standard The

786.2624

)41)(21(20

24

)12)(1(

nnnW

:have weSo 829.1786.26

105154

W

WW

Z

-1.96 0 1.96 Z

.475.475.025 .025

critical region

critical region

Since the critical values for a 2-tailed Z test at the 5% level are 1.96 and -1.96, we can not reject the null hypothesis H0 and so we conclude that the medians are the same.

Page 21: Nonparametric Statistics

For small sample sizes, you can use Table 12.19 in the online material associated with section 12.8 of your textbook, which provides the lower and upper critical values for the Wilcoxon Signed Rank Test.

This table is shown on the next slide.

Page 22: Nonparametric Statistics

Lower & Upper Critical Values, W, of Wilcoxon Signed Ranks Test

ONE-TAIL α = 0.05 α = 0.025 α = 0.01 α = 0.005TWO-TAIL α = 0.10 α = 0.05 α = 0.02 α = 0.01

n (Lower, Upper)5 0,15 —,— —,— —,—6 2,19 0,21 —,— —,—7 3,25 2,26 0,28 —,—8 5,31 3,33 1,35 0,369 8,37 5,40 3,42 1,44

10 10,45 8,47 5,50 3,5211 13,53 10,56 7,59 5,6112 17,61 13,65 10,68 7,7113 21,70 17,74 12,79 10,8114 25,80 21,84 16,89 13,9215 30,90 25,95 19,101 16,10416 35,101 29,107 23,113 19,11717 41,112 34,119 27,126 23,13018 47,124 40,131 32,139 27,14419 53,137 46,144 37,153 32,15820 60,150 52,158 43,167 37,173

Recall that we have 20 non-zero differences and are performing a 5% 2-tailed test.Here we see that the lower critical value is 52 and the upper critical value is 158.Our statistic W, the sum of the positive ranks, is 154, which is inside the interval (52, 158) indicated in the table. So we can not reject the null hypothesis and we conclude that the medians are the same.

Page 23: Nonparametric Statistics

The Kruskal-Wallis Test

This test is used to test whether several populations have the same median.

It is a nonparametric substitute for a one-factor ANOVA F-test.

Page 24: Nonparametric Statistics

, 1)3(n - n

R

1)n(n

12 K is statistic test The

j

2j

where nj is the number of observations in the jth sample,n is the total number of observations, and Rj is the sum of ranks for the jth sample.

groups. sample ofnumber theis c where 1,-c dof with isK ofon distributi then the

true,is hypothesis null theand 5neach If2

j

In the case of ties, a corrected statistic should be computed:

nn

)t(t-1

KK

3j

3j

c where tj is the number of ties in the jth sample.

Page 25: Nonparametric Statistics

Kruskal-Wallis Test Example: Test at the 5% level whether average employee performance is the same at 3 firms, using the following standardized test scores for 20 employees.

Firm 1 Firm 2 Firm 3

score rank score rank score rank

78 68 82

95 77 65

85 84 50

87 61 93

75 62 70

90 72 60

80 73

n1 = 7 n2 = 6 n3 =7

Page 26: Nonparametric Statistics

We rank all the scores. Then we sum the ranks for each firm.

Then we calculate the K statistic.

Firm 1 Firm 2 Firm 3

score rank score rank score rank

78 12 68 6 82 14

95 20 77 11 65 5

85 16 84 15 50 1

87 17 61 3 93 19

75 10 62 4 70 7

90 18 72 8 60 2

80 13 73 9

n1 = 7 R1 = 106 n2 = 6 R2 = 47 n3 =7 R3 = 57

1)3(n - n

R

1)n(n

12 K

j

2j

6.6413(21) -

7

57

6

47

7

106

20(21)

12

222

Page 27: Nonparametric Statistics

f(2)

acceptance region

crit. reg.

.05

5.99122

From the 2 table, we see that the 5% critical value for a 2 with 2 dof is 5.991.

Since our value for K was 6.641, we reject H0 that the medians are the same and accept H1 that the medians are different.

Page 28: Nonparametric Statistics

One sample test of runs

a test for randomness of order of occurrence

Page 29: Nonparametric Statistics

A run is a sequence of identical occurrences that are followed and preceded by different occurrences.

Example: The list of X’s & O’s below consists of 7 runs.

x x x o o o o x x o o o o x x x x o o x

Page 30: Nonparametric Statistics

Suppose r is the number of runs, n1 is the number of type 1 occurrences and n2 is the number of type 2 occurrences.

. 1nn

n2nμ

is runs ofnumber mean The

21

21r

. 1)n(n)n(n

)n-n-n(2nn2n

is runs ofnumber theofdeviation standard The

212

21

212121r

Page 31: Nonparametric Statistics

If n1 and n2 are each at least 10, then r is approximately normal.

variable.normal standard a is

-r

Z So,r

r

Page 32: Nonparametric Statistics

Example: A stock exhibits the following price increase (+) and decrease () behavior over 25 business days. Test at the 1% whether the pattern is random.

+ + + + + + + + + + + + + r =16, n1 (+) = 13, n2 () = 12

-r

Zr

r

1nn

n2nμ

21

21r

1)n(n)n(n

)n-n-n(2nn2n

212

21

212121r

11213

2(13)(12)

48.13

1)21(13)21(13

12]-13-)[(2(13)(12 2(13)(12)2

44.2

03.12.44

13.48 - 16

Since the critical values for a 2-tailed 1% test are 2.575 and -2.575, we accept H0 that the pattern is random.

-2.575 0 2.575

Z

critical region.005

critical region.005acceptance

region

.495.495