Factorial ANOVA
description
Transcript of Factorial ANOVA
Factorial ANOVA
2 or More IVs
Questions (1) What are main effects in ANOVA? What are interactions in ANOVA? How do
you know you have an interaction? What does it mean for a design to be
completely crossed? Balanced? Orthogonal?
Describe each term in a linear model like this one:
ijkjkkjijk ey )(
Questions (2) Correctly interpret ANOVA summary
tables. Identify mistakes in such tables. What’s the matter with this one?
Source SS Df MS FA 512 2 (J-1) 128 128
B 108 1 (K-1) 108 54
AxB 96 2 (J-1)(K-1) 48 24
Error 12 5 N-JK 2
Questions (3) Find correct critical values of F from a table
for a given design. How does post hoc testing for factorial
ANOVA differ from post hoc testing in one-way ANOVA?
Describe a concrete example of a two-factor experiment. Why is it interesting and/or important to consider both factors in one experiment?
2-way ANOVA• So far, 1-Way ANOVA, but can have 2
or more IVs. IVs aka Factors.• Example: Study aids for exam
– IV 1: workbook or not– IV 2: 1 cup of coffee or not
Workbook (Factor A)
Caffeine (Factor B)
No Yes
Yes Caffeine only Both
No Neither (Control)
Workbook only
Main Effects (R & C means)N=30 per cell
Workbook (Factor A) Row Means
Caffeine(Factor B)
No Yes
Yes Caff =80SD=5
Both =85SD=5
82.5
No Control =75SD=5
Book =80SD=5
77.5
Col Means 77.5 82.5 80
X X
X X
Main Effects and Interactions• Main effects seen
by row and column means; Slopes and breaks.
• Interactions seen by lack of parallel lines.
• Interactions are a main reason to use multiple IVs
Workbook (Factor A)
86
84
82
80
78
76
74
Mea
n R
M T
est S
core
No Yes
Without Caffeine
With Caffeine
Factor B
Single Main Effect for B
2.0 1.0
Factor A
25
20
15
10
5
0
Mea
n R
espo
nseSingle Main Effect
B=1
B=2
A1 2
B1
2
10 10
20 20
(Coffee only)
Single Main Effect for A
2.0 1.0
Factor A
20
16
12
8
4
0
Mea
n R
espo
nse
Single Main Effect
B=1
B=2
A1 2
B12
10 2010 20
(Workbook only)
Two Main Effects; Both A & B
2.0 1.0Factor A
35
30
25
20
15
10
5
0
Mea
n R
espo
nse
Two Main Effects
B=1
B=2
A1 2
B12
10 2020 30
Both workbook and coffee
Interaction (1)
2.0 1.0Factor A
35
30
25
20
15
10
5
0
Mea
n R
espo
nse
Interaction 1
B=1
B=2
A1 2
B12
10 2010 30
Interactions take many forms; all show lack of parallel lines.
Coffee has no effect without the workbook.
Interaction (2)
2.0 1.0Factor A
25
20
15
10
5
0
Mea
n R
espo
nse
Interaction 2
B=1
B=2
A1 2
B12
10 2020 10
People with workbook do better without coffee; people without workbook do better with coffee.
Interaction (3)
2.0 1.0
Factor A
40
35
30
25
20
15
10
5
0
Mea
n R
espo
nse
Interaction 3
B = 1
B = 2
Coffee always helps, but it helps more if you use workbook.
Labeling Factorial Designs• Levels – each IV is referred to by its number
of levels, e.g., 2X2, 3X2, 4X3 designs. Two by two factorial ANOVA.
• Cell – treatment combination.• Completely Crossed designs –each level of
each factor appears at all levels of other factors (vs. nested designs or confounded designs).
• Balanced – each cell has same n. • Orthogonal design – random sampling and
assignment to balanced cells in completely crossed design.
ReviewWhat are main effects in ANOVA? What are interactions in ANOVA?
How do you know you have an interaction?
What does it mean for a design to be completely crossed? Balanced? Orthogonal?
Population Effects for 2-wayPopulation main effect associated with the treatment Aj (first factor): jj
Population main effect associated with treatment Bk (second factor): kk
The interaction is defined as , so the linear model is:
ijkjkkjijk ey )(jk)(
The interaction is a residual:
kjjkjk )(
kjjkjk ..)(
Each person’s score is a deviation from a cell mean (error). The cell means vary for 3 reasons.
Expected Mean Squares
E(MS error) = 2e
(Factor A has J levels; factor B has K levels; there are n people per cell.)
E(MS A) = 1
2
2
J
Knj
j
e
E(MS B) = 1
2
2
K
Jnk
k
e
E(MS Interaction) = )1)(1(
)( 2
2
KJ
nj k
jk
e
Note how all terms estimate error.
F TestsFor orthogonal designs, F tests for the main effects and the interaction are simple. For each, find the F ratio by dividing the MS for the effect of interest by MS error.
Effect F df
A J-1,N-JK
B K-1,N-JK
AxBInteraction
(J-1)(K-1), N-JK
errorMSAMS
errorMSBMS
errorMSABMS
Example Factorial Design (1)• Effects of fatigue and alcohol consumption on
driving performance.• Fatigue
– Rested (8 hrs sleep then awake 4 hrs)– Fatigued (24 hrs no sleep)
• Alcohol consumption– None (control)– 2 beers– Blood alcohol .08 %
• DV - performance errors on closed driving course rated by driving instructor.
Cells of the Design
Alcohol (Factor A)Orthogonal design; n=2
Fatigue (Factor B)
None(J=1)
2 beers(J=2)
.08 %(J=3)
Tired(K=1)
Cell 12, 4 M=3
Cell 216, 18M=17
Cell 318, 20M=19
Rested(K=2)
Cell 40, 2M=1
Cell 52, 4M=3
Cell 616, 18M=17
M=2 M=10 M=18
M=13
M=7
M=10
Factorial Example Results
Intox2 beersnoneAlcohol Consumption
25
20
15
10
5
0
Driv
ing
Err
ors
Factorial Design
Rested
Fatigued
Main Effects?Interactions? Both main effects and the interaction
appear significant. Let’s look.
Data Person DV Cell A alc B rest1 2 1 1 12 4 1 1 13 16 2 2 14 18 2 2 15 18 3 3 16 20 3 3 17 0 4 1 28 2 4 1 29 2 5 2 210 4 5 2 211 16 6 3 212 18 6 3 2Mean 10
Total Sum of SquaresPerson DV Mean D D*D1 2 10 -8 642 4 10 -6 363 16 10 6 364 18 10 8 645 18 10 8 646 20 10 10 1007 0 10 -10 1008 2 10 -8 649 2 10 -8 6410 4 10 -6 3611 16 10 6 3612 18 10 8 64Total 728
SS Within CellsPerson DV Cell Mean D*D1 2 1 3 12 4 1 3 13 16 2 17 14 18 2 17 15 18 3 19 16 20 3 19 17 0 4 1 18 2 4 1 19 2 5 3 110 4 5 3 111 16 6 17 112 18 6 17 1Total 12
SS A – Effects of AlcoholPerson M Level
(A)Mean (A)
D*D
1 10 1 2 642 10 1 2 643 10 2 10 04 10 2 10 05 10 3 18 646 10 3 18 647 10 1 2 648 10 1 2 649 10 2 10 010 10 2 10 011 10 3 18 6412 10 3 18 64Total 512
SS B – Effects of FatiguePerson M Level
(B)Mean (B)
D*D
1 10 1 13 92 10 1 13 93 10 1 13 94 10 1 13 95 10 1 13 96 10 1 13 97 10 2 7 98 10 2 7 99 10 2 7 910 10 2 7 911 10 2 7 912 10 2 7 9Total 108
SS Cells – Total BetweenPerson M Cell Mean
(Cell)D*D
1 10 1 3 492 10 1 3 493 10 2 17 494 10 2 17 495 10 3 19 816 10 3 19 817 10 4 1 818 10 4 1 819 10 5 3 4910 10 5 3 4911 10 6 17 4912 10 6 17 49Total 716
Summary Table Source SSTotal 728Between 716A 512B 108Within 12
Check: Total=Within+Between728 = 716+12
Interaction = Between – (A+B).Interaction = 716-(512+108) = 96.
Source SS df MS FA 512 2 (J-1) 256 128B 108 1(K-1) 108 54AxB 96 2 (J-1)(K-1) 48 24Error 12 6 (N-JK) 2
98.5)6,1,05.( F14.5)6,2,05.( F
Interactions
Choose the factor with more levels for X, the horizontal axis. Plot the means. Join the means by lines representing the other factor. The size of the interaction SS is proportional to the lack of parallel lines.
If interactions exist, the main effects must be qualified for the interactions. Here, effect of alcohol depends on the amount of rest of the participant.
Intox2 beersnoneAlcohol Consumption
25
20
15
10
5
0
Driv
ing
Err
ors
Factorial Design
Rested
Fatigued
ReviewCorrectly interpret ANOVA summary
tables. Identify mistakes in such tables. What’s the matter with this one?
Source SS Df MS FA 512 2 (J-1) 128 128
B 108 1 (K-1) 108 54
AxB 96 2 (J-1)(K-1) 48 24
Error 12 5 N-JK 2
Proportions of VarianceWe can compute R-squared for magnitude of effect, but it’s biased, so the convention is to use omega-squared.
70.7282
)2(2512)1(. 2.
totalSSerrorMSerrorMSJASSest Ay
15.7282
)2(1108)1(. 2.
totalSSerrorMSerrorMSKBSSest By
13.7282
)2)(1)(2(96)1)(1(. 2.
totalSSerrorMSerrorMSKJAxBSSest AxBy
Planned ComparisonsCell Mean C1 C21 A1B1 3 -1/3 1/22 A2B1 17 -1/3 -1/43 A3B1 19 -1/3 -1/44 A1B2 1 1/3 1/25 A2B2 3 1/3 -1/46 A3B2 17 1/3 -1/4
-6 -12B1 v B2 No alc v
others
Planned Comparisons (2)The first comparison (B1 v B2) has a value of –6. For any comparison,
6666.2/962)()ˆ(.
2
j j
jerror n
cMSVarest
348.76666.
6)ˆvar(.
ˆ
estt
j j
jgg
g
gg n
cw
wSS
22
;ˆ
)ˆ(
3333.2
9/62
)3/1()3/1()3/1()3/1()3/1()3/1( 222222
gw
1083333.
6ˆ)ˆ(
22
g
gg w
SS
Note this is the same as SS for B in the ANOVA.
Note 7.348 squared is 54, which is our value of F from the ANOVA.(critical t has dfe)
Planned Comparisons (3)We can substitute planned comparisons for tests of main effects; they are equivalent (if you choose the relevant means). We can also do the same for interactions. In general, there are a total of (Cells-1) independent comparisons we can make (6-1 or 5 in our example). Our second test compared no alcohol to all other conditions.
12ˆ
375.216/12
2)4/1()4/1()2/1()4/1()4/1()2/1( 222222
gw
75.)375(.2)()ˆ(. gerror wMSVarest
86.1375.12
)ˆvar(.ˆ
est
tThis looks to be the largest comparison with these data.
Post Hoc TestsFor post hoc tests about levels of a factor, we pool cells. The only real difference for Tukey HSD and Newman –Keuls is accounting for this difference. For interactions, we are back to comparing cells. Don’t test unless F for the effect is significant.
nKerrorMSqHSD JKNJaA ,,
nJerrorMSqHSD JKNKaB ,,
For comparing cells in the presence of an interaction:
nerrorMSqHSD JKNJKaAB ,,
Post Hoc (2)In our example A has 3 levels, B has 2. Both were significant. No post hoc for B (2 levels). For A, the column means were 2, 10, and 18. Are they different?
07.32/134.4)2(2
26,3,05. qHSDA
nKerrorMSqHSD JKNJaA ,,
A: Yes, all are different because the differences are larger than 3.07. But because of the interaction, the interpretation of differences in A or B are tricky.
Post Hoc (3)
For the rested folks, is the difference between no alcohol and 2 beers significant for driving errors? The means are 1 and 3.
nerrorMSqHSD JKNJKaAB ,,
63.5163.522
6,6,05. qHSDAB
A: They are not significantly different because 2 is less than 5.63. Note: data are fictitious. Do not drink and drive.
Review• Describe each term in a linear model like this
one:
How does post hoc testing for factorial ANOVA differ from post hoc testing in one-way ANOVA?
Describe a concrete example of a two-factor experiment. Why is it interesting and/or important to consider both factors in one experiment?
ijkjkkjijk ey )(
Higher Order Factorials• If you can do ANOVA with 2 factors, you
can do it with as many as you like.• For 3 factors, you have one 3-way interaction
and three 2-way interactions. • Computations are simple but tedious.• For orthogonal, between-subject designs, all
F tests have same denominator.• We generally don’t do designs with more
than 3 factors. Complex & expensive.