stat 215 multifactor anova i
play

STAT 215 Multifactor ANOVA I Colin Reimer Dawson Oberlin College - PowerPoint PPT Presentation

Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms STAT 215 Multifactor ANOVA I Colin Reimer Dawson Oberlin College November 28, 2017 1 / 25 Outline Two-Way ANOVA: Additive Model FIT:


  1. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms STAT 215 Multifactor ANOVA I Colin Reimer Dawson Oberlin College November 28, 2017 1 / 25

  2. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms 2 / 25

  3. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Alfalfa sprouts (Ex. 6.25) Some students were interested in the effect of acidic environments on plant growth. They planted alfalfa seeds in fifteen cups and randomly chose five to get plain water , five to get a moderate amount of acid and five to get a strong er acid solution. The cups were arranged indoors near a window in five rows of three with one cup from each Acid level in each row (with row a nearest the window, and row e farthest away). The response variable was average Height of the alfalfa sprouts after four days. A model: Acid = µ + α k + ε, k = water , moderate , strong Any concerns about the ANOVA/regression conditions? The residuals might not be independent within rows! 4 / 25

  4. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Alfalfa Data Treatment/Row a b c d e Trt. mean water 1.45 2.79 1.93 2.33 4.85 2.67 moderate acid 1.00 0.70 1.37 2.80 1.46 1.47 strong acid 1.03 1.22 0.45 1.65 1.07 1.08 Row mean 1.16 1.57 1.25 2.26 2.46 1.74 Since each treatment is applied to each row, we can include row as a predictor. 5 / 25

  5. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Means Plots library("Stat2Data"); library("mosaic"); library("gplots") data("Alfalfa") plotmeans(Ht4 ~ factor(Acid, levels = c("water", "1.5HCl", "3.0HCl")), data = Alfalfa, xlab = "Solution", ylab = "Height (in.)") 4 Height (in.) 3 ● 2 ● ● 1 n=5 n=5 n=5 water 1.5HCl 3.0HCl Solution 6 / 25

  6. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Means Plots plotmeans(Ht4 ~ factor(Row), data = Alfalfa, xlab = "Row", ylab = "Height (in.)") 8 6 Height (in.) 4 ● ● 2 ● ● ● 0 −2 n=3 n=3 n=3 n=3 n=3 a b c d e Row 7 / 25

  7. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms The One-way ANOVA Population Model ( X categorical) Y = f ( X ) + ε ε ∼ N (0 , σ 2 Y = µ + α k + ε, ε ) One α k for each level of X : group deviation from overall mean The Two-way ANOVA Additive Model ( X A , X B categorical) Y = f ( X ) + ε ε ∼ N (0 , σ 2 Y = µ + α j + β k + ε, ε ) One α j for each level of X A One β k for each level of X B 8 / 25

  8. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms FIT: Parameter Estimation • Population model: y j,k,i = µ + α j + β k + ε j,k,i • Estimate terms by µ = ¯ ˆ ¯ y y j − ¯ α j = ¯ ˆ y ¯ ˆ y k − ¯ β k = ¯ ¯ y α j + ˆ y j,k,i = ˆ ˆ µ + ˆ β k ε j,k,i = y j,k,i − ˆ ˆ y j,k,i 10 / 25

  9. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Sums of Squares α j + ˆ y j,k,i = ˆ µ + ˆ β k + ε j,k,i µ ) 2 = (ˆ α j + ˆ β k + ε j,k,i ) 2 ( y j,k,i − ˆ n j,k � � � α 2 SS A = ˆ j j k i =1 n j,k ˆ � � � β 2 SS B = k j k i =1 n j,k � � � ε 2 SS Error = ˆ j,k,i j k i =1 Note: SS Total = SS A + SS B + SS Error , since cross terms are all zero. 11 / 25

  10. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms The Two-Way ANOVA Table Source d f SS MS F P Factor A J − 1 K − 1 Factor B Residuals N − J − K + 1 — — Total N − 1 — — Pair “Quiz”: Factor A has J = 3 levels, factor B has K = 5 levels, with one observation per cell. How many degrees of freedom in each row of the table above? 12 / 25

  11. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Two-Way ANOVA Table library("mosaic"); library("Stat2Data") data("Alfalfa") two.way.model <- aov(Ht4 ~ Acid + Row, data = Alfalfa) summary(two.way.model) Df Sum Sq Mean Sq F value Pr(>F) Acid 2 6.852 3.426 4.513 0.0487 * Row 4 4.183 1.046 1.378 0.3235 Residuals 8 6.072 0.759 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Caution: The F tests here amount to sequential nested F -tests, so order matters if there is any collinearity (here there is none, since the design is perfectly balanced) 13 / 25

  12. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Getting Means ## Note: this only works if you used aov(), not lm() model.tables(two.way.model, type = "means") Tables of means Grand mean 1.74 Acid Acid 1.5HCl 3.0HCl water 1.466 1.084 2.670 Row Row a b c d e 1.16 1.57 1.25 2.26 2.46 14 / 25

  13. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Getting “Effects” ( α s and β s) ## Note: this only works if you used aov(), not lm() model.tables(two.way.model, type = "effects") Tables of effects Acid Acid 1.5HCl 3.0HCl water -0.274 -0.656 0.930 Row Row a b c d e -0.58 -0.17 -0.49 0.52 0.72 ## Notice that the alphas and betas each sum to zero 15 / 25

  14. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Post-Hoc Pairwise Comparisons TukeyHSD(two.way.model) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = Ht4 ~ Acid + Row, data = Alfalfa) $Acid diff lwr upr p adj 3.0HCl-1.5HCl -0.382 -1.95650626 1.192506 0.7739299 water-1.5HCl 1.204 -0.37050626 2.778506 0.1338368 water-3.0HCl 1.586 0.01149374 3.160506 0.0484908 $Row diff lwr upr p adj b-a 0.41 -2.04758 2.86758 0.9750089 c-a 0.09 -2.36758 2.54758 0.9999282 d-a 1.10 -1.35758 3.55758 0.5642564 e-a 1.30 -1.15758 3.75758 0.4211177 c-b -0.32 -2.77758 2.13758 0.9899007 d-b 0.69 -1.76758 3.14758 0.8613573 e-b 0.89 -1.56758 3.34758 0.7251160 d-c 1.01 -1.44758 3.46758 0.6333208 e-c 1.21 -1.24758 3.66758 0.4830625 e-d 0.20 -2.25758 2.65758 0.9983249 17 / 25

  15. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Additive vs. Interaction Model The Two-way ANOVA Additive Model ( X A , X B categorical) Y = f ( X ) + ε ε ∼ N (0 , σ 2 Y = µ + α j + β k + ε, ε ) One α j for each level of X A One β k for each level of X B Assumes the “effect” of Factor A is the same at each level of Factor B (like parallel lines models in regression). 19 / 25

  16. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Interaction Model The Two-way ANOVA Interaction Model ( X A , X B categorical) Y = f ( X ) + ε ε ∼ N (0 , σ 2 Y = µ + α j + β k + γ jk + ε, ε ) One α j for each level of X A One β k for each level of X B One γ jk for each combination of X A and X B • Predicted “effect” of level j of factor A , when at level k of factor B : α j + γ jk . • Predicted “effect” of level k of factor B , when at level j of factor A : β k + γ jk . • “Effects” are modulated by the interaction term, γ jk : a “difference of differences”. 20 / 25

  17. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Example: Glue! An experiment recorded the amount of force in Newtons (the response) that it takes to separate two pieces of plastic that have been glued together, for three different thicknesses of material (thin, moderate, thick), and two types of glue (wood vs. plastic). There are two cases at each combination of factors. The data is below usual one-row-per-case form. Thickness/Glue Plastic Wood Mean Thin 52 , 64 72 , 60 62 Moderate 67 , 55 78 , 68 67 Thick 86 , 72 43 , 51 63 Mean 66 62 64 21 / 25

  18. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Glue! library("mosaic") GlueData <- read.file("http://colinreimerdawson.com/data/glue.csv") ### Plot the means with(GlueData, interaction.plot(Thickness, Glue, Force)) 80 Glue 75 Wood mean of Force 70 Plastic 65 60 55 50 Moderate Thick Thin Thickness 22 / 25

  19. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Glue! We can write down a two-way ANOVA model with an interaction as follows: Y = µ + α j + β k + γ j,k + ε How do we interpret each coefficient? 23 / 25

  20. Outline Two-Way ANOVA: Additive Model FIT: Estimating Parameters Pairwise Comparisons Interaction Terms Fitting the Model Demo 24 / 25

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend