Presentation is loading. Please wait.

Presentation is loading. Please wait.

Testing for a difference

Similar presentations


Presentation on theme: "Testing for a difference"— Presentation transcript:

1 Testing for a difference
U1 = n1 n2 + ½ n1 (n1 + 1) – R1 Mann-Whitney U-test Testing for a difference Note: the equivalent of this for paired data is Wilcoxon

2 What is it? A technique to see if there is a difference between the medians of two sets of data. It is non-parametric (assumes the data is not normally distributed). However, it does assume that there is similar dispersion of both sets of data (you can check this on a dispersion graph).

3 Mann-Whitney U test can be used...
You can only compare two sets of data The data must be ordinal (ranked in order) You need a minimum of 5 values in each data set It is not advisable to use more than 20 values in each data set The Mann-Whitney U test starts with a null hypothesis.

4 What does it do? Tests for a difference in averages
(medians – the middle value – to be exact) Compares two cases (eg species diversity in polluted and unpolluted water) The data can be of any kind, provided it’s numerical eg lengths, percentages, numbers of people… The samples do not have to be of the same size You can use this test for any data, provided you have at least 5 values in each sample. If the data are numbers of people/items etc, then chi-squared could also be used

5 Planning to use it? Make sure that… You want to test for difference
You have just two cases to compare You have five or more values from each case If your data are likely to be normally distributed, it may be easier to get a significant result using the t-test It’s still OK to use MW instead of t, if the student would rather

6 How does it work? You assume (null hypothesis) there is no difference between the two cases The test involves ranking all the data together, then adding up the ranks for each sample. If, for example, the values in the first sample were all much bigger, then the first sample would have higher ranks

7 Strength and Weaknesses
Strengths Weaknesses You can use two data sets that have different sizes e.g. One data set could have 10 values and the other only 8 You can state whether the relationship is significant or if your results occurred by chance You can see clearly whether there is a difference in the median of two sets of data It is a lengthy calculation and prone to human error It does not explain why the difference in the two data sets occurs

8 Doing the test These are the stages in doing the test:
Write down your hypotheses Doing the ranking Calculating your U-values Look at the tables Make a decision The underlined terms are hyperlinks to the appropriate slide Click here for an example

9 Hypotheses H0: There is no difference between population 1 and population 2 For H1, you have a choice, depending on what alternative you were looking for. H1: Population 1 is larger than population 2 eg: Species diversity in unpolluted water is greater than in polluted water or H1: Population 1 is different to population 2 eg: Species diversity is different in unpolluted water and polluted water Unless you have a good geographical reason for expecting one to be larger, you should choose “different” for H1 The form of the alternative hypothesis should be chosen before getting the data – to ensure there really is a good reason for 1-tailed version, if chosen

10 Ranking We need to put all the data together, and rank it, but remember which sample it’s from. One easy way to do this is to write data from different samples in different colours Give rank 1 to the highest value, rank 2 to the second highest and so on. If there are any ties, give them the average of the ranks they would have had. eg Suppose three pieces of data tie for second place. They would otherwise have been in 2nd, 3rd and 4th place. So give them all the average of 2nd, 3rd and 4th – that’s rank 3. It is important to do the ranking this way round – otherwise the one-tailed hypothesis test won’t work Ties are done as in Spearman’s

11 U-values First work out: Then work out R1 = sum of ranks for sample 1
U1 = n1 n2 + ½ n1 (n1 + 1) – R1 U2 = n1 n2 + ½ n2 (n2 + 1) – R2 n1 , n2 are the sizes of the two samples

12 Sizes of the two samples.
Tables This is a Mann-Whitney table You usually have to look in a different table for different significance levels Sizes of the two samples. The bigger one is “n2” Some MW tables have 2 or 3 significance levels on different rows on the table.

13 Make a decision If you used: H1: Population 1 is larger than population 2: You are doing a 1-tailed test (1 alternative only considered) Choose the U-value from the sample you’d expected to be larger (It should be the smaller U-value) If your U-value is smaller than the tables value, you reject your null hypothesis If you used H1: Population 1 is different to population 2: You are doing a 2-tailed test (both alternatives considered) Choose the smaller of the two U-values Worth emphasising that this one is unusual – in most cases, reject H0 if our value is larger than tables

14 Example: Invertebrates in Long & Short Grass
Data were obtained for the number of invertebrates caught in sweep nets at 8 sites in long and short grass. Hypotheses: H0: There is no difference in the number of invertebrates in long and short grass H1 There is a difference in the number of invertebrates in long and short grass Could actually use chi-squared here

15 The data Site 1 2 3 4 5 6 7 long grass 41 43 34 37 15 22 27
short grass

16 Ranking We need to put all the data together, and rank it, but remember whether it’s a long or short grass We’ll do this with colours long short We have: 41, 43,34, 37,15, 22, 27, 47, 38, 98, 27, 72, 65 In order: 98, 72, 65, 47, 43, 41, 38, 37, 34, 27, 27, 22, 15 Ranks: Note tied ranks for the two “27”s.

17 U-Values First find the sum of ranks for long and short grass:
Now work out the two U values, using the formulae: U1 = n1 n2 + ½ n1 (n1 + 1) – R1 U2 = n1 n2 + ½ n2 (n2 + 1) – R2 So U1 = (7)(6) + ½ 7 (7 + 1) – = 6.5 (long grass) U2 = (7)(6) + ½ 6 (6 + 1) – = 35.5 (short grass) Doesn’t matter which you call “sample 1” and which you call “sample 2”, provided you are consistent

18 Sizes of the two samples.
Tables This is a Mann-Whitney table You usually have to look in a different table for different significance levels Sizes of the two samples. The bigger one is “n2” Some MW tables have 2 or 3 significance levels on different rows on the table.

19 The Test Since our H1 referred to “a difference”, we’re doing the 2-tailed test U = smaller of U1 and U2 = 6.5 Critical value (5%) = 6 Our value is larger. So accept H0 – there is no significant difference between the numbers of invertebrates in long grass and in short grass. If we’d done a 1-tailed test, we could have rejected H0.

20 Inner city (St Peter & the Waterfront) Outer Suburb (Plymstock)
One for you to try... In this example a student is investigating economic deprivation across the city of Plymouth. Student’s hypothesis: There is a greater income deprivation score for inner-city areas than outer suburbs. The income deprivation score measures the percentage of people who are income-deprived. The higher the score, the more income-deprived the area is. Inner city (St Peter & the Waterfront) Outer Suburb (Plymstock) 0.53 0.05 0.40 0.09 0.24 0.06 0.25 0.12 0.08 0.16 0.10 0.20 0.13

21 Sizes of the two samples.
Tables This is a Mann-Whitney table You usually have to look in a different table for different significance levels Sizes of the two samples. The bigger one is “n2” Some MW tables have 2 or 3 significance levels on different rows on the table.

22 Doing the test These are the stages in doing the test:
Write down your hypotheses Doing the ranking Calculating your U-values Look at the tables Make a decision The underlined terms are hyperlinks to the appropriate slide Click here for an example

23 Inner city (St Peter & the Waterfront) U1 Outer Suburb (Plymstock)
Rank the data Inner city (St Peter & the Waterfront) U1 Outer Suburb (Plymstock) U2 0.53 0.05 0.40 0.09 0.24 0.06 0.25 0.12 0.08 0.16 0.10 0.20 0.13 Give a different colour for each sample and then rank them in order from the largest value to the smallest value. 0.53, 0.40, 0.25, 0.24, 0.20, 0.16, 0.13, 0.12, 0.12, , 0.10, 0.09, 0.08, 0.08, 0.06, 0.05, 0.05

24 U-Values First find the sum of ranks for long and short grass:
Inner City: =42 Outer suburbs: =94 Now work out the two U values, using the formulae: U1 = n1 n2 + ½ n1 (n1 + 1) – R1 U2 = n1 n2 + ½ n2 (n2 + 1) – R2 So U1 = (8)(8) + ½ 8 (8 + 1) – 42 = 58 (Inner city) U2 = (8)(8) + ½ 8 (8 + 1) – 94 = 6 (Suburbs) Doesn’t matter which you call “sample 1” and which you call “sample 2”, provided you are consistent

25 Sizes of the two samples.
Tables This is a Mann-Whitney table You usually have to look in a different table for different significance levels Sizes of the two samples. The bigger one is “n2” Some MW tables have 2 or 3 significance levels on different rows on the table.

26 The Test Since our H1 referred to “a difference”, we’re doing the 2-tailed test U = smaller of U1 and U2 = 6 Critical value (5%) = 13 Our value is smaller. So we accept the Hypothesis – There is a greater income deprivation score for inner-city areas than outer suburbs. If we’d done a 1-tailed test, we could have rejected H0.

27 Sediment size foe Darcy Beach (x) Sediment size for Mapleton (y)
Mann-Whitney Put the two data sets in order Sediment size foe Darcy Beach (x) Sediment size for Mapleton (y) 32 45 42 26 12 19 40 21 33 16 4 9 3 N= 9 N = 9 .

28 Answers Here are our 2 data sets. Darcy Beach in black and Mapleton in blue 32,42, 26,19,21,16,12,4,3, 45,32,12,40,33,26,16,9,4 Then we order them and rank them. 45 42 40 33 32 26 21 19 16 12 9 4 3 1 2 5.5 7.5 10 11.5 13.5 15 16.5 18

29 The sum of the ranks for Darcy Beach is:- 93.5
The sum of the ranks for Mapleton is : Using the formula’s we have to work out the U value U1 = (9)(9) + ½ 9 (9 + 1) – 93.5 = 32.5 U2 = (9)(9) + ½ 9 (9 + 1) – 77.5 = 48.5 You can check your formula calculations by making sure your 2 U values when added equal the same as your two N numbers multiplied together

30 The smallest U number is for Darcy Beach at the value of 32.5.
Our critical value (5%) = 17 Our value is larger. We accept our null hypothesis.


Download ppt "Testing for a difference"

Similar presentations


Ads by Google