You are on page 1of 25

H0 : µΑ = µΒ SPSS

t-test and ANOVA


By the end of this lecture you should
understand
›Carrying out a t-test
›Why we need ANOVA
›Entering data and running a 1-way ANOVA
›Interpreting a 1-way ANOVA

H0 : µΑ = µΒ
Basic Stats. Revision
Assumptions and requirements
›All data are independent (no data point can
appear twice) (APPLIES TO ALL TESTS)
›Variances must be homogenous (can be fixed
using transformations)
›For ANOVA and t tests the assumption of a
normal distribution of the data is least important
and can effectively be ignored

1
H0 : µΑ = µΒ
Errors

Accept Reject

Type I error
Null Hyp. True
 by convention
p(type I) = α
= 0.05

Null Hyp. False Type II error


p (type II) = β

3

H0 : µΑ = µΒ A t-test

»Comparing 2 means (t test), robust, reliable.

µA µB 4

2
H0 : µΑ = µΒ
A Basic t-test
› Investigation into group size in kangaroos. The
literature says that the average group size is 10

› Model: You are testing the model that your


group is representative of other studies

› Hypothesis is that your mean is statistically not


different from 10

›Collect data from 25 groups 5

H0 : µΑ = µΒ
A Basic t-test
› 2 ways of doing this

›1. Excel using the formula, with n-1 degrees of


freedom

3
H0 : µΑ = µΒ
A Basic t-test

H0 : µΑ = µΒ
A Basic t-test
› Use a statistical programme

› Good example is SPSS

› Is NOT a spreadsheet

› 1. copy and paste data into cells, then name


cells

4
9

Then double click on


var00001

10

5
Code Label
Grouping
(will appear in print-outs)

11

12

6
13

Mean is significantly less than


10, t24 = 9.28, P < 0.001
14

7
H0 : µΑ = µΒ
A Basic t-test
› 2-sample t-test to compare 2 means

› Model: You are testing the model that your


groups are different from another 20 groups from
different habitats

› Hypothesis is that the average group size differs


between groups seen in area A ) (bush) and area
B (grass

15
›Collect data from 20 groups in each habitat

Need to code the groups

16

8
17

18

9
P > 0.05

So, the mean size of groups of kangaroos in


each habitat was not significantly different
t38 = 0.662, NS 19

H0 : µΑ = µΒ
ANOVA
By the end of this lecture you should
understand
›Why we need ANOVA
›Entering data and running a 1-way ANOVA
›Interpreting a 1-way ANOVA
›Entering data and running a 2 way
orthogonal ANOVA
›Interpretation of such an ANOVA
20

10
H0 : µΑ = µΒ
Basic Stats. Revision
Assumptions and requirements
›All data are independent (no data point can
appear twice) (APPLIES TO ALL TESTS)
›Variances must be homogenous (can be fixed
using transformations)
›For ANOVA and t tests the assumption of a
normal distribution of the data is least important
and can effectively be ignored

21

H0 : µΑ = µΒ Why ANOVA?

»Comparing 2 means (t test), robust, reliable.


»What happens for 3 levels of a treatment,
e.g. 3 diets affecting growth of shrimps?
»t tests look for differences in treatment
means, consider overlap of “tails”

22
µA µB

11
H0 : µΑ = µΒ t tests
»3 means, now have 11 possible tails......
OW!
»Instead of using 1 test, could use 3 tests
» A vs B, A vs C, and B vs C
»This approach... 2 problems...
» 1. Problems of independence
» 2. Increased probability of type I error (on 3
tests rises to 0.14 from 0.05)
»Can get round pt 2 by corrections
(Bonferroni), but this increases probability of
23
type II error and gives reduced power

H0 : µΑ = µΒ
ANOVA

»Can use an ANOVA for >2 means

»Allows development of complex designs

24

12
H0 : µΑ = µΒ Language Break!
»Response variable: the thing you are measuring
»Most people think in terms of treatment(s)
»Clumsy and ambiguous term
»Example.... To investigate the effect of growth
enhancers on the cattle.

Treatment (T) effect: Factor: Diet


Diet 3 Levels

T1 = normal diet L1 = normal diet


T2 = diet + x L2 = diet + x
T3 = diet + 2x L3 = diet + 2x 25

H0 : µΑ = µΒ
1-way ANOVA on SPSS
»Model: Temperature controls the
metamorphosis rate of barnacles cyprids
»Hypothesis: If temperature increases, time
taken for metamorphosis is reduced (H1:
µtime at high T0C < µtime at medium T0C <
µtime at low T0C

26

13
Double click on var0001
to get variable view and
name vars

27

28

14
29

H0 : µΑ = µΒ
1-way ANOVA on SPSS
»CRITICAL ASSUMPTIONS

»Assumptions of independence.. DESIGN

»Assumptions of Homogeneity of Variance..

»Normality… ignore except for extreme cases


30

15
H0 : µΑ = µΒ
1-way ANOVA on SPSS

31

H0 : µΑ = µΒ
Heterogeneity of variance
» Analogous to looking for traffic when
crossing the road

»2 useful tests… Levene’s (has some


problems but otherwise ok)

»Cochran’s (excellent, but only for


BALANCED samples… σmax/Σσ
32

16
Post-hoc tests
Single test
3 means though

A≠B≠C
A=B≠C
A≠B=C
A=B=C
C≠A=B
C=A=B
Use a Post-hoc
test, lots… SNK 33

34

17
H0 : µΑ = µΒ
1-way ANOVA on SPSS
METAM
Sum of
Squares df Mean Square F Sig.
Between Groups 6174.050 2 3087.025 75.014 .000
Within Groups 1111.125 27 41.153
Total 7285.175 29

Source SS df MS F P
Temperature 6174.1 2 3087.03 75.01 P <0.001
Residual 1111.1 27 41.15
Total 7285.2 29

Result Written as: Temperature significantly


reduced the time taken for cyprids to metamorphose
35
(F(2,27) = 75.01, P < 0.001) (Table 1)

Cyprid Metamorphosis Times in Relation to Temperature

50

45
Time Taken (Hours) to metamorphosis

40

35

30

25

20

15

10

0
Low Medium High
Temperature

36

18
2-way Factorial ANOVA on
SPSS
»Model: People disturb birds, so kestrels will be
less successful in foraging in human utilised areas.
Additionally complex vegetation will mean prey is
harder to see, thus reducing success rate.
»Hypotheses:
» In highly disturbed areas kestrels will have less
success at foraging than in medium disturbed
areas, and this will be less than undisturbed
areas.
» In complex vegetation areas kestrels will have
less success at foraging than in grassy areas.37

NOTE SORT ORDER

38

19
2-way Factorial ANOVA on
SPSS
»Paste data from Excel into SPSS, code both
factors using values box in variable view

39

40

20
41

{
42

21
Source SS df MS F P
Vegetation Ve 4556.3 1 4556.25 52.90 < 0.001
Disturbance Di 118.2 2 59.11 0.69 > 0.5
Ve x Di 194.7 2 97.33 1.13 > 0.3
Residual 2583.8 30 86.13
Total 15523.0 36

Effect of Vegetation Type on Success Rates of Foraging Kestrels

40

35
High Dist
Success Rates (Kills per day)

30 Med Dist
Low dist

25

20
Interpret?
15

10

0
Grass Complex
43
Vegetation

2-way Factorial ANOVA : SPSS


»Too simplistic?

»Madeitup, I (1989) redid the experiment

»Kestrels 2 data set,

44

22
2-way Factorial ANOVA : SPSS
Source SS df MS F P
Vegetation Ve 850.7 1 850.69 8.71 < 0.01
Disturbance Di 840.4 2 420.19 4.3 < 0.05
Ve x Di 1395.7 2 697.86 7.15 < 0.01
Residual 2928.8 30 97.63
Total 13269.0 36

45

Effect of Vegetation Type on Success Rates of Foraging Kestrels

30

low Dist
Success Rates (Kills per day)

25 Med Dist
High dist

20

15

10

0
Grass Complex

Vegetation

46

23
2-way Factorial ANOVA on
H0 : µΑ = µΒ SPSS
»What have I missed?

»Assumptions of independence.. DESIGN

»Assumptions of Homogeneity of Variance..


Test data
»stat, ANOVA, Homogeneity of Variance
» use Levene’s test?
47

Homogeneity of Variance
Test Homogeneity of
Variance
Non Significant Significant
Result Result
Do ANOVA Transform Data
and Interpret and re-test
Fixed Problem
of heterogeneity?
Yes No
Do ANOVA Do ANOVA
and interpret
ANOVA NS ANOVA Sig.
Absolutely Fine
Design Large?
N > 30, a > 6
Yes No
Probably OK Interpret with
caution, treat as pilot 48

24
Summary and survival guide
›ANOVA is more powerful in terms of flexibility
› data must be independent
› variances must be homogeneous
› Normality is not important
›Nearly all biological hypotheses are about
interactions... Know what that means!
›SPSS is useful for general purposes
›All detailed in your refs + Dytham, C. (1999)
Choosing and using statistics. Blackwell. (note he
is wrong about assumptions of normality.. Ignore it!)
49

25

You might also like