Experimental Design & Analysis Factorial ANOVA Copyright, Gerry Quinn & Mick Keough, 1998 Please do not copy or distribute this file without the authors’ permission Two factor factorial ANOVA • Two factors (2 independent 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 Quinn (1988) - fecundity of limpets • Factor A is season with 2 levels: – spring, summer • Factor B is density with 4 levels: – 8, 15, 30, 45 per 225cm2 • n = 3 fences in each combination: – each combination is termed a cell (8 cells) • Dependent variable: – fecundity (no. egg masses per limpet) 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 • Dependent variable: – growth of Douglas fir trees seedlings Data layout Factor A 1 j 1 ........ i 2 j 2 Factor B 1 Reps y111 y112 yij1 yij2 y11k yijk Cell means y11 2 2 1 j yij Linear model • yijk = m + ai + bj + (ab)ij + eijk where • m is overall mean • ai is effect of factor A • bi is effect of factor B • (ab)ii is effect of interaction between A and B • eijk is unexplained variation Worked example Season Spring Density 8 15 30 45 Reps Summer 8 15 30 45 n = 3 in each of 8 groups (cells) p = 2 seasons, q = 4 densities Worked example Cell means: 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 Density marginal 2.13 1.68 means 1.19 0.89 1.47 Grand mean 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): – m1, m2...mi • Factor B marginal means (pooling A): – m1, m2...mj • HO: no difference between marginal means of factor A, pooling levels of B – HO: m1 = m2 = mi = m • HO: no main effect of factor A, pooling levels of B (a1 = a2 = … = ai = 0) • Example: – No difference between season marginal means – No effect of season, pooling densities Cell means Density Spring 8 15 30 45 Season means 2.42 2.18 1.57 1.20 1.84 m spring Summer 1.83 1.18 0.81 0.59 1.10 m summer Density means 2.13 1.68 1.19 0.89 1.47 m overall m8 m 15 m 30 m 45 • HO: no difference between marginal means of factor B, pooling levels of A – HO: m1 = m2 = mj = m • HO: no main effect of factor B, pooling levels of A (b1 = b2 = … = bi = 0) • Example: – No difference between density marginal means – No effect of density, pooling seasons Cell means Density 8 15 30 45 Season means 2.42 2.18 1.57 1.20 1.84 m spring Summer 1.83 1.18 0.81 0.59 1.10 m summer Density means 2.13 1.68 1.19 0.89 1.47 m overall Spring m 8 = m 15 = m 30 = m 45 Interaction • An interaction between 2 factors: – effect of factor A is dependent on level of factor B and vice-versa • HO: no interaction between factor A and factor B: – effects of factor A and factor B are independent of each other – no joint effects of A & B acting together (abij = 0) – mij - mi - mj + m = 0 Interaction example from Underwood (1981) Season: Summer Autumn Winter Spring Area: 1 2 1 2 1 2 1 2 • n = 3 plankton tows for each season/area combination • DV is no. plankton in each tow • cell means (each season/area combination) • main effect means: •season means pooling areas •area means pooling seasons MEAN NUMBER PER HAUL Interaction plot Main effects Cell means Season means Area means 800 600 400 200 A1 800 600 400 200 A2 A2 A1 800 600 400 200 A2 A1 S A W S SEASON S A W S SEASON 1 2 AREA Residual variation • Variation between replicates within each cell • Pooled across cells if homogeneity of variance assumption holds ( yijk y ) 2 Partitioning total variation SSTotal SSA SSA SSB SSAB SSResidual + SSB + SSAB + SSResidual variation between A marginal means variation between B marginal means variation due to interaction between A and B variation between replicates within each cell Factorial ANOVA table Source SS df MS Factor A SSA p-1 Factor B SSB q-1 Interaction AXB SSAB (p-1)(q-1) SS A p-1 SS B q-1 SS AB (p-1)(q-1) Residual SSResidual pq(n-1) SS Residual pq(n-1) Worked example Source SS Season 3.25 1 3.25 Density 5.28 3 1.76 Interaction 0.17 3 0.06 Residual 2.92 16 0.18 11.62 23 Total df MS Expected mean squares Both factors fixed: • MSA s2 + nqai2/p-1 • MSB s2 + npbi2/q-1 • MSA X B s2 + n(ab)ij2/(p-1)(q-1) • MSResidual s2 HO: no interaction • If no interaction: – HO: interaction (abij) = 0 true • F-ratio: – MSAB / MSResidual 1 • Compare F-ratio with F-distribution with (a-1)(b-1) and ab(n-1) df • Determine P-value HO: no main effects • If no main effect of factor A: – HO: m1 = m2 = mi = m (ai = 0) is true • F-ratio: – MSA / MSResidual 1 • If no main effect of factor B: – HO: m1 = m2 = mj = m (bj = 0) is true • F-ratio: – MSB / MSResidual 1 Worked example Source df MS F P Season 1 3.25 17.84 0.001 Density 3 1.76 9.67 0.001 Interaction 3 0.06 0.30 0.824 Residual 16 0.18 Total 23 Testing of HO’s • Test HO 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 Interpreting interactions • Plotting cell means • Multiple comparison across interaction term • Simple main effects • Treatment-contrast tests • Contrast-contrast tests No. egg masses per limpet Interaction plot 3 2 Spring Summer 1 0 0 20 40 60 Density • Effect of density same for both seasons • Difference between seasons same for all densities • Parallel lines in cell means (interaction) plot Worked example II • Low shore Siphonaria – larger limpets • Two factors – Season (spring and summer) – Density (6, 12, 24 limpets per 225cm2) • DV = no. egg masses per limpet • n = 3 enclosures per season/density combination Worked example II Source df MS F P 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 No. egg masses per limpet Interaction plot 4 3 Spring Summer 2 1 0 0 20 10 30 Density • Effect of density different for each season • Difference between seasons varies for each density • Non-parallel lines in cell means (interaction) plot Multiple comparison • 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 an effect of density for winter? – Is there an effect of density for summer? Alternatively – Is there an effect of season for density = 6? – etc. • Equivalent to series of one factor ANOVAs • Use dfResidual and MSResidual from original 2 factor ANOVA Treatment-contrast interaction • Do contrasts or trends in one factor interact with levels of other factor? • Does the density contrast [6 vs the average of 12 & 24] interact with season? Worked example II Source df MS F P Density 2 2.00 13.98 0.001 2 2 0.17 2.67 1.21 18.69 Simple main effects Density in winter Density in summer Season 1 Density x Season 2 0.85 5.91 1 1.53 10.66 12 0.14 Treatment-contrast inter. 6 vs (avg 12 & 24) x season Residual 0.331 <0.001 17.15 119.85 <0.001 0.016 0.007 Mixed model Factor A fixed, B random: • MSA s2 + nsab2 + nqai2/p-1 • MSB s2 + npsb2 • MSA X B s2 + nsab2 • MSResidual s2 Tests in mixed model • HO: no effect of random interaction A*B: – F-ratio: MSAB / MSResidual • HO: no effect of random factor B: – F-ratio: MSB / MSResidual • HO: no effect of fixed factor A: – F-ratio: MSA / MSAB Assumptions of factorial ANOVA Assumptions apply to DV within each cell • Normality – boxplots etc. • Homogeneity of residual variance – residual plots, variance vs mean plots etc. • Independence Factorial ANOVAs in the literature Copyright, Gerry Quinn & Mick Keough, 1998 Please do not copy or distribute this file without the authors’ permission Barbeau et al. (1994) • J. Exp. Mar. Biol. Ecol. 180:103-136 • Experiment on consumption rate of crabs feeding on scallops • Two factors: – Crab size (3 levels - small, medium, large) – Scallop size (3 levels - small, medium, large) • Dependent variable: – consumption rate (number of scallops per predator per day) of crabs (Cancer irroratus) • Sample size: – n = 2 - 4 replicate aquaria in each of 9 cells Source Crab size Scallop size Interaction Residual df MS F 2 2 4 18 123.0 220.3 68.0 42.6 2.89 5.18 1.60 P 0.082 0.017 0.218 Unplanned multiple comparison on main effect of scallop size (pooling crab sizes): S = M < L McIntosh et al. (1994) • Ecology 75 : 2078-2090 • Effects of predatory fish on drifting behaviour of insects (mayflies) in streams • Factors: – Predator cues (3 levels - no fish, galaxids, trout) – Time (2 levels - day, night) • Dependent variable: – number of mayflies drifitng • Sample size: – n=3 stream channels in each cell Source df Predator cues 2 Time 1 Interaction 2 Residual 18 F P 1.45 131.88 1.05 0.261 <0.001 0.369 Mayflies 20 15 Day Night 10 5 0 no fish galaxids trout Assumptions not met? • Robust if equal n • Transformations important • No suitable non-parametric (rankbased) test