Mann Whitney U Test And Chi Squared

24
Mann-Whitney U Test and Chi Squared.. More tests of significance- Yipee.

Transcript of Mann Whitney U Test And Chi Squared

Page 1: Mann Whitney U Test And Chi Squared

Mann-Whitney U Test and Chi Squared..

More tests of significance- Yipee.

Page 2: Mann Whitney U Test And Chi Squared

The Mann Whitney U Test.

• This test should be used when you are comparing two places.

• For example- The micro climate of a wood compared with a field.

• There are 3 versions, their use of which depends on the number of observations you have carried out.

Page 3: Mann Whitney U Test And Chi Squared

Fewer than 9 readings. • Stage1- Call one sample A and the other B• Stage 2 Call the number of values in the smaller sample n1 and the

number of samples in the larger sample n2.• Stage 3 Place all the values together in rank order. (from smallest to

largest)• Stage 4 Inspect each B in turn and count the number of A’s which

precede it. Add up the total to get a U value.• Stage 4 repeat stage 4, but this time inspect each A in turn and

count the number of B’s which precede it. Add up the total to get a second U value.

• Taking the smaller of the two U values look up the probability value associated with it in the appropriate table. Multiply this by 100 to get the percentage probability figure that the difference between your two sample sets could have occurred by chance.

Page 4: Mann Whitney U Test And Chi Squared

Example.

• A Temps out a wood 3.5, 3.7, 4.4, 4.0, 4.6, 4.5• B Temps in a wood 3.2, 3.3, 4.2, 3.4, 3.6, 4.3• N1 =6• N2 = 6• B B B A B A A B B A A A• 3.2 3.3 3.4 3.5 3.6 3.7 4.0 4.2 4.3 4.4 4.5 4.6• STAGE 4 U= 0+0+0+1+3+3=7• STAGE 5 U= 3+4+4+6+6+6= 29. • STAGE 6 U= 7. The correct table is D. The critical value =

0.047X100 = 4.7The chance that the temperatures measured out of the wood were

warmer just by chance is only 4.7%

Page 5: Mann Whitney U Test And Chi Squared

2

• Fewer than 20 readings (n1) in one sample and 9-20 readings in the other.

• Stage 1-Tabulate the readings in two separate columns. Rank the readings, treating them as one group. The smallest value is rank 1.

• Stage 2 – Add the ranks for n1 (to get ∑ R1). Add the ranks for n2 (∑ R2).

• Stage 3 Calculate the formula • U1= n1n2+ 1 n1 (n1+1) - ∑r1.

2

Page 6: Mann Whitney U Test And Chi Squared

• N1= number of sample readings in one area.

• N2= number of sample readings in the other area, with n1 representing the smaller of the two numbers, if they are different.

• ∑R1 = sum of the ranks of readings.

Page 7: Mann Whitney U Test And Chi Squared

• Stage 4 Calculate the similar formula • U2= n1n2+ 1 n2 (n2 + 1) - ∑R2.

2 • ∑R2 =sum of the ranks of readings of n2.• Stage 5 You now have two U values. Select the smallest

of the two.• Using your values of n1 and n2, look up the critical value

of U in table J.• If the critical value U is more than your calculated value

of U then there is a 5% or less probability that the difference between the two samples sets could have occurred by chance.

• If the critical value of U is less than your calculated value of U, then there is a more than 5% probability that the difference between the two sample sets could have occurred by chance alone.

Page 8: Mann Whitney U Test And Chi Squared

Example.

• Aim to see if office rents are higher in west London than London Docklands.

West London Docklands

32.6 30.4

31.2 26.6

36.6 31.0

35.6 31.1

36.1 32.0

28.4 33.2

34.5 28.3

34.2 32.9

34.9 30.9

33.9 30.0

36.4

30.6

26.2

Page 9: Mann Whitney U Test And Chi Squared

Stage 1 and 2.West London Rank (R1) Docklands Rank (R2)

32.6 13 30.4 6

31.2 11 26.6 2

36.6 23 31.0 9

35.6 20 31.1 10

36.1 21 32.0 12

28.4 4 33.2 15

34.5 18 28.3 3

34.2 17 32.9 14

34.9 19 30.9 8

33.9 16 30.0 5

36.4 22

30.6 7

26.2 1

∑ R1 =162 ∑R2= 114

Page 10: Mann Whitney U Test And Chi Squared

Stage 3

• U1= n1n2+ 1 n1 (n1+1) - ∑r1.

2

10X 13 + 1 10(10+1) -162= 23

2

=23

Page 11: Mann Whitney U Test And Chi Squared

Stage 4

• U2= n1n2+ 1 n2 (n2 + 1) - ∑R2.

2

• 10X 13 + 1 X 13(13+1) – 114= 107

2

=107

Page 12: Mann Whitney U Test And Chi Squared

Stage 5

• N1 =10

• N2 = 13

• Critical value = 37.

• 37 is more than 23, therefore there is a 5% or smaller probability that property values are higher in west London than in the Docklands.

Page 13: Mann Whitney U Test And Chi Squared

Samples of more than 20

• Stages 1-3 as we already discussed. This will give you the value of U, n1 and n2.

• Stage 4 Calculate Z

Z= U – n1+n2

(n1)(n2)(n1+n2+1)

12

Page 14: Mann Whitney U Test And Chi Squared

Stage 5

• Look up your critical value using your Z value. Multiply this by 100 to find the percentage probability that the difference between the two sample sets could be due to chance.

Page 15: Mann Whitney U Test And Chi Squared

Chi Squared.

• The Chi Squared test can only be used on data which has the following characteristics.

1. The data must be in the form of frequencies counted in each of a number of categories. Data on the interval scale (Data which have a precise numerical meaning - height above sea level, population of a town etc) can be grouped into categories to enable this test.

2. Total observations need to be more than 20. 3. The expected frequency should not be less than 5.4. The observations should not be such that one

influences the other.

Page 16: Mann Whitney U Test And Chi Squared

Chi- Squared for 2 variables.

• Stage 1- Tabulate the data- I will show you how to do this in a few slides- labelled 0

• Stage 2- Calculate the number of counts you would expect to find in each category if the categories had no impact on these.

• Stage 3 calculate the formula…

Page 17: Mann Whitney U Test And Chi Squared

• Xsquared= ∑(O-E)squaredE.

X squared= Chi Squared Figure.

O=Observed Frequency.

E= Expected frequency.

Page 18: Mann Whitney U Test And Chi Squared

Stage 4 and 5

• Stage 4- Calculate the degrees of freedom. This is simply one less than the total number of categories.

• Df= n – 1.• Where Df = degrees of freedom.

N= Number of categories in the test.Stage 5- Using the worksheet, the calculated value

of Xsquared and the degrees of freedom, read off the probability that the data frequencies you are testing could have occurred by chance.

Page 19: Mann Whitney U Test And Chi Squared

Example.

• You have visited four equal size areas, each on a different rock type. You counted the number of streams in each area.

• The results were as follows.

Rock Type. No. of streams.

Chalk 7

Granite 58

Limestone 15

Sandstone 20

Page 20: Mann Whitney U Test And Chi Squared

What do we want to know• You now wish to know if these results are a true reflection of the nature of

each rock type or whether they could be simply the result of chance.• The Chi Squared test can be used because…1. The data is in the form of counts.2. The total number of streams observed exceeds 20.3. The expected frequency in any one fraction exceeds 4. This is the

number of streams you would expect if rock type had no influence on stream densities. In this case it is the total number of streams (100) divided by the number of rock types (4).

4. The observations are independent (the number of streams on one rock type does not influence the number of streams on another).

The hypothesis we are trying to prove is that there is a significant difference between the sample data sets i.e rock type does influence stream density.

Page 21: Mann Whitney U Test And Chi Squared

The Data.

Rock type Observed Frequency O

Expected frequency (e)

(O-E)squared

E

Chalk 7 25

Granite 58 25

Limestone 15 25

Sandstone 20 25

Page 22: Mann Whitney U Test And Chi Squared

Formula

• Xsquared= ∑(O-E)squaredE.

=61.6

• Df=n-1

• Df=4-1

• =3.

Page 23: Mann Whitney U Test And Chi Squared

Stage 5

• From the graph we read off the degrees of freedom (3) on the horizontal axis against the xsqaured value (61.6) on the vertical.

• The resulting point is above the line marked 0.1 chance in 100. This means that the probability that the data given above could be due to chance alone is less than 1 in 100.

Page 24: Mann Whitney U Test And Chi Squared

• That is the end of the Mann Whitney U test and Chi Squared- now go and lie down.

• Next week Correlation and Spearman’s Rank Correlation Coefficient.