introduction to factorial anova 2015
TRANSCRIPT
1
Introduction to Factorial ANOVA
Read from the bottom up!!!!
Two factor factorial ANOVA
• Two factors (2 predictor variables)– Factor A (with p groups or levels)
– Factor B (with q groups or levels)
• Crossed design:– every level of one factor crossed with every
level of second factor
– all combinations (i.e. cells) of factor A and factor B
2
Quinn (1988) - fecundity of limpets
• Factor A - season with 2 levels:– spring, summer
• Factor B - density with 4 levels:– 8, 15, 30, 45 per 225cm2
• n = 3 fences in each combination:– each combination is termed a cell (8 cells)
• Response variable:– fecundity (no. egg masses per limpet)
Fecundity of limpets
3
Stehman & Meredith (1995) -growth of fir tree seedlings
• Factor A is nitrogen with 2 levels– present, absent
• Factor B is phosphorous with 4 levels– 0, 100, 300, 500 kg.ha-1
• 8 cells, n replicate seedlings in each cell
• Response variable:– growth of Douglas fir trees
seedlings
Data layout
Factor A 1 2 ........ i
Factor B 1 2 j 1 2 j 1 2 j
Reps y111 yij1
y112 yij2
y11k yijk
Cell means y11 yij
Note levels in factor B are the same for all levels in Factor A (not nested)
4
Linear model
yijk = + i + j + ()ij + ijk
where overall meani effect of factor Aj effect of factor B
()ij effect of interaction between A & B
ijk unexplained variation (error term)
Worked example - Limpets
Season Spring Summer
Density 8 15 30 45 8 15 30 45
Reps n = 3 in each of 8 groups (cells)
p = 2 seasons, q = 4 densities
5
Worked example
Density 8 15 30 45 Season Marginal means
Spring 2.42 2.18 1.57 1.20 1.84
Summer 1.83 1.18 0.81 0.59 1.10
Densitymarginal 2.13 1.68 1.19 0.89 1.47means Grand mean
Cell means
Null hypotheses• Main effect:
– effect of one factor, pooling over levels of other factor
– effect of one factor, independent of other factor
• Factor A marginal means (pooling B):– 1, 2...i
• Factor B marginal means (pooling A):– 1, 2...j
6
Main effect A• H0: no difference between marginal means of
factor A, pooling levels of B– H0: 1 = 2 = i =
• H0: no main effect of factor A, pooling levels of B (1 = 2 = … = i = 0)
• Example:– No difference between season marginal means
– No effect of season, pooling densities
Density 8 15 30 45 Seasonmeans
Spring 2.42 2.18 1.57 1.20 1.84 spring
Summer 1.83 1.18 0.81 0.59 1.10 summer
Densitymeans 2.13 1.68 1.19 0.89 1.47 overall
8 15 30 45
Cell means
7
Main effect B
• H0: no difference between marginal means of factor B, pooling levels of A– H0: 1 = 2 = j =
• H0: no main effect of factor B, pooling levels of A (1 = 2 = … = j = 0)
• Example:– No difference between density marginal means
– No effect of density, pooling seasons
Density 8 15 30 45 Seasonmeans
Spring 2.42 2.18 1.57 1.20 1.84 spring
Summer 1.83 1.18 0.81 0.59 1.10 summer
Densitymeans 2.13 1.68 1.19 0.89 1.47 overall
8 = 15 = 30 = 45
Cell means
8
Interaction
• An interaction between 2 factors:– effect of factor A dependent on level of factor B and vice-
versa
• H0: no interaction between factor A & factor B:– effects of factor A & factor B are independent of each
other
– no joint effects of A & B acting together (ij = 0)
– ij - i - j + = 0, which is equal to
ij – (i + j) + = 0
Factors A and B are additive
ij – (i + j) + = 0
µ+α+β+ αβ –( µ+α+µ+β)+ µ = 0
µ+α+β+ αβ – µ-α-µ-β+ µ = 0
µ+α+β+ αβ – µ-α-µ-β+ µ = 0
αβ = 0
9
No interaction
• Root:shoot ratio of invasive grass:– C. maculosa
• Two factors:– AM fungus
(present/absent)
– Type of phosphorous (organic/inorganic)
• Factorial design– replicate pots
0
0.1
0.2
0.3
0.4
0.5
+ AM fungi - AM fungiR
oot:
shoo
t ra
tio
Inorganic POrganic P
Interaction
• Root:shoot ratio of native grass:– F. idahoensis
• Two factors:– AM fungus
(present/absent)
– Invasive competitor C. maculosa
• Factorial design– replicate pots
0
1
2
3
F. idahoensis C. maculosa
Competitor
Roo
t:sh
oot
rati
o
+ AM- AM
10
If interaction absent
• Factors A & B affect Y independently of each other
• Examine/test main effects and marginal means
Interaction examination
0
0.1
0.2
0.3
0.4
0.5
+ AM fungi - AM fungi
Roo
t:sh
oot
rati
o
Inorganic POrganic P
Organic Inorganic Row means
+AM Fungi
0.36 0.29 0.325
-AM Fungi
0.33 0.23 0.28
Column means
0.345 0.26 Overall mean =
0.3025
ij – (i + j) + = 0
0.36-(0.325+0.345)+0.3025 = -0.0075
11
If interaction present
• Factors A & B interact in their effect on Y
• Factors A & B do NOT affect Yindependently of each other
• Difficult to examine/test main effect and marginal means
• Must examine results to determine if main effects are interpretable
Interaction examination
F. idahoensis C. maculosa Row means
+AM Fungi
1.2 2.3 1.75
-AM Fungi
1.6 1.4 1.5
Column means
1.4 1.85 Overall mean =
1.625
ij – (i + j) + = 0
1.4-(1.85+1.5)+1.625 = -0.325
0
1
2
3
F. idahoensis C. maculosa
Competitor
Roo
t:sh
oot
rati
o
+ AM- AM
12
Residual variation
• Variation between replicates within each cell
• Pooled across cells if homogeneity of variance assumption holds
2)( ijijk yy
Partitioning total variation
SSTotal
SSA + SSB + SSAB + SSResidual
SSA variation between A marginal meansSSB variation between B marginal meansSSAB variation due to interaction between A
and BSSResidual variation between replicates within
each cell
13
Source SS df MS
Factor A SSA p-1 SS Ap-1
Factor B SSB q-1 SS Bq-1
Interaction SSAB (p-1)(q-1) SS ABA X B (p-1)(q-1)
Residual SSResidual pq(n-1) SS Residualpq(n-1)
Factorial ANOVA table
Expected mean squares
Both factors fixed:
MSA
MSB
MSA X B
MSResidual2
22
22
22
)1)(1(
)(
1
1
qp
n
q
np
p
nq
ij
i
i
14
H0: no interaction
• If no interaction:– H0: interaction (ij)
= 0 true
• F-ratio:– MSAB / MSResidual 1
2
22
22
22
)1)(1(
)(
1
1
qp
n
q
np
p
nq
ij
i
i
H0: no main effect
• If no main effect of factor A:– H0: 1 = 2 = i = (i = 0) is
true
• F-ratio:– MSA / MSResidual 1
• If no main effect of factor B:– H0: 1 = 2 = j = (j = 0) is
true
• F-ratio:– MSB / MSResidual 1 2
22
22
22
)1)(1(
)(
1
1
qp
n
q
np
p
nq
ij
i
i
15
Worked example
Density 8 15 30 45 Season Marginal means
Spring 2.42 2.18 1.57 1.20 1.84
Summer 1.83 1.18 0.81 0.59 1.10
Densitymarginal 2.13 1.68 1.19 0.89 1.47means Grand mean
Cell means
Testing of H0’s
• Test H0 of no interaction first:– no significant interaction between density
and season (P = 0.824)• If not significant, test main effects:
– significant effects of season (P < 0.001) and density (P < 0.001)
• Planned and unplanned comparisons:– applied to interaction and to main effects– try to limit unplanned comparisons
16
Interpreting interactions
1. Hopefully you will have a hypothesis or set of hypotheses for the interaction term
2. Plot cell means (This is usually the most informative thing to do)
3. Test hypotheses concerning the interaction (using Specify command)
4. If appropriate examine hypotheses concerned with main effects (using contrast or specify)
Interaction plot
0
1
2
3
0 20 40 60
Density
No
. eg
g m
asse
s p
er li
mp
et
SpringSummer
• Effect of density same for both seasons• Difference between seasons same for all densities• Parallel lines in cell means (interaction) plot
17
Worked example II
• Low shore Siphonaria– larger limpets
• Two factors– Season (spring and summer)
– Density (6, 12, 24 limpets per 225cm2)
• Response variable:– no. egg masses per limpet
• n = 3 enclosures per season/density combination
Worked example II
Season 1 17.15 119.85 < 0.001
Density 2 2.00 13.98 0.001
Interaction 2 0.85 5.91 0.016
Residual 12 0.14
Total 17
Source df MS F P
18
Interaction plot
0
1
2
3
4
0 10 20 30
Density
No
. eg
g m
asse
s p
er li
mp
etSpring
Summer
• Effect of density different for each season• Difference between seasons varies for each density• Non-parallel lines in cell means (interaction) plot• Is the effect of Season interpretable??
Complex interaction
• Behavioural response of larval newts in lab
• Factor A– Chemical cues from
adult newts
• Factor B– Earthworm prey
• Factorial design– replicate aquaria
0
10
20
30
40
50
Newtpresent
Newtabsent
% la
rval
new
ts in
op
en
+ worms- worms
19
Multiple comparisons
• Use Tukey’s test, Bonferroni t-tests etc.:– compare all cell means in interaction
• Usually lots of means:– lots of non-independent comparisons
• Often ambiguous results
• Not very informative, not very powerful
Simple main effects
• Tests across levels of one factor for each level of second factor separately.– Is there effect of density for spring?– Is there effect of density for summer?Alternatively– Is there effect of season for density = 6?– etc.
• Equivalent to series of one factor ANOVAs• Use dfResidual and MSResidual from original
factorial ANOVA
20
Season 1 17.15 119.85 < 0.001
Density 2 2.00 13.98 0.001
Interaction 2 0.85 5.91 0.016
Residual 12 0.14
Total 17
Source df MS F P
Worked example II: Low shore Siphonaria
Worked example II: Low shore Siphonaria
Density 2 2.00 13.98 0.001
Season 1 17.15 119.85 <0.001
Density x Season 2 0.85 5.91 0.016Simple main effectsDensity in spring 2 0.17 1.21 0.331Density in summer 2 2.67 18.69 <0.001
Residual 12 0.14
Source df MS F P
21
0
1
2
3
4
0 10 20 30
Density
No
. eg
g m
ass
es p
er li
mp
etSpring
Summer
Worked example II: Low shore Siphonaria
Simple main effects df MS F PDensity in spring 2 0.17 1.21 0.331Density in summer 2 2.67 18.69 <0.001
Mixed ModelsTraditional ANOVA approach
• At least one of the Factors is Random
• At least one of the Factors is Fixed
• Not too difficult if only one Factor is Random
• Very complex if more than one Factor is Random (realm or psuedo – F stats)
22
Palm seedlings in Peru (Losos 1995)
Mixed model
• Survivorship of palm seedlings in Peru
• Factor A - fixed– 4 successional zones
– early-seral, mid-seral, late-seral, Heliconia
• Factor B - random– 2 randomly located transects
• 5 replicate plots of seedlings within each zone-transect combination (cell)
23
Mixed model
• Age at metamorphosis of copepod larvae
• Factor A - fixed– 4 food treatments
– high food, high to low, etc.
• Factor B - random– 15 randomly chosen sibships
• 4 replicate dishes of larvae within each food-sibship combinations (cell)
Expected mean squares
Factor A fixed, B random:
• MSA
• MSB
• MSA X B
• MSResidual2
22
22
222
1
n
np
p
nqn i
24
Tests in mixed model
• H0: no effect of random interaction A*B:– F-ratio: MSAB / MSResidual
• H0: no effect of random factor B:– F-ratio: MSB / MSResidual
• H0: no effect of fixed factor A:– F-ratio: MSA / MSAB
2
22
22
222
1
n
np
p
nqn i
Palm seedlings
Source df MS F P Denom.
Zone 3 0.060 0.31 0.819 Z x T
Transect 1 0.045 3.10 0.041 Residual
Zone x transect 3 0.191 13.33 <0.001 Residual
Residual 30 0.014
25
Assumptions of factorial ANOVA
Assumptions apply to yijk within each cell
• Normality– boxplots etc.
• Homogeneity of residual variance– residual plots, variance vs mean plots etc.
• Independence
Assumptions not met?
• Robust if equal n
• Transformations important
• No suitable non-parametric (rank-based) test
26
More complex ANOVAs
• Three or more factors
• Three factor ANOVA:– 3 main effects
– 3 two-way interactions
– 1 three-way interaction
• Test three-way interaction first, then two ways, then main effects
Canola (Brassica) germination
• Factor A - seed type– 3 levels (different genetic lines & controls)
• Factor B - light– 3 levels (full, dark, shade)
• Factor C - nutrients– 2 levels (low, high)
• Residual:– 5 petri dishes (with seeds) in each of 18 cells
• Response variable:– average time to germinate
27
3 factor exampleSource df F P
Seed type (S) 2 17.23 <0.001Light (L) 2 3.04 0.063Nutrient (N) 1 0.16 0.690S x L 4 5.95 0.001S x N 2 0.05 0.954N x L 2 0.21 0.815S x N x L 4 0.43 0.787Residual 30
Complex mixed models
Source df F-test denominator
Season 1 Season x TransZone 3 Zone x TransTransect (random) 1 ResidualSeason X Zone 3 Season x Zone x TransSeason X Trans 1 ResidualZone x Trans 3 ResidualSeason X Zone x Trans 3 Residual
Residual 55
28
General scheme for testing ANOVA models with fixed factors
Source df dfdenomonator F
A dfA = p-1 dfResidual MSA/MSResidual
B dfB = q-1 dfResidual MSB/MSResidual
AB dfAB = (p-1)(q-1) dfResidual MSAB/MSResidual
Residual pq(n-1)
Source df dfdenomonator F
A dfA = p-1 dfResidual MSA/MSResidual
B dfB = q-1 dfResidual MSB/MSResidual
C dfC = r-1 dfResidual MSC/MSResidual
AB dfAB = (p-1)(q-1) dfResidual MSAB/MSResidual
AC dfAC = (p-1)(r-1) dfResidual MSAC/MSResidual
BC dfBC = (q-1)(r-1) dfResidual MSBC/MSResidual
ABC dfABC = (p-1)(q-1)(r-1) dfResidual MSABC/MSResidual
Residual pqr(n-1)
A, B
A, B, C
And so on
General scheme for testing Mixed ANOVA models (fixed and random factors)
Source df dfdenomonator F
A dfA = p-1 dfAB MSA/MSAB
B dfB = q-1 dfResidual MSB/MSResidual
AB dfAB = (p-1)(q-1) dfResidual MSAB/MSResidual
Residual pq(n-1)
Source df dfdenomonator F
A dfA = p-1 dfAC MSA/MSAC
B dfB = q-1 dfBC MSB/MSBC
C dfC = r-1 dfResidual MSC/MSResidual
AB dfAB = (p-1)(q-1) dfABC MSAB/MSABC
AC dfAC = (p-1)(r-1) dfResidual MSAC/MSResidual
BC dfBC = (q-1)(r-1) dfResidual MSBC/MSResidual
ABC dfABC = (p-1)(q-1)(r-1) dfResidual MSABC/MSResidual
Residual pqr(n-1)
A = fixedB = random
A = fixedB = fixedC = random
And so on
29
Effect of Blocking on Power of Test
Relationship between supplemental watering and oak seedling germination
Ho: No difference in seedling number in watered and control plots
How to set this up!!!
Options
• Fully randomized• Randomized Block - with no replication
– Account for underlying but unknown spatial variation
• Randomized block - with replication– Account for underlying but unknown spatial variation– Tradeoff between number of Blocks and replicates
within Block
• Constraints - we can only logistically handle 24 replicate plots
30
Completely RandomWatered
Control
Randomized Block - no replicationWatered
Control
31
Randomized Block - MaximizeBlocks minimize replication within Blocks
Watered
Control
Randomized Block - MinimizeBlocks Maximize replication within Blocks
Watered
Control
32
Mea
n an
d S
EM
Control WaterTTT
9.0
11.6
14.2
16.8
19.4
22.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
9.0
11.6
14.2
16.8
19.4
22.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Completely randomized design24 replicated plots (12 per TTT)
Randomized Block design2 Blocks 6 reps of each TTT per Block
Randomized Block design6 Blocks 2 reps of each TTT per Block
Randomized Block design12 Blocks (no TTT reps in each Block)
Control WaterTTT
9.0
11.6
14.2
16.8
19.4
22.0
SE
ED
ING
S
Control WaterTTT
9.0
11.6
14.2
16.8
19.4
22.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
9.0
11.6
14.2
16.8
19.4
22.0
SE
ED
ING
S
Control WaterTTT
9.0
11.6
14.2
16.8
19.4
22.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Control WaterTTT
10.0
12.2
14.4
16.6
18.8
21.0
SE
ED
ING
S
Completely randomized design24 replicated plots (12 per TTT)
Randomized Block design2 Blocks 6 reps of each TTT per Block
Randomized Block design6 Blocks 2 reps of each TTT per Block
Randomized Block design12 Blocks (no TTT reps in each Block)
Compare Models
Design Source df1 df2 MS F P Test Notes
CR TTT$ 1 22 121.5 4.2 0.052 MSTTT/MSResidual No BlocksCR Residual 22 28.7
RB - no rep TTT$ 1 11 121.5 92.2 0.000001 MSTTT/MSResidual 12 BlocksRB - no rep Block 11 56.2 No testRB - no rep Residual 11 1.3
RB - 2 reps TTT$ 1 5 121.5 43.4 0.001 MSTTT/MSTTT*Block 6 BlocksRB - 2 reps Block 5 11 120.9 103.6 0.0000001 MSBlock/MSResidual
RB - 2 reps TTT$*Blk 5 11 2.8 2.4 0.10 MSTTT*Block/MSResidual
RB - 2 reps Residual 11 1.2
RB - 6 reps TTT$ 1 1 121.56 11.4 0.18 MSTTT/MSTTT*Block 2 BlocksRB - 6 reps Block 1 20 450.7 52.7 0.000001 MSBlock/MSResidual
RB - 6 reps TTT$*Blk 1 20 10.7 1.2 0.28 MSTTT*Block/MSResidual
RB - 6 reps Residual 20 8.6
33
0.0000010.0000020.0000030.0000050.000007
0.000010.000020.000030.000040.00006
0.00010.00020.00030.00040.0006
0.0010.0020.0030.0050.007
0.010.020.030.050.07
0.1
1 5 11 22
DF Denominator
Tradeoff between blocking and degrees of freedom
CR
RB, 2, 6
RB, 6, 2
RB, 12, 1
P =0.05Randomized block, 2 blocks 6 reps of each treatment per block
Randomized block, 6 blocks 2 reps of each treatment per block
Randomized block, 12 blocks 1 reps of each treatment per block
Completely randomized design
RB, 2, 6
RB, 6, 2
RB, 12, 1
CR