FACTORIAL ANOVA - Elder Laboratoryelderlab.yorku.ca/~elder/teaching/psyc3031/lectures/Lecture 8 Factorial... · Factorial ANOVA PSYC 3031 INTERMEDIATE STATISTICS LABORATORY J. Elder

Post on 14-Oct-2019

24 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

Transcript

PSYC 3031 INTERMEDIATE STATISTICS LABORATORY J. Elder

FACTORIAL ANOVA

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

2

Acknowledgements

¨  Some of these slides have been sourced or modified from slides created by A. Field for Discovering Statistics using R.

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

3

Aims

¨ Rationale of factorial ANOVA ¨ Partitioning variance ¨ Interaction effects

¤ Interaction graphs ¤ Interpretation

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

4

What is Two-Way Independent ANOVA?

¨  Two independent variables ¤ Two-way = 2 Independent variables ¤ Three-way = 3 Independent variables

¨  Different participants in all conditions ¤  Independent = ‘different participants’

¨  Several independent variables is known as a factorial design.

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

5

Benefit of Factorial Designs

¨  We can look at how variables interact. ¨  Interactions

¤  Show how the effects of one IV might depend on the effects of another

¤ Are often more interesting than main effects.

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

6

An Example

¨  Field (2009): Testing the effects of alcohol and gender on ‘the beer-goggles effect’:

¤  IV 1 (Alcohol): none, 2 pints, 4 pints

¤  IV 2 (Gender): male, female

¨  Dependent variable (DV) was an objective measure of the attractiveness of the partner selected at the end of the evening.

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

9

Step 1: Calculate SST

65 50 70 45 55 30

50 55 65 60 65 30

70 80 60 85 70 30

45 65 70 65 55 55

55 70 65 70 55 35

30 75 60 70 60 20

70 75 60 80 50 45

55 65 50 60 50 40

Grand Mean = 58.33

66896614878190

12

.)(.)(SS grandT

=−=

−= Ns

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

10

Step 2: Calculate SSM

( )∑ −= 2grandMSS xxn ii

16754791362412451125136258411121391362584136242

2883085458817485458829528

335883358833588

335883358833588

222222

222

222

.......

2.705)().().().().().(

).(35.625).(57.5).(66.875

).(62.5).(66.875).(60.625SSM

=+++++=

−+−++++=

−+−+−+

−+−+−=

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

11

Step 2a: Calculate SSA

( )∑ −= 2grandASS xxn ii

A1: Female A2: Male

65 70 55 50 45 30

70 65 65 55 60 30

60 60 70 80 85 30

60 70 55 65 65 55

60 65 55 70 70 35

55 60 60 75 70 20

60 60 50 75 80 45

55 50 50 65 60 40

Mean Female = 60.21 Mean Male = 56.46

751689256838256842488124

33582433582422

22

...

1.87)().(

).(56.46).(60.21SSGender

=+=

−+=

−+−=

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

12

Step 2b: Calculate SSB

Slide 12

( )∑ −= 2grandBSS xxn ii

B1: None B2: 2 Pints B3: 4 Pints

65 50 70 45 55 30

70 55 65 60 65 30

60 80 60 85 70 30

60 65 70 65 55 55

60 70 65 70 55 35

55 75 60 70 60 20

60 75 60 80 50 45

55 65 50 60 50 40

Mean None = 63.75 Mean 2 Pints = 64.6875

Mean 4 Pints = 46.5625

2 2 2Alcohol

2 2 2

SS 16(63.75 58.33) 16(64.6875 58.33) 16(46.5625 58.33)

16(5.42) 16(6.3575) 16( 11.7675)470.0224 646.6849 2215.58493332.292

= − + − + −

= + + −= + +=

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

13

Step 2c: Calculate SSAxB

Slide 13

MSS SS SS SSA B A B× = − −

MSS SS SS5479.167 168.75 3332.2921978.125

A B A BSS× = − −= − −=

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

14

Step 3: Calculate SSR

Slide 14

2 2 2 2R group1 1 group2 2 group3 3 group SS ( 1) ( 1) ( 1) ( 1)n ns n s n s n s n= − + − + − −K

5234878782135091096300974685171

717571747172

111

111

62

52

42

32

22

12

.....

)17.41()0()56.7()2.86()06.7()4.55(

)()()(

)()()(SS

group6group5group4

group3group2group1R

=+++++=×+×+×+×+×+×=

−+−+−+

−+−+−=

nsnsns

nsnsns

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

15

Orthogonal contrasts for the alcohol variable

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

16

Running a Factorial ANOVA in R

¨  Packages: ¤  car

n  Levene’s test ¤  compute.es

n  Effect sizes ¤  ggplot2

n  Graphs ¤ multcomp

n  Post-hoc tests ¤  pastecs

n  Descriptive statistics ¤  reshape

n  Reshaping the data

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

17

Procedure

¨  Explore the data ¤ Tests of normality, homogeneity of variance, etc.

¨  Construct contrasts ¨  Compute ANOVA ¨  Compute contrasts or post-hoc tests

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

18

Fitting a Factorial ANOVA Model

gogglesModel<-aov(attractiveness ~ gender + alcohol + gender:alcohol, data = gogglesData)

¨  Or: gogglesModel<-aov(attractiveness ~ alcohol*gender, data = gogglesData)

¨  If we want to look at the Type III sums of squares for the model, we need to also execute this command after we have created the model: ¤ Anova(gogglesModel, type="III")

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

19

Interpreting Factorial ANOVA

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

20

Interpretation: Main Effect Alcohol

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

21

Interpretation: Main Effect Gender

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

22

Interpretation: Interaction

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

23

What Is an Interaction?

6.25 6.25

5.625

−21.875

Is There Likely to Be a Significant Interaction Effect?

Is There Likely to Be a Significant Interaction Effect?

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

26

Interpreting Contrasts

¨  To see the output for the contrasts that we specified, execute: summary.lm(gogglesModel)

Factorial ANOVA

J. Elder PSYC 3031 INTERMEDIATE STATISTICS LABORATORY

27

Interpreting Contrasts

top related