Chapter 13 Factorial ANOVA Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 0 / 19
Today s Menu Now we extend our one-way ANOVA approach to two (or more) factors. Factorial ANOVA: two-way ANOVA, SS decomposition, interactions. Unbalanced designs. Factorial ANOVA through a linear model: simple effect analysis. Nonparametric approaches. Mixed ANOVA (between-within subject designs) Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 1 / 19
Extension to Two Factors The data scenario for this unit is: Two or more categorical variables (factors). One metric variable (response). We are interested in which factors (or factor combinations) have an influence on the response variable. Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 2 / 19
Effects in Two-Way ANOVA In a one-way ANOVA the only possible effect was due to the factor. Question: Do the response means differ across factor levels (groups)? In a two-way ANOVA with factors A and B we have: Main effect A: the means of Y differ across the levels of A Main effect B: the means of Y differ across the levels of B Interaction effect: the means of Y differ across combinations of A and B Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 3 / 19
Honk Example In the t-test unit we looked for differences in the average honking frequency between a fancy BMW and a small Ford KA. Now: This time we use a different response variable: Duration until the first honk. We have two factors: car and gender. What we have is a 2 2 design (2 car categories, 2 gender categories). Note that we are not limited to binary factors. Research question: Do car type and/or gender influence the average honking duration? Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 4 / 19
The F-test and Sum of Squares We have our well-known SS decomposition: SSTO = SSTR + SSE Now, the SSTR (based on deviation of the cell means from the grand mean) looks a little bit more complex: SSTR = SSTR A + SSTR B + SSTR A B with: SSTR A as the deviation of the A factor level mean from the grand mean. SSTR B as the deviation of the B factor level mean from the grand mean. SSTR AB = SSTO SSTR A SSTR B SSE. The F -statistics are based on these SS and the corresponding df. Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 5 / 19
Assumptions Basically there are two assumptions in factorial ANOVA: For small samples, normal residuals/response within each factor combination. Variance homogeneity across factor combinations: Levene test. If possible, keep your design balanced (same number of observations within each factor combination). With unbalanced designs things are getting tricky in factorial ANOVA. More on that later. Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 6 / 19
Main Effects Structures for the Honking Example Hypothetical main effect structures (means across groups) for our car example (dashed line male, solid line female). Null Model Main Effect Car 3 4 5 6 7 3 4 5 6 7 BMW Ford BMW Ford Main Effect Sex Main Effect Car + Sex 3 4 5 6 7 3 4 5 6 7 BMW Ford BMW Ford Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 7 / 19
Interactions The interpretation of a two-way (or more) ANOVA depends on the interaction structure. If the interaction effect is significant, we need to look at the interaction plots and distinguish: 1) Ordinal interactions: even though significant, main effects interpretable. B A interaction A B interaction Means Factor B 1 2 3 4 5 6 b1 b2 Means Factor A 1 2 3 4 5 6 a1 a2 a1 a2 b1 b2 Factor A Factor B Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 8 / 19
Interactions 2) Disordinal Interactions: if significant, main effects not interpretable. B A interaction A B interaction Means Factor B 1 2 3 4 5 6 b1 b2 Means Factor A 1 2 3 4 5 6 a1 a2 a1 a2 b1 b2 Factor A Factor B In this case we can go back to the interaction plot and interpret the interaction effect. Another possibility would be to define special contrasts and look at the effect of one factor at individual levels of the other factor (simple effect analysis). Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 9 / 19
Interactions 3) Hybrid Interactions: if significant, main effect for B interpretable, main effect for A not. B A interaction A B interaction Means Factor B 1 2 3 4 5 6 b1 b2 Means Factor A 1 2 3 4 5 6 a1 a2 a1 a2 b1 b2 Factor A Factor B Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 10 / 19
[ Factorial ANOVA ] Unbalanced Designs Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 11 / 19
Unbalanced Designs An unbalanced design can occur: because of subject attrition, because the study is observational in nature and subjects were taken as they came. The main problem is that the factors lose their independence from one another. It then makes a difference in what order the factors are entered into the model formula. A quick and dirty way would be to try entering the factors in different orders to see how much of a difference this makes to the outcome of the analysis. Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 12 / 19
Unbalanced Designs Different types of SS: Type I SS (sequential SS): Used by aov(), SSTR A SSTR B A SSTR AB A,B Type II SS: Implemented in Anova(), SSTR A B ; SSTR B A. It assumes no interaction, main effects are interpretable independently from each other. Type III SS: Implemented in Anova(), SSTR A B,AB ; SSTR B A,AB. This approach is therefore valid in the presence of significant interactions. 1 A few remarks: Note that the interaction effect doesn t change at all across the approaches. It is all about the main effects. Note that with unbalanced designs the parameter interpretation within the context of a linear model (design matrix) becomes difficult. There is lots of controversy/confusion in literature regarding how to formulate hypotheses, contrasts, and SS in unbalanced designs. Type II SS is the way to go if the interaction is not significant. If we have a significant interaction, we can t interpret the main effects anyway (except for ordinal and hybrid interactions). 1 But if we have disordinal significant interactions we shouldn t interpret the main effects anyway! Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 13 / 19
[ Factorial ANOVA ] Linear Models Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 14 / 19
Factorial ANOVA as Linear Models The design matrix principle is exactly the same as we ve seen so far. dummy coding (contr.treatment) effects coding (contr.sum) other special coding schemes such as Helmert, polynomial, etc. The interaction contrasts result from main-effects multiplication. Another nice implication of doing 2-way ANOVA through a linear model specification is that we can do a simple effect analysis in order to break down significant interactions. Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 15 / 19
Extensions We ve already seen how painful interactions can be for two variables. Things become much worse for 3, 4, etc. and at some point it becomes uninterpretable. Keep the number of factors low, if possible! There is an example in the R code file for a 3-way ANOVA. Nonparametric approaches: For 2-way ANOVA the WRS2 package offers several options: 2-way ANOVA on trimmed means (t2way()) 2-way ANOVA on medians (med2way()) The nonparametric version is t3way() in the WRS2 package. Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 16 / 19
[ Factorial ANOVA ] Mixed ANOVA Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 17 / 19
Mixed ANOVA Let s now combine dependent measure ANOVA with standard between group ANOVA. This leads to a mixed ANOVA (aka split-plot design or between-within subjects ANOVA). We can fit these models through: classic between-within ANOVA: ezanova(). mixed effects models: greater flexibility (lme()) Nothing changes in terms of assumptions and interpretation. Robust alternatives are given in the WRS2 package by means of bwtrim(). Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 18 / 19
Summary Today we have seen higher-order ANOVA models with possibly unbalanced designs: 2-way ANOVA, 3-way ANOVA, robust alternatives. Note that you can also use post-hoc tests. The glht() function in the multcomp package is pretty powerful. However, a more modern approach is to incorporate special hypotheses using design matrices. We also started elaborating on mixed ANOVA (between-within subjects) designs. Such settings will be extensively covered in the mixed-effects units. Readings due to Tues: Field Chapter 11 (ANCOVA). Patrick Mair 2015 Psych 1950 13 Factorial ANOVA 19 / 19