ANOVA with More than 1 IV - University of South Florida

Download Report

Transcript ANOVA with More than 1 IV - University of South Florida

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:
yijk     j  k  ( ) jk  eijk
Questions (2)
 Correctly interpret ANOVA summary
tables. Identify mistakes in such
tables. What’s the matter with this
one?
Source SS
Df
MS
F
A
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 oneway 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)
Caffeine
(Factor B)
No
Yes
Yes
Caff
X =80
SD=5
Control
X =75
SD=5
77.5
Both
X =85
SD=5
Book
X =80
SD=5
82.5
No
Col Means
Row
Means
82.5
77.5
80
Main Effects and Interactions
Mean RM Test Score
86
84
With C affeine
82
80
Fac tor B
78
Without C affeine
76
74
No
Work book (Fac tor A)
• Main effects seen
by row and column
means; Slopes and
breaks.
• Interactions seen by
lack of parallel
lines.
• Interactions are a
Yes main reason to use
multiple IVs
Single Main Effect for B
S ingle Main E ffect
(Coffee only)
M ean Res pons e
25
B=2
20
A
15
B
2
1
1
10
2
20 20
10
10
B=1
5
0
1. 0
2. 0
Fac tor A
Single Main Effect for A
S ingle Main E ffect
M ean Res pons e
20
16
B=2
12
B=1
A
B
1
1 10
2 10
2
20
20
8
(Workbook only)
4
0
1. 0
2. 0
Fac tor A
Two Main Effects; Both A &
B
Both workbook and coffee
Two Main E ffects
M ean Res pons e
35
30
B=2
25
A
20
15
B
1
1 10
2 20
2
20
30
B=1
10
5
0
1 .0
2 .0
Fac tor A
Interaction (1)
Interactions take many forms; all show lack of parallel
lines.
Interaction 1
M ean Res pons e
35
30
25
20
B=2
Coffee has no effect
without the workbook.
A
B
1
2
1
10
10
2
20
30
B=1
15
10
5
0
1 .0
2 .0
Fac tor A
Interaction (2)
Interaction 2
M ean Res pons e
25
20
B=2
A
15
B
10
1
1 10
2 20
2
20
10
B=1
People with workbook do better without
coffee; people without workbook do
better with coffee.
5
0
1 .0
2 .0
Fac tor A
Interaction (3)
Coffee always helps, but it helps more if you use
workbook.
Interaction 3
40
M ean Res pons e
35
30
B= 2
25
20
15
B= 1
10
5
0
1. 0
2. 0
Fac tor A
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.
Review
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?
Population Effects for 2-way
Population main effect associated with the treatment Aj
(first factor):
j  j 
Population main effect associated with treatment Bk
(second factor):
 k  k  
The interaction is defined as ( ) jk , so the linear model is:
yijk     j  k  ( ) jk  eijk Each person’s score
The interaction is a residual:
( ) jk   jk     j  k
( ) jk   jk   j.  .k  
is a deviation from a
cell mean (error).
The cell means vary
for 3 reasons.
Expected Mean Squares
E(MS error) =
E(MS A) =
E(MS B) =

2
e
 
(Factor A has J levels; factor B
has K levels; there are n people
per cell.)
Kn 2j
 e2 
Note how all terms
estimate error.
j
2
e
J 1
Jn  k2
E(MS Interaction) =
k
K 1
 e2 
n ( ) 2jk
j
k
( J  1)(K  1)
F Tests
For 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
MS A
MS error
B
MS B
MS error
AxB
Interaction
MS AB
MS error
J-1,
N-JK
K-1,
N-JK
(J-1)(K-1),
N-JK
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 1
2, 4
M=3
Cell 2
16, 18
M=17
Cell 3
18, 20
M=19
M=13
Rested
(K=2)
Cell 4
0, 2
M=1
Cell 5
2, 4
M=3
Cell 6
16, 18
M=17
M=7
M=2
M=10
M=18
M=10
Factorial Example Results
Factorial Design
25
Dri v i ng Errors
20
Fati gued
15
10
Res ted
5
0
none
2 beers
Alc ohol Cons um pti on
Intox
Main Effects?
Interactions? Both main effects and the interaction
appear significant. Let’s look.
Data
Person
DV
Cell
A alc
B rest
1
2
1
1
1
2
4
1
1
1
3
16
2
2
1
4
18
2
2
1
5
18
3
3
1
6
20
3
3
1
7
0
4
1
2
8
2
4
1
2
9
2
5
2
2
10
4
5
2
2
11
16
6
3
2
12
18
6
3
2
Mean
10
Total Sum of Squares
Person
DV
Mean
1
2
10
-8
64
2
4
10
-6
36
3
16
10
6
36
4
18
10
8
64
5
18
10
8
64
6
20
10
10
100
7
0
10
-10
100
8
2
10
-8
64
9
2
10
-8
64
10
4
10
-6
36
11
16
10
6
36
12
18
10
8
64
Total
D
D*D
728
SS Within Cells
Person
DV
Cell
1
2
1
3
1
2
4
1
3
1
3
16
2
17
1
4
18
2
17
1
5
18
3
19
1
6
20
3
19
1
7
0
4
1
1
8
2
4
1
1
9
2
5
3
1
10
4
5
3
1
11
16
6
17
1
12
18
6
17
1
Total
Mean
D*D
12
SS A – Effects of Alcohol
Person
M
Level Mean
(A)
(A)
1
10
1
2
64
2
10
1
2
64
3
10
2
10
0
4
10
2
10
0
5
10
3
18
64
6
10
3
18
64
7
10
1
2
64
8
10
1
2
64
9
10
2
10
0
10
10
2
10
0
11
10
3
18
64
12
10
3
18
64
Total
D*D
512
SS B – Effects of Fatigue
Person
M
Level Mean
(B)
(B)
1
10
1
13
9
2
10
1
13
9
3
10
1
13
9
4
10
1
13
9
5
10
1
13
9
6
10
1
13
9
7
10
2
7
9
8
10
2
7
9
9
10
2
7
9
10
10
2
7
9
11
10
2
7
9
12
10
2
7
9
Total
D*D
108
SS Cells – Total Between
Person
M
Cell
1
10
1
3
49
2
10
1
3
49
3
10
2
17
49
4
10
2
17
49
5
10
3
19
81
6
10
3
19
81
7
10
4
1
81
8
10
4
1
81
9
10
5
3
49
10
10
5
3
49
11
10
6
17
49
12
10
6
17
49
Total
Mean
(Cell)
D*D
716
Summary Table
Source
SS
Total
728
Between
716
A
512
B
108
Within
12
Source
A
B
AxB
Error
SS
512
108
96
12
Check: Total=Within+Between
728 = 716+12 
Interaction = Between – (A+B).
Interaction = 716-(512+108) = 96.
F( .05, 2,6)  5.14
F( .05,1,6)  5.98
df
2 (J-1)
1(K-1)
2 (J-1)(K-1)
6 (N-JK)
MS
256
108
48
2
F
128
54
24
Factorial Design
25
Dri v i ng Errors
Interactions
20
Fati gued
15
10
Res ted
5
0
none
2 beers
Alc ohol Cons um pti on
Intox
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.
Review
Correctly interpret ANOVA summary
tables. Identify mistakes in such tables.
What’s the matter with this one?
Source SS
Df
MS
F
A
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 Variance
We can compute R-squared for magnitude of effect, but it’s
biased, so the convention is to use omega-squared.
est.
est.
est.
2
y . AxB
2
y. A
2
y.B
SS A  ( J  1) MS error 512 2(2)


 .70
MS error  SS total
2  728
SS B  ( K  1) MS error 108 1(2)


 .15
MS error  SS total
2  728
SS AxB  ( J  1)(K  1) MS error 96  (2)(1)(2)


 .13
MS error  SS total
2  728
Planned Comparisons
Cell
1 A1B1
2 A2B1
3 A3B1
4 A1B2
5 A2B2
6 A3B2
ˆ
Mean
3
17
19
1
3
17
C1
-1/3
-1/3
-1/3
1/3
1/3
1/3
-6
C2
1/2
-1/4
-1/4
1/2
-1/4
-1/4
-12
B1 v B2 No alc v
others
Planned Comparisons (2)
The first comparison (B1 v B2) has a value of –6. For any
comparison,
ˆ g2
c 2jg
SS(ˆ g ) 
wg
; wg  
j
nj
(1 / 3) 2  (1 / 3) 2  (1 / 3) 2  (1 / 3) 2  (1 / 3) 2  (1 / 3) 2 6 / 9
wg 

 .3333
2
2
ˆ g2  62
SS(ˆ g ) 

 108 Note this is the same as SS for
wg .3333
B in the ANOVA.
c
6
est. Var (ˆ )  ( MSerror )  2 / 2  .6666
9
j nj
2
j
t
ˆ
est. var(ˆ )

6
 7.348
.6666
(critical t has dfe)
Note 7.348 squared is
54, which is our value
of F from the
ANOVA.
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
(1 / 2) 2  (1 / 4) 2  (1 / 4) 2  (1 / 2) 2  (1 / 4) 2  (1 / 4) 2 12 / 16
wg 

 .375
2
2
est. Var(ˆ )  (MSerror )wg  2(.375)  .75
ˆ
 12
t

 13.86
est. var(ˆ )
.75
This looks to be the
largest comparison with
these data.
Post Hoc Tests
For 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.
HSDA  qa , J , N  JK
MS error
nK
HSDB  qa , K , N  JK
MS error
nJ
For comparing cells in the presence of an interaction:
HSDAB  qa , JK , N  JK
MS error
n
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?
HSDA  qa , J , N  JK
HSDA  q.05,3,6
MS error
nK
2
 4.34 1 / 2  3.07
2(2)
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.
HSDAB  qa , JK , N  JK
HSDAB  q.05,6,6
MS error
n
2
 5.63 1  5.63
2
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:
yijk     j  k  ( ) jk  eijk
How does post hoc testing for factorial
ANOVA differ from post hoc testing in oneway ANOVA?
Describe a concrete example of a two-factor
experiment. Why is it interesting and/or
important to consider both factors in one
experiment?
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.