+ All Categories
Home > Documents > Nonparametric Methods and Chi-Square Tests Session 5.

Nonparametric Methods and Chi-Square Tests Session 5.

Date post: 14-Jan-2016
Category:
Upload: ethelbert-cunningham
View: 218 times
Download: 0 times
Share this document with a friend
51
Nonparametric Methods and Chi-Square Tests Session 5
Transcript
Page 1: Nonparametric Methods and Chi-Square Tests Session 5.

Nonparametric Methods and Chi-Square Tests

Session 5

Page 2: Nonparametric Methods and Chi-Square Tests Session 5.

• Using Statistics.

• The Sign Test.

• The Runs Test - A Test for Randomness.

• The Mann-Whitney U Test.

• The Wilcoxon Signed-Rank Test.

Nonparametric Methods and Chi-Square Tests (1)

Page 3: Nonparametric Methods and Chi-Square Tests Session 5.

• The Kruskal-Wallis Test - A Nonparametric Alternative to One-Way ANOVA.

• The Friedman Test for a Randomized Block Design.

• The Spearman Rank Correlation Coefficient.

• A Chi-Square Test for Goodness of Fit.

• Contingency Table Analysis - A Chi-Square Test for Independence.

• A Chi-Square Test for Equality of Proportions.

• Using the Computer.

• Summary and Review of Terms.

Nonparametric Methods and Chi-Square Tests (2)

Page 4: Nonparametric Methods and Chi-Square Tests Session 5.

• Parametric MethodsInferences based on assumptions about the

nature of the population distribution.Usually: population is normal.

Types of testst-test

» Comparing two population means or proportions.

» Testing value of population mean or proportion.

ANOVA» Testing equality of several population means.

5-1 Using Statistics (Parametric Tests)

Page 5: Nonparametric Methods and Chi-Square Tests Session 5.

• Nonparametric TestsDistribution-free methods making no

assumptions about the population distribution.Types of tests

Sign tests» Sign Test: Comparing paired observations.

» McNemar Test: Comparing qualitative variables.

» Cox and Stuart Test: Detecting trend.

Runs tests» Runs Test: Detecting randomness.

» Wald-Wolfowitz Test: Comparing two distributions.

Nonparametric Tests (1)

Page 6: Nonparametric Methods and Chi-Square Tests Session 5.

• Nonparametric Tests– Ranks tests

• Mann-Whitney U Test: Comparing two populations.

• Wilcoxon Signed-Rank Test: Paired comparisons.

• Comparing several populations: ANOVA with ranks. Kruskal-Wallis Test Friedman Test: Repeated measures

– Spearman Rank Correlation Coefficient.

– Chi-Square Tests• Goodness of Fit.

• Testing for independence: Contingency Table Analysis.

• Equality of Proportions.

Nonparametric Tests (2)

Page 7: Nonparametric Methods and Chi-Square Tests Session 5.

• Deal with enumerative (frequency counts) data.

• Do not deal with specific population parameters, such as the mean or standard deviation.

• Do not require assumptions about specific population distributions (in particular, the normality assumption).

Nonparametric Tests (3)

Page 8: Nonparametric Methods and Chi-Square Tests Session 5.

• Comparing paired observationsPaired observations: X and Yp = P(X>Y)

Two-tailed test H0: p = 0.50 H1: p0.50

Right-tailed test H0: p 0.50 H1: p0.50

Left-tailed test H0: p 0.50H1: p0.50

Test statistic: T = Number of + signs» Large sample

zT n

n

2

5-2 Sign Test

Page 9: Nonparametric Methods and Chi-Square Tests Session 5.

• Small Sample: Binomial TestFor a two-tailed test, find a critical point corresponding as

closely as possible to /2 (C1) and define C2 as n-C1. Reject null hypothesis if T C1or T C2.

For a right-tailed test, reject H0 if T C, where C is the value of the binomial distribution with parameters n and p = 0.50 such that the sum of the probabilities of all values less than or equal to C is as close as possible to the chosen level of significance, .

For a left-tailed test, reject H0 if T C, where C is defined as above.

Sign Test Decision Rule

Page 10: Nonparametric Methods and Chi-Square Tests Session 5.

Cumulative Binomial

Probabilities(n=15, p=0.5)

x F(x) 0 0.00003 1 0.00049 2 0.00369 3 0.01758 4 0.05923 5 0.15088 6 0.30362 7 0.50000 8 0.69638 9 0.8491210 0.9407711 0.9824212 0.9963113 0.9995114 0.9999715 1.00000

CEO Before After Sign 1 3 4 1 + 2 5 5 0 3 2 3 1 + 4 2 4 1 + 5 4 4 0 6 2 3 1 + 7 1 2 1 + 8 5 4 -1 - 9 4 5 1 +10 5 4 -1 -11 3 4 1 +12 2 5 1 +13 2 5 1 +14 2 3 1 +15 1 2 1 +16 3 2 -1 -17 4 5 1 +

n = 15 T = 120.025C1=3 C2 = 15-3 = 12H0 rejected, since TC2

C1

Normal Approximation:

zT n

n

p zp value

2 2 12 15

1524 15

15

9

152 32

2 32 1 09898 0010200102 2 00204

( )( )

.

( . ) . .( . )( ) .

Example 5-1

Page 11: Nonparametric Methods and Chi-Square Tests Session 5.

A run is a sequence of like elements that are preceded and followed by different elements or no element at all.

Case 1: S|E|S|E|S|E|S|E|S|E|S|E|S|E|S|E|S|E|S|E : R = 20 Apparently nonrandomCase 2: SSSSSSSSSS|EEEEEEEEEE : R = 2 Apparently nonrandomCase 3: S|EE|SS|EEE|S|E|SS|E|S|EE|SSS|E : R = 12 Perhaps random

A two-tailed hypothesis test for randomness:H0: Observations are generated randomlyH1: Observations are not generated randomly

Test Statistic:R=Number of Runs

Reject H0 at level if R C1 or R C2, as given in Table 8, with total tail probability P(R C1) + P(R C2) =

5-3 The Runs Test - A Test for Randomness

Page 12: Nonparametric Methods and Chi-Square Tests Session 5.

Table 8: Number of Runs (r)(n1,n2) 11 12 13 14 15 16 17 18 19 20 . . .(10,10) 0.586 0.758 0.872 0.949 0.981 0.996 0.999 1.000 1.000 1.000

Case 1: n1 = 10 n2 = 10 R= 20 p-value0Case 2: n1 = 10 n2 = 10 R = 2 p-value 0Case 3: n1 = 10 n2 = 10 R= 12

p-value PR F(11)] = (2)(1-0.586) = (2)(0.414) = 0.828 H0 not rejected

Runs Test: Examples

Page 13: Nonparametric Methods and Chi-Square Tests Session 5.

The mean of the normal distribution of the number of runs:

The standard deviation:

The

E Rn n

n n

n n n n n n

n n n n

R E R

R

R

( )

( )

( ) ( )

( )

21

2 2

1

1 2

1 2

1 2 1 2 1 2

1 2

2

1 2

standard normal test statistic:

z

Large-Sample Runs Test: Using the Normal Approximation

Page 14: Nonparametric Methods and Chi-Square Tests Session 5.

Example 14-2: n1 = 27 n2 = 26 R = 16

p - value = 2(1-.9993) = 0.0014

E Rn n

n n

R

n n n n n n

n n n n

R E R

R

( )( )( )( )

( ). .

( )

( ) ( )

( )( )( )(( )( )( ) ))

( ) ( )

. .

( ) .

..

2 1 2

1 21

2 27 26

27 261 26 49 1 27 49

2 1 2 2 1 2 1 2

1 22

1 2 1

2 27 26 2 27 26 27 26

27 262

27 26 1

1896804

14606812 986 3 604

16 27 49

3 604319

z

H0 should be rejected at any common level of significance.

Large-Sample Runs Test: Example 5-2

Page 15: Nonparametric Methods and Chi-Square Tests Session 5.

The null and alternative hypotheses for the Wald-Wolfowitz test:

H0: The two populations have the same distribution.H1: The two populations have different distributions.

The test statistic: R = Number of Runs in the sequence of samples, when the data from both samples have been sorted.

Salesperson A: 35 44 39 50 48 29 60 75 49 66 Salesperson B: 17 23 13 24 33 21 18 16 32

Using the Runs Test to Compare Two Population Distributions (Means): the Wald-Wolfowitz Test

Page 16: Nonparametric Methods and Chi-Square Tests Session 5.

Table Number of Runs (r)(n1,n2) 2 3 4 5 . . .(9,10) 0.000 0.000 0.002 0.004 ...

SalesSales Sales Person

Sales Person (Sorted) (Sorted) Runs35 A 13 B44 A 16 B39 A 17 B48 A 21 B60 A 24 B 175 A 29 A 249 A 32 B66 A 33 B 317 B 35 A23 B 39 A13 B 44 A24 B 48 A33 B 49 A21 B 50 A18 B 60 A16 B 66 A32 B 75 A 4

n1 = 10 n2 = 9 R= 4 p-value PR H0 may be rejected

The Wald-Wolfowitz Test: Example 5-3

Page 17: Nonparametric Methods and Chi-Square Tests Session 5.

• Ranks tests– Mann-Whitney U Test: Comparing two

populations.– Wilcoxon Signed-Rank Test: Paired

comparisons.– Comparing several populations: ANOVA with

ranks.• Kruskal-Wallis Test.• Friedman Test: Repeated measures.

Ranks Tests

Page 18: Nonparametric Methods and Chi-Square Tests Session 5.

The null and alternative hypotheses:H0: The distributions of two populations are identicalH1: The two population distributions are not identical

The Mann-Whitney U statistic:

where n1 is the sample size from population 1 and n2 is the sample size from population 2.

U n nn n

R

1 21 1

1

12

( ) R Ranks from sample 11

E Un n n n n n

zU E U

U

U

[ ]( )

[ ]

1 2 1 2 1 2

21

12

The large - sample test statistic:

5-4 The Mann-Whitney U Test (Comparing Two Populations)

Page 19: Nonparametric Methods and Chi-Square Tests Session 5.

Cumulative Distribution Function of the Mann-Whitney U Statistic

n2=6n1=6

u...4 0.01305 0.02066 0.0325...

RankModel Time Rank SumA 35 5A 38 8A 40 10A 42 12A 41 11A 36 6 52B 29 2B 27 1B 30 3B 33 4B 39 9B 37 7 26

P(u5)

U n nn n

R

1 21 1 1

2 1

52

5

( )

= (6)(6) +(6)(6 + 1)

2

The Mann-Whitney U Test: Example 5-4

Page 20: Nonparametric Methods and Chi-Square Tests Session 5.

Example 5-5: Large-Sample Mann-Whitney U Test

Score RankScore Program Rank Sum85 1 20.0 20.087 1 21.0 41.092 1 27.0 68.098 1 30.0 98.090 1 26.0 124.088 1 23.0 147.075 1 17.0 164.072 1 13.5 177.560 1 6.5 184.093 1 28.0 212.088 1 23.0 235.089 1 25.0 260.096 1 29.0 289.073 1 15.0 304.062 1 8.5 312.5

Score RankScore Program Rank Sum65 2 10.0 10.057 2 4.0 14.074 2 16.0 30.043 2 2.0 32.039 2 1.0 33.088 2 23.0 56.062 2 8.5 64.569 2 11.0 75.570 2 12.0 87.572 2 13.5 101.059 2 5.0 106.060 2 6.5 112.580 2 18.0 130.583 2 19.0 149.550 2 3.0 152.5

Since the test statistic is z = -3.32,the p-value0.0005, and H0 is rejected.

U n nn n

R

E Un n

U

n n n n

zU E U

U

1 21 1 1

2 1

15 1515 15 1

2312 5 32 5

1 2

2

1 2 1 2 1

1215 15 15 15 1

24 109

32 5 112 5

24 1093 32

( )

( )( )( )( )

. .

[ ]

( )

( )( )( ).

[ ] . .

..

=(15)(15)

2= 112.5

12

Page 21: Nonparametric Methods and Chi-Square Tests Session 5.

The null and alternative hypotheses:H0: The median difference between populations are 1 and 2 is zero.H1: The median difference between populations are 1 and 2 is not zero.

Find the difference between the ranks for each pair, D = x1 -x2, and then rank the absolute values of the differences. The Wilcoxon T statistic is the smaller of the sums of the positive ranks and the sum of the negative ranks:

For small samples, a left-tailed test is used, using the values in Appendix C, Table 10.

The large-sample test statistic:

T min ( ), ( )

E Tn n

Tn n n

[ ]( ) ( )( )

1

4

1 2 1

24

zT E T

T

[ ]

5-5 The Wilcoxon Signed-Ranks Test (Paired Ranks)

Page 22: Nonparametric Methods and Chi-Square Tests Session 5.

Sold Sold Rank Rank Rank(1) (2) D=x1-x2 ABS(D) ABS(D)(D>0) (D<0)

56 40 16 16 9.0 9.0 048 70 -22 22 12.0 0.0 12100 60 40 40 15.0 15.0 085 70 15 15 8.0 8.0 022 8 14 14 7.0 7.0 044 40 4 4 2.0 2.0 035 45 -10 10 6.0 0.0 628 7 21 21 11.0 11.0 052 60 -8 8 5.0 0.0 577 70 7 7 3.5 3.5 089 90 -1 1 1.0 0.0 110 10 0 * * * *65 85 -20 20 10.0 0.0 1090 61 29 29 13.0 13.0 070 40 30 30 14.0 14.0 033 26 7 7 3.5 3.5 0

Sum: 86 34

T=34n=15

P=0.05 30P=0.025 25P=0.01 20P=0.005 16

H0 is not rejected (Note the arithmetic error in the text for store 13)

Example 5-6

Page 23: Nonparametric Methods and Chi-Square Tests Session 5.

The spreadsheet implements a Wilcoxon sign rank test. The RANK function was used in column F (Rank Diff), however, the resulting values required adjustment due to the presence of tie in the rankng for Scores 10 and 16 (which Excel handles differently than in the Wilcoxon sign ranked procedure.

Example 5-6 using Excel

Page 24: Nonparametric Methods and Chi-Square Tests Session 5.

Store # Violet # Pink Difference Abs Diff Rank Diff Rank Pos Rank Neg1 56 40 16 16 9 92 48 70 -22 22 12 123 100 60 40 40 15 154 85 70 15 15 8 85 22 8 14 14 7 76 44 40 4 4 2 27 35 45 -10 10 6 68 28 7 21 21 11 119 52 60 -8 8 5 5

10 77 70 7 7 35 3.511 89 90 -1 1 1 112 10 10 0 013 65 85 -20 20 10 1014 90 61 29 29 13 1315 70 40 30 30 14 1416 33 26 7 7 35 3.5

SUMS: 86 34Test Statistic 34Critical Value (two-tail) 25

Conclusion: Do Not Reject H0

Example 5-6 using Excel

Page 25: Nonparametric Methods and Chi-Square Tests Session 5.

Hourly Rank Rank Rank

Messages Md0 D=x1-x2 ABS(D) ABS(D) (D>0) (D<0)

151 149 2 2 1.0 1.0 0.0144 149 -5 5 2.0 0.0 2.0123 149 -26 26 13.0 0.0 13.0178 149 29 29 15.0 15.0 0.0105 149 -44 44 23.0 0.0 23.0112 149 -37 37 20.0 0.0 20.0140 149 -9 9 4.0 0.0 4.0167 149 18 18 10.0 10.0 0.0177 149 28 28 14.0 14.0 0.0185 149 36 36 19.0 19.0 0.0129 149 -20 20 11.0 0.0 11.0160 149 11 11 6.0 6.0 0.0110 149 -39 39 21.0 0.0 21.0170 149 21 21 12.0 12.0 0.0198 149 49 49 25.0 25.0 0.0165 149 16 16 8.0 8.0 0.0109 149 -40 40 22.0 0.0 22.0118 149 -31 31 16.5 0.0 16.5155 149 6 6 3.0 3.0 0.0102 149 -47 47 24.0 0.0 24.0164 149 15 15 7.0 7.0 0.0180 149 31 31 16.5 16.5 0.0139 149 -10 10 5.0 0.0 5.0166 149 17 17 9.0 9.0 0.0

82 149 33 33 18.0 18.0 0.0

Sum: 163.5 161.5

E Tn n

T

n n n

zT E T

T

[ ]( )

( )( )

( )(( )( ) )

.

[ ]

. .

.

1

41 2 1

2425 25 1 2 25 1

2433150

2437 165

163 5 162 5

37 1650.027

=(25)(25 + 1)

4= 162.5

The large - sample test statistic:

H 0 cannot be rejected

Example 5-7

Page 26: Nonparametric Methods and Chi-Square Tests Session 5.

The Kruskal-Wallis hypothesis test:H0: All k populations have the same distribution.H1: Not all k populations have the same distribution.

The Kruskal-Wallis test statistic:

If each nj > 5, then H is approximately distributed as a 2.

Hn n

Rn

nj

jj

k

12

13 1

2

1( )( )

5-6 The Kruskal-Wallis Test - A Nonparametric Alternative to One-Way ANOVA

Page 27: Nonparametric Methods and Chi-Square Tests Session 5.

SoftwareTimeRank Group RankSum 1 45 14 1 90 1 38 10 2 56 1 56 16 3 25 1 60 17 1 47 15 1 65 18 2 30 8 2 40 11 2 28 7 2 44 13 2 25 5 2 42 12 3 22 4 3 19 3 3 15 1 3 31 9 3 27 6 3 17 2

Hn n

R j

n jj

kn

12

1

2

13 1

12

18 18 1

902

6

562

6

252

63 18 1

12

342

11861

657

12 3625

( )( )

( )( )

.

2(2,0.005)=10.5966, so

H0 is rejected.

Example 5-8: The Kruskal-Wallis Test

Page 28: Nonparametric Methods and Chi-Square Tests Session 5.

If the null hypothesis in the Kruskal-Wallis test is rejected, then we may wish, in addition, compare each pair of populations to determine which are different and which are the same.

The pairwise comparison test statistic: where R is the mean of the ranks of the observations frompopulation i.

The critical point for the paired comparisons:

C

Reject if D > C

i

KW

KW

D R R

n nn n

i j

ki j

( )

( ), 1

2 112

1 1

Further Analysis (Pairwise Comparisons of Average Ranks)

Page 29: Nonparametric Methods and Chi-Square Tests Session 5.

Critical Point:

C

D

D

D

KW

1,2

1,3

2,3

( )( )

( )( )

.

. ***

.

, ki j

n nn n

R

R

R

1

2

1

2

3

112

1 1

9.2103418 18 1

1216

16

87.49823 9.35

906

15 15 9.33 567566

9.33 15 4.17 10 83256

4.17 9.33 4.17 516

Pairwise Comparisons: Example 5-8

Page 30: Nonparametric Methods and Chi-Square Tests Session 5.

A manager wants to explore upgrading the fleet of trucks. There are three new models to choose from. The manager is allowed to drive the trucks for a few days, and randomly picks 15 drivers to do so. Five drivers will test each truck. Conduct a Kruskal-Wallis rank test for differences in the three population medians for the MPGs.

Truck MPG RankTruck A 17 1 Truck A 1 Truck B 9 Truck C 4Truck A 18.2 2 2 11 6Truck A 18.5 3 3 13 7Truck C 18.7 4 5 14 8Truck A 19.4 5 10 15 12Truck C 19.9 6Truck C 20.3 7Truck C 21.1 8Truck B 22.7 9Truck A 23.5 10Truck B 23.8 11Truck C 23.9 12Truck B 24.2 13Truck B 25.1 14Truck B 26.3 15

Pairwise Comparisons: Example 5-9 Using Excel

Page 31: Nonparametric Methods and Chi-Square Tests Session 5.

Test DataSum of Ranks for Truck A 21Sample Size for Truck A 5Sum of Ranks for Truck B 62Sample Size for truck B 5Sum of Ranks for Truck C 37Sample size for truck C 5

Total Sample Size 15Total Sum of Ranks 120

Alpha 0.05Sum of Squared Ranks/Sample Size 1130.8H 8.54Number of Groups 3Critical Value 5.991476p-value 0.013982

Reject (0.013 < 0.05)

Pairwise Comparisons: Example 5-9 Using Excel

Page 32: Nonparametric Methods and Chi-Square Tests Session 5.

The Spearman Rank Correlation Coefficient is the simple correlation coefficient calculated from variables converted to ranks from their original values.

The Spearman Rank Correlation Coefficient (assuming no ties):

rs where di = R(xi ) - R(yi )

Null and alternative hypotheses: H0: = 0

H1: 0

Critical values for small sample tests from Appendix C, Table 11Large sample test statistic: z = rs

16 2

12 1

1

dii

n

n n

s

s

n

( )

( )

5-7 The Spearman Rank Correlation Coefficient

Page 33: Nonparametric Methods and Chi-Square Tests Session 5.

Table 11: =0.005n...7 ------8 0.8819 0.83310 0.79411 0.818...

rs = 1 -(6)(4)

(10)(102 - 1) = 1 -

24

990= 0.9758 > 0.794

1

6 212 1

dii

n

n n( )H

0 rejected

MMIS&P100 R-MMI R-S&P Diff Diffsq220 151 7 6 1 1218 150 5 5 0 0216 148 3 3 0 0217 149 4 4 0 0215 147 2 2 0 0213 146 1 1 0 0219 152 6 7 -1 1236 165 9 10 -1 1237 162 10 9 1 1235 161 8 8 0 0

Sum: 4

Spearman Rank Correlation Coefficient: Example 5-10

Page 34: Nonparametric Methods and Chi-Square Tests Session 5.

MMI S&P 500 Rank MMI Rank S&P 500 Difference Difference Squared220 150 7 6 1 1218 150 5 5 0 0216 148 3 3 0 0217 149 4 4 0 0215 147 2 2 0 0213 146 1 1 0 0219 152 6 7 -1 1236 165 9 10 -1 1237 162 10 9 1 1235 161 8 8 0 0

4Test Spearman Rank Correlation Coefficient: 0.975758

Critical Coefficient (= 0.005) 0.794

CONCLUSION: Reject H0 that the indexes are not positively correlated.

Spearman Rank Correlation Coefficient: Example 5-10 Using Excel

Page 35: Nonparametric Methods and Chi-Square Tests Session 5.

Steps in a chi-square analysis: Formulate null and alternative hypotheses Compute frequencies of occurrence that would be expected

if the null hypothesis were true - expected cell counts Note actual, observed cell counts Use differences between expected and actual cell counts to

find chi-square statistic:

Compare chi-statistic with critical values from the chi-square distribution (with k-1 degrees of freedom) to test the null hypothesis

22

1

( )O E

Ei i

ii

k

5-8 A Chi-Square Test for Goodness of Fit

Page 36: Nonparametric Methods and Chi-Square Tests Session 5.

The null and alternative hypotheses:H0: The probabilities of occurrence of events E1, E2...,Ek are given by p1,p2,...,pk

H1: The probabilities of the k events are not as specified in the null hypothesis

Exit 14-11: Assuming equal probabilities, p1= p2 = p3 = p4 =0.25 and n=80Preference Tan Brown Maroon Black TotalObserved 12 40 8 20 80Expected(np) 20 20 20 20 80(O-E) -8 20 -12 0 0

2

2

1

82

20

202

20

122

20

02

2030 4

0 01 3

211 3449

( ) ( ) ( ) ( ) ( ).

( . , ).

Oi Ei

Eii

k

H is rejected at the 0.01 level.0

Goodness-of-Fit Test for the Multinomial Distribution

Page 37: Nonparametric Methods and Chi-Square Tests Session 5.

50-5

0.4

0.3

0.2

0.1

0.0z

f(z)

Partitioning the Standard Normal Distribution

-1 1

-0.44 0.44

0.1700

0.1713

0.15870.1587

0.1700

0.1713

1. Use the table of the standard normal distribution to determine an appropriate partition of the standard normal distribution which gives ranges with approximately equal percentages.p(z<-1) = 0.1587p(-1<z<-0.44) = 0.1713p(-0.44<z<0) = 0.1700p(0<z<0.44) = 0.1700p(0.44<z<14) = 0.1713p(z>1) = 0.1587

2. Given z boundaries, x boundaries can be determined from the inverse standard normal transformation: x = + z = 125 + 40z.

3. Compare with the critical value of the 2 distribution with k-3 degrees of freedom.

Goodness-of-Fit for the Normal Distribution: Example 5-11

Page 38: Nonparametric Methods and Chi-Square Tests Session 5.

i Oi Ei Oi - Ei (Oi - Ei)2 (Oi - Ei)2/ Ei

1 14 15.87 -1.87 3.49690 0.220352 20 17.13 2.87 8.23691 0.480853 16 17.00 -1.00 1.00000 0.058824 19 17.00 2.00 4.00000 0.235295 16 17.13 -1.13 1.27690 0.074546 15 15.87 -0.87 0.75690 0.04769

2: 1.11755

2(0.10,k-3)= 6.5139 > 1.11755 H0 is not rejected at the 0.10 level

Example 5-12: Solution

Page 39: Nonparametric Methods and Chi-Square Tests Session 5.

In lieu of all the recent mergers, companies have looked to employees for help in determining the new company name. When two prominent banks joined forces, 250 employees were chosen at random to evaluate (like or dislike) two names. 140 workers commented on Name A, of whom 85 liked the name. Out of the 110 workers who commented on Name B, 54 liked the name. Conduct a chi-square test.

Example 5-13

Page 40: Nonparametric Methods and Chi-Square Tests Session 5.

Chi-Square Test

Response Observed Observed Total Expected Expected Total Name A Name B Name A Name B

Like 85 54 139 78 61 139Dislike 55 56 111 62 49 111Total 140 110 250 140 110 250

p-value 0.06634Number of Rows 2Number of Columns 2Degrees of Freedom 1Alpha 0.05Critical Value 3.84146Chi-Square Statistic 3.37123

CONCLUSION: Do not reject H0 of equal proportions

since the p-value = 0.06634.

Example 5-13: Solution

Page 41: Nonparametric Methods and Chi-Square Tests Session 5.

First Classification Category

SecondClassification

Category 1 2 3 4 5RowTotal

1 O11 O12 O13 O14 O15 R1

2 O21 O22 O23 O24 O25 R2

3 O31 O32 O33 O34 O35 R3

4 O41 O42 O43 O44 O45 R4

5 O51 O52 O53 O54 O55 R5

ColumnTotal C1 C2 C3 C4 C5 n

5-9 Contingency Table Analysis: A Chi-Square Test for Independence

Page 42: Nonparametric Methods and Chi-Square Tests Session 5.

Null and alternative hypotheses:H0: The two classification variables are independent of each otherH1: The two classification variables are not independent

Chi-square test statistic for independence:

Degrees of freedom: df=(r-1)(c-1)

Expected cell count:

2

2

11

( )O EE

ij ij

ijj

c

i

r

ER C

nij

i j

A and B are independent if: P(AUB) = P(A)P(B). If the first and second classification categories are independent:Eij = (Ri)(Cj)/n

Contingency Table Analysis: A Chi-Square Test for Independence

Page 43: Nonparametric Methods and Chi-Square Tests Session 5.

Industry TypeService

(Expected)Nonservice(Expected) Total

Profit(Expected)

42(60*48/100)=28.8

18(60*52/100)=31.2

60

Loss(Expected)

6(40*48/100)=19.2

34(40*52/100)=20.8

40

Total 48 52 100

ij O E O-E (O-E)2 (O-E)2/E11 42 28.8 13.2 174.24 6.050012 18 31.2 -13.2 174.24 5.584621 6 19.2 -13.2 174.24 9.075022 34 20.8 13.2 174.24 8.3769

2: 29.0865

2(0.01,(2-1)(2-1))=6.63490

H0 is rejected at the 0.01 level andit is concluded that the two variablesare not independent.

Yates corrected 2 for a 2x2 table:

2

Oij Eij

Eij

0 52

.

Contingency Table Analysis: Example 5-14

Page 44: Nonparametric Methods and Chi-Square Tests Session 5.

MTB > Unstack (C3) (c4) (c5) (c6) (c7);SUBC> Subscripts C2.MTB > chisquare c4-c7

Chi-Square Test

Expected counts are printed below observed counts

C4 C5 C6 C7 Total 1 22 21 34 56 133 27.43 30.81 34.19 40.56

2 39 45 42 68 194 40.02 44.95 49.88 59.16

3 77 89 96 80 342 70.55 79.24 87.93 104.29

Total 138 155 172 204 669

ChiSq = 1.077 + 3.126 + 0.001 + 5.881 + 0.026 + 0.000 + 1.244 + 1.322 + 0.590 + 1.203 + 0.741 + 5.656 = 20.867df = 6, p = 0.002

Given the p-value of 0.002, the null hypothesis of independence can be rejected at any common level of significance.

Using the Computer: Example 5-15

Page 45: Nonparametric Methods and Chi-Square Tests Session 5.

MTB > ChiSquare C1 C2 C3.

Chi-Square Test.

Expected counts are printed below observed counts.

C1 C2 C3 Total 1 40 35 60 135 45.00 45.00 45.00

2 60 65 40 165 55.00 55.00 55.00

Total 100 100 100 300

ChiSq = 0.556 + 2.222 + 5.000 + 0.455 + 1.818 + 4.091 = 14.141df = 2, p = 0.001

5-10 Chi-Square Test forEquality of Proportions

Page 46: Nonparametric Methods and Chi-Square Tests Session 5.

MTB > median c5 k1Column Median Median of C5 = 31.500MTB > let c6=c5-k1MTB > let c7=sign(c6)MTB > Table C4 C7;SUBC> Counts;SUBC> ChiSquare 2.Tabulated Statistics ROWS: C4 COLUMNS: C7 -1 1 ALL 1 4 6 10 5.00 5.00 10.00 2 5 5 10

5.00 5.00 10.00 3 6 4 10

5.00 5.00 10.00 ALL 15 15 30

15.00 15.00 30.00 CHI-SQUARE = 0.800 WITH D.F. = 2

Chi-Square Test for the Median: Example 5-16

Page 47: Nonparametric Methods and Chi-Square Tests Session 5.

Figure 5-12:MTB > RUNS ABOVE AND BELOW 30, C1

Runs Test C1 K = 30.0000 The observed no. of runs = 18 The expected no. of runs = 26.8462 24 Observations above K 28 below The test is significant at 0.0128

Figure 5-13:MTB > mann-whitney (alternative=1) c1 c2Mann-Whitney Confidence Interval and Test

C1 N = 10 Median = 37.50C2 N = 10 Median = 27.00Point estimate for ETA1-ETA2 is 11.0095.5 Percent C.I. for ETA1-ETA2 is (7.00,18.00)W = 145.5Test of ETA1 = ETA2 vs. ETA1 > ETA2 is significant at 0.0012The test is significant at 0.0012 (adjusted for ties)

5-11 Using the Computer: Mann-Whitney Test

Page 48: Nonparametric Methods and Chi-Square Tests Session 5.

MTB > let c3=c1-c2MTB > wtest c3

Wilcoxon Signed Rank Test

TEST OF MEDIAN = 0.000000 VERSUS MEDIAN N.E. 0.000000

N FOR WILCOXON ESTIMATED N TEST STATISTIC P-VALUE MEDIANC3 11 11 12.5 0.075 -14.75

C1 C2 C3143 165 -22124 170 -46179 231 -52166 154 12133 200 -67167 169 -2134 149 -15104 111 -7190 202 -12121 98 23144 152 -8

Table 5-14

Using the Computer:Wilcoxon Signed-Rank Test

Page 49: Nonparametric Methods and Chi-Square Tests Session 5.

MTB > Kruskal-Wallis C1 C2.

Kruskal-Wallis Test

LEVEL NOBS MEDIAN AVE. RANK Z VALUE 1 9 15.00 9.9 -0.71 2 7 18.00 17.5 3.39 3 5 12.00 3.9 -2.93OVERALL 21 11.0

H = 14.52 d.f. = 2 p = 0.001H = 14.72 d.f. = 2 p = 0.001 (adjusted for ties)

C1 C212 114 115 112 115 117 115 117 116 118 216 217 219 218 221 220 211 312 310 312 314 3

Table 5-15

Using the Computer:Kruskal-Wallis Test

Page 50: Nonparametric Methods and Chi-Square Tests Session 5.

MTB > print c1 c2Row C1 C2 1 86 54 2 89 59 3 97 66 4 54 20 5 66 70 6 49 57 7 40 81 8 69 90 9 22 60 10 39 95

MTB > rank c1 c3MTB > rank c2 c4MTB > correlation c3 c4

Correlations (Pearson)Correlation of C3 and C4 = -0.236

Table 5-16

Using the Computer:Rank Correlation

Page 51: Nonparametric Methods and Chi-Square Tests Session 5.

c1 c2 c33 1 43 2 03 3 04 1 104 2 24 3 95 1 65 2 135 3 5

MTB > Table 'c1' 'c2';SUBC> Frequencies 'c3';SUBC> ChiSquare 2.Tabulated Statistics ROWS: c1 COLUMNS: c2 1 2 3 Total 3 4 0 0 4 1.63 1.22 1.14 4.00 4 10 2 9 21 8.57 6.43 6.00 21.00 5 6 13 5 24 9.80 7.35 6.86 24.00 Total 20 15 14 49 20.00 15.00 14.00 49.00 CHI-SQUARE = 16.913 WITH D.F. = 4

Table 5-17

Using the Computer:Chi-Square Test


Recommended