Analysis of variance (2) Lecture 10
Normality Check Frequency histogram (Skewness & Kurtosis) Probability plot, K-S test Normality Check Frequency histogram (Skewness & Kurtosis) Probability plot, K-S test Descriptive statistics Measurements (data) Measurements (data) Mean, SD, SEM, 95% confidence interval YES Check the Homogeneity of Variance Data transformation NO Data transformation NO Median, range, Q1 and Q3 Non-Parametric Test(s) For 2 samples: Mann- Whitney For 2-paired samples: Wilcoxon For >2 samples: Kruskal-Wallis Sheirer-Ray-Hare Non-Parametric Test(s) For 2 samples: Mann- Whitney For 2-paired samples: Wilcoxon For >2 samples: Kruskal-Wallis Sheirer-Ray-Hare Parametric Tests Student’s t tests for 2 samples; ANOVA for 2 samples; post hoc tests for multiple comparison of means Parametric Tests Student’s t tests for 2 samples; ANOVA for 2 samples; post hoc tests for multiple comparison of means YES One-way ANOVA Tukey’s test Two-way ANOVA F max test K-W test, Dunn’s test
Kruskal-Wallis test with tied ranks Example (Zar, 1999) – comparison of pH among 4 ponds N = = 31 H = {12/[N(N + 1)]} (R i 2 /n i ) - 3(N + 1) H = {12/[31(31 + 1)]} (8917.8) - 3(31 + 1) = Number of groups of tied ranks = m = 7 T = (t i 3 - t i ) = ( ) + ( ) + ( ) + ( ) + ( ) + ( ) + ( ) = 168 C = 1 - T / (N 3 - N) = 1 - (168/ ( )) = H c = H/C = / = = k - 1 = 4 -1 = 3 , 3 = < , 0.005< p <0.01, hence reject Ho (Table B1)
Dunn’s test is a non-parametric test and is used to compare any significant different means or medians. Using Example 10.11: T = 168 For n A = 8 and n B = 8, SE = {[(N(N + 1)/12) – T /(12(N – 1)][(1/n A ) + (1/n B )]} SE = {[(31(32)/12) – 168 /(12(31 – 1)][(1/8) + (1/8)]} = 4.53 For n A = 7 and n B = 8, SE = {[(31(32)/12) – 168 /(12(31 – 1)][(1/7) + (1/8)]} = 4.69 Sample ranked by mean rank: Rank sum: Sample sizes:8887 Mean ranks: Nonparametric multiple comparisons: Dunn’s test (e.g , Zar 1999) In conclusion, water pH is the same in ponds 4 & 3 but is different in pond 1, and the relationship of pond 2 to the others is unclear. (see Table B15 for critical Q values) Similar to Tukey’s test
Normality Check Frequency histogram (Skewness & Kurtosis) Probability plot, K-S test Normality Check Frequency histogram (Skewness & Kurtosis) Probability plot, K-S test Descriptive statistics Measurements (data) Measurements (data) Mean, SD, SEM, 95% confidence interval YES Check the Homogeneity of Variance Data transformation NO Data transformation NO Median, range, Q1 and Q3 Non-Parametric Test(s) For 2 samples: Mann- Whitney For 2-paired samples: Wilcoxon For >2 samples: Kruskal-Wallis Sheirer-Ray-Hare Non-Parametric Test(s) For 2 samples: Mann- Whitney For 2-paired samples: Wilcoxon For >2 samples: Kruskal-Wallis Sheirer-Ray-Hare Parametric Tests Student’s t tests for 2 samples; ANOVA for 2 samples; post hoc tests for multiple comparison of means Parametric Tests Student’s t tests for 2 samples; ANOVA for 2 samples; post hoc tests for multiple comparison of means YES One-way ANOVA Tukey’s test Two-way ANOVA F max test K-W test, Dunn’s test Friedman Next lecture Other ANOVAs
Two-factor ANOVA 2-way ANOVA Can simultaneously assess the effects of two factors on a variable. Can also test for interaction among factors, provided that data in each cell of a contingency table consist observations n > 1. Assumption: normal data with equal variances but ANOVA is robust (see p , Zar 1999)
2-way ANOVA with equal replication Example 12.1: The effects of sex and hormone treatment on plasma calcium concentrations (in mg/100 ml) of birds. Questions: Is there a significant difference between the mean calcium concentration of males and females? Is there a significant difference between the mean calcium concentration in each treatment (control vs. hormone treatment)?
Mean & 95% C.I.
Mean and 95% C.I. Two factors -Sex -Hormone F-Test Two-Sample for Variances Variable 1Variable 2 Mean Variance Observations55 df44 F P(F<=f) one-tail F Critical one-tail Passed the Fmax test, indicating equal variances among the four means
SS total = SS within cells + SS between A + SS between B + SS interaction SS within cells = SS total – SS cells SS interaction = SS cells – SS between A – SS between B DF total = N – 1 DF cells (explained) = (n A )(n B ) – 1 DF within cells (residual or error) = (n A )(n B )(n’ – 1) where n’= no. of replicates within each cell DF between A = n A – 1 DF between B = n B – 1 DF A B interaction = (DF between A )(DF between B )
SS total = – (436.5) 2 /20 = DF total = 20 – 1 = 19 SS cells = [(74.4) 2 + (60.6) 2 + (162.6) 2 + (138.9) 2 ]/5 - (436.5) 2 /20 = DF cells = (2)(2) - 1 = 3 SS within cells = SS total - SS cells = – = DF within cells = (2)(2)(5 – 1) = 16
SS total = – (436.5) 2 /20 = DF total = 20 – 1 = 19 SS cells = [(74.4) 2 + (60.6) 2 + (162.6) 2 + (138.9) 2 ]/5 - (436.5) 2 /20 = DF cells = (2)(2) - 1 = 3 SS within cells = – = DF within cells = (2)(2)(5 – 1) = 16 SS between treatments = {[(135.0) 2 + (301.5) 2 ] /(2)(5)} - (436.5) 2 /20 = DF between treatment = = 1 SS between sexes = {[(237.0) 2 + (199.5) 2 ] /(2)(5)} - (436.5) 2 /20 = DF between sexes = = 1 SS interaction = SS cells – SS between A – SS between B = – – = DF interaction = (1)(1) = 1 Equations: See p. 242 (Zar, 1999)
Analysis of Variance Summary Table There was a significant effect of hormone treatment on plasma calcium concentrations in the birds (P <0.001). There was no interaction between sex and hormone treatment while the sex effect was not significant (likely due to inadequate power) Tukey test same as 1-way ANOVA
ANOVA Source of VariationSSdfMSFP-valueF crit Sample < Columns Interaction Within Total Output from Excel
[Ca] female male [Ca] control hormone treated control hormone treated [Ca] control hormone treated [Ca] control hormone treated Sex Horm. Sex X Horm. Sex X Horm. X Sex Horm. X
[Ca] female male [Ca] control hormone treated control hormone treated [Ca] control hormone treated [Ca] control hormone treated Sex Horm. Sex Horm. Intera. Sex Horm. Intera. Sex Horm. Intera.
Interactive effects between variables: (a) no interaction; (b) interaction. (a) (b)
An example: The effects of light and sex on food intake in starlings. Total food intake (g) for 7 days
An example: The effects of light and sex on food intake in starlings. Two sexes have different food intake levels (p < 0.001). A significant interaction (p <0.05) indicates that two sexes respond significantly differently to day- length in the amount of food they eat.
Computation of the F statistics for tests of significance in 2- way ANOVA with replicates
Cannot test for the interacting effect !
2-way ANOVA for data without replication Interaction cannot be measured where data in each cell of a contingency table consist of single observations. Variability due to interaction is combined with the within variability and it is assumed to be negligible.
Other two experimental design suitable for 2-way ANOVA The randomized block See Example 12.4 (Zar, 99) Each block contains 4 animals: The randomized block See Example 12.4 (Zar, 99) Each block contains 4 animals: Repeated-measures See Example 12.5 (Zar, 1999) e.g. effects of diet type on food wastage in fish farm Repeated-measures See Example 12.5 (Zar, 1999) e.g. effects of diet type on food wastage in fish farm Other example: different colours of buckets (water traps) to sample insects Equivalent non-parametric method: Friedman’s analysis of variance by ranks (see p , Zar 1999)
Use SPSS to conduct a 2-way ANOVA Column 1Column 2 Column 3 obs obs obs obs. i obs. i obs. i 23 Factor AFactor BDependent variable ……..
Normality Check Frequency histogram (Skewness & Kurtosis) Probability plot, K-S test Normality Check Frequency histogram (Skewness & Kurtosis) Probability plot, K-S test Descriptive statistics Measurements (data) Measurements (data) Mean, SD, SEM, 95% confidence interval YES Check the Homogeneity of Variance Data transformation NO Data transformation NO Median, range, Q1 and Q3 Non-Parametric Test(s) For 2 samples: Mann- Whitney For 2-paired samples: Wilcoxon For >2 samples: Kruskal-Wallis Sheirer-Ray-Hare Non-Parametric Test(s) For 2 samples: Mann- Whitney For 2-paired samples: Wilcoxon For >2 samples: Kruskal-Wallis Sheirer-Ray-Hare Parametric Tests Student’s t tests for 2 samples; ANOVA for 2 samples; post hoc tests for multiple comparison of means Parametric Tests Student’s t tests for 2 samples; ANOVA for 2 samples; post hoc tests for multiple comparison of means YES One-way ANOVA Tukey’s test Two-way ANOVA F max test K-W test, Dunn’s test Friedman Next lecture Other ANOVAs
Key notes After performing a Kruskal-Wallis test, a Dunn’s test can be used to identify any significantly different medians (or means) based on ranking Two-way ANOVA can be used to analyze samples which have been subjected to two levels of treatment In two-way ANOVA, there are several different design: (Model 1) both factors A and B are fixed factors; (Model 2) both factors are random factors; (Model 3) mixed factors. Furthermore, two-way ANOVA can also be applied to data with randomized block or repeated measure designs as well as data without replication. In two-way ANOVA, interaction cannot be tested where data in each cell of a contingency table consist of single observations.