class: center, middle, inverse, title-slide # Interactions (III) --- ## Last time Mixing categorical and continuous variables - [New example](https://uopsych.github.io/psy612/lectures/15-interactions.html#23) - Starting factorial ANOVA --- class:inverse ## Factorial ANOVA The interaction of two or more categorical variables in a general linear model is formally known as **Factorial ANOVA**. A factorial design is used when there is an interest in how two or more variables (or factors) affect the outcome. * Rather than conduct separate one-way ANOVAs for each factor, they are all included in one analysis. * The unique and important advantage to a factorial ANOVA over separate one-way ANOVAs is the ability to examine interactions. --- .pull-left[ The example data are from a simulated study in which 180 participants performed an eye-hand coordination task in which they were required to keep a mouse pointer on a red dot that moved in a circular motion. ] .pull-right[ ![](images/dot.jpg) ] The outcome was the time of the 10th failure. The experiment used a completely crossed, 3 x 3 factorial design. One factor was dot speed: .5, 1, or 1.5 revolutions per second. The second factor was noise condition: no noise, controllable noise, and uncontrollable noise. The design was balanced. --- ### Marginal means <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Noise </th> <th style="text-align:right;"> Slow </th> <th style="text-align:right;"> Medium </th> <th style="text-align:right;"> Fast </th> <th style="text-align:right;"> Marginal </th> </tr> </thead> <tbody> <tr grouplength="3"><td colspan="5" style="border-bottom: 1px solid;"><strong></strong></td></tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> None </td> <td style="text-align:right;"> 630.72 </td> <td style="text-align:right;"> 525.29 </td> <td style="text-align:right;"> 329.28 </td> <td style="text-align:right;"> 495.10 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Controllable </td> <td style="text-align:right;"> 576.67 </td> <td style="text-align:right;"> 492.72 </td> <td style="text-align:right;"> 287.23 </td> <td style="text-align:right;"> 452.21 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Uncontrollable </td> <td style="text-align:right;"> 594.44 </td> <td style="text-align:right;"> 304.62 </td> <td style="text-align:right;"> 268.16 </td> <td style="text-align:right;"> 389.08 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;color: white !important;background-color: #562457 !important;"> Marginal </td> <td style="text-align:right;font-weight: bold;color: white !important;background-color: #562457 !important;"> 600.61 </td> <td style="text-align:right;font-weight: bold;color: white !important;background-color: #562457 !important;"> 440.88 </td> <td style="text-align:right;font-weight: bold;color: white !important;background-color: #562457 !important;"> 294.89 </td> <td style="text-align:right;font-weight: bold;color: white !important;background-color: #562457 !important;"> 445.46 </td> </tr> </tbody> </table> Regardless of noise condition, does speed of the moving dot affect performance? --- ### Marginal means <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Noise </th> <th style="text-align:right;"> Slow </th> <th style="text-align:right;"> Medium </th> <th style="text-align:right;"> Fast </th> <th style="text-align:right;"> Marginal </th> </tr> </thead> <tbody> <tr grouplength="3"><td colspan="5" style="border-bottom: 1px solid;"><strong></strong></td></tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> None </td> <td style="text-align:right;"> 630.72 </td> <td style="text-align:right;"> 525.29 </td> <td style="text-align:right;"> 329.28 </td> <td style="text-align:right;font-weight: bold;color: white !important;background-color: #562457 !important;"> 495.10 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Controllable </td> <td style="text-align:right;"> 576.67 </td> <td style="text-align:right;"> 492.72 </td> <td style="text-align:right;"> 287.23 </td> <td style="text-align:right;font-weight: bold;color: white !important;background-color: #562457 !important;"> 452.21 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Uncontrollable </td> <td style="text-align:right;"> 594.44 </td> <td style="text-align:right;"> 304.62 </td> <td style="text-align:right;"> 268.16 </td> <td style="text-align:right;font-weight: bold;color: white !important;background-color: #562457 !important;"> 389.08 </td> </tr> <tr> <td style="text-align:left;"> Marginal </td> <td style="text-align:right;"> 600.61 </td> <td style="text-align:right;"> 440.88 </td> <td style="text-align:right;"> 294.89 </td> <td style="text-align:right;font-weight: bold;color: white !important;background-color: #562457 !important;"> 445.46 </td> </tr> </tbody> </table> Regardless of dot speed, does noise condition affect performance? --- ### Marginal means <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Noise </th> <th style="text-align:right;"> Slow </th> <th style="text-align:right;"> Medium </th> <th style="text-align:right;"> Fast </th> <th style="text-align:right;"> Marginal </th> </tr> </thead> <tbody> <tr grouplength="3"><td colspan="5" style="border-bottom: 1px solid;"><strong></strong></td></tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> None </td> <td style="text-align:right;"> 630.72 </td> <td style="text-align:right;"> 525.29 </td> <td style="text-align:right;"> 329.28 </td> <td style="text-align:right;"> 495.10 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Controllable </td> <td style="text-align:right;"> 576.67 </td> <td style="text-align:right;"> 492.72 </td> <td style="text-align:right;"> 287.23 </td> <td style="text-align:right;"> 452.21 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Uncontrollable </td> <td style="text-align:right;"> 594.44 </td> <td style="text-align:right;"> 304.62 </td> <td style="text-align:right;"> 268.16 </td> <td style="text-align:right;"> 389.08 </td> </tr> <tr> <td style="text-align:left;"> Marginal </td> <td style="text-align:right;"> 600.61 </td> <td style="text-align:right;"> 440.88 </td> <td style="text-align:right;"> 294.89 </td> <td style="text-align:right;"> 445.46 </td> </tr> </tbody> </table> The **marginal mean differences** correspond to main effects. They tell us what impact a particular factor has, ignoring the impact of the other factor. The remaining effect in a factorial design, and it primary advantage over separate one-way ANOVAs, is the ability to examine **conditional mean differences**. --- ### Mean differences <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Noise </th> <th style="text-align:right;"> Slow </th> <th style="text-align:right;"> Medium </th> <th style="text-align:right;"> Fast </th> <th style="text-align:right;"> Marginal </th> </tr> </thead> <tbody> <tr grouplength="3"><td colspan="5" style="border-bottom: 1px solid;"><strong></strong></td></tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> None </td> <td style="text-align:right;background-color: #EECACA !important;"> 630.72 </td> <td style="text-align:right;background-color: #B2D4EB !important;"> 525.29 </td> <td style="text-align:right;background-color: #FFFFC5 !important;"> 329.28 </td> <td style="text-align:right;color: white !important;background-color: grey !important;"> 495.10 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Controllable </td> <td style="text-align:right;background-color: #EECACA !important;"> 576.67 </td> <td style="text-align:right;background-color: #B2D4EB !important;"> 492.72 </td> <td style="text-align:right;background-color: #FFFFC5 !important;"> 287.23 </td> <td style="text-align:right;color: white !important;background-color: grey !important;"> 452.21 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;" indentlevel="1"> Uncontrollable </td> <td style="text-align:right;background-color: #EECACA !important;"> 594.44 </td> <td style="text-align:right;background-color: #B2D4EB !important;"> 304.62 </td> <td style="text-align:right;background-color: #FFFFC5 !important;"> 268.16 </td> <td style="text-align:right;color: white !important;background-color: grey !important;"> 389.08 </td> </tr> <tr> <td style="text-align:left;background-color: white !important;"> Marginal </td> <td style="text-align:right;background-color: #EECACA !important;background-color: white !important;"> 600.61 </td> <td style="text-align:right;background-color: #B2D4EB !important;background-color: white !important;"> 440.88 </td> <td style="text-align:right;background-color: #FFFFC5 !important;background-color: white !important;"> 294.89 </td> <td style="text-align:right;color: white !important;background-color: grey !important;background-color: white !important;"> 445.46 </td> </tr> </tbody> </table> Are the marginal mean differences for noise condition a good representation of what is happening within each of the dot speed conditions? If not, then we would need to say that the noise condition effect depends upon (is conditional on) dot speed. We would have an interaction between noise condition and dot speed condition. --- ![](16-interactions_files/figure-html/unnamed-chunk-7-1.png)<!-- --> The noise condition means are most distinctly different in the medium speed condition. The noise condition means are clearly not different in the fast speed condition. --- ### Interpretation of interactions The presence of an interaction qualifies any main effect conclusions, leading to "yes, but" or "it depends" kinds of inferences. .pull-left[ ![](16-interactions_files/figure-html/unnamed-chunk-8-1.png)<!-- --> ] .pull-right[ Does noise condition affect failure time? "Yes, but the magnitude of the effect is strongest for the medium speed condition, weaker for the fast speed condition, and mostly absent for the slow speed condition." ] --- ### Interactions are symmetrical <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Noise </th> <th style="text-align:right;"> Slow </th> <th style="text-align:right;"> Medium </th> <th style="text-align:right;"> Fast </th> <th style="text-align:right;"> Marginal </th> </tr> </thead> <tbody> <tr grouplength="3"><td colspan="5" style="border-bottom: 1px solid;"><strong></strong></td></tr> <tr> <td style="text-align:left; padding-left: 2em;background-color: #EECACA !important;" indentlevel="1"> None </td> <td style="text-align:right;background-color: #EECACA !important;"> 630.72 </td> <td style="text-align:right;background-color: #EECACA !important;"> 525.29 </td> <td style="text-align:right;background-color: #EECACA !important;"> 329.28 </td> <td style="text-align:right;background-color: #EECACA !important;background-color: white !important;"> 495.10 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;background-color: #B2D4EB !important;" indentlevel="1"> Controllable </td> <td style="text-align:right;background-color: #B2D4EB !important;"> 576.67 </td> <td style="text-align:right;background-color: #B2D4EB !important;"> 492.72 </td> <td style="text-align:right;background-color: #B2D4EB !important;"> 287.23 </td> <td style="text-align:right;background-color: #B2D4EB !important;background-color: white !important;"> 452.21 </td> </tr> <tr> <td style="text-align:left; padding-left: 2em;background-color: #FFFFC5 !important;" indentlevel="1"> Uncontrollable </td> <td style="text-align:right;background-color: #FFFFC5 !important;"> 594.44 </td> <td style="text-align:right;background-color: #FFFFC5 !important;"> 304.62 </td> <td style="text-align:right;background-color: #FFFFC5 !important;"> 268.16 </td> <td style="text-align:right;background-color: #FFFFC5 !important;background-color: white !important;"> 389.08 </td> </tr> <tr> <td style="text-align:left;color: white !important;background-color: grey !important;"> Marginal </td> <td style="text-align:right;color: white !important;background-color: grey !important;"> 600.61 </td> <td style="text-align:right;color: white !important;background-color: grey !important;"> 440.88 </td> <td style="text-align:right;color: white !important;background-color: grey !important;"> 294.89 </td> <td style="text-align:right;color: white !important;background-color: grey !important;background-color: white !important;"> 445.46 </td> </tr> </tbody> </table> Are the marginal mean differences for speed condition a good representation of what is happening within each of the noise conditions? If not, then we would need to say that the speed condition effect depends upon (is conditional on) noise condition. --- .left-column[ .small[ The speed condition means are clearly different in each noise condition, but the pattern of those differences is not the same. The marginal speed condition means do not represent well the means in each noise condition. An interaction.] ] ![](16-interactions_files/figure-html/unnamed-chunk-10-1.png)<!-- --> --- ### Null Hypotheses | | Slow | Medium | Fast | Marginal | |:-|:-:|:-:|:-:|:-:| | No Noise | `\(\mu_{11}\)` | `\(\mu_{12}\)` | `\(\mu_{13}\)` | `\(\mu_{1.}\)` | | Controllable Noise | `\(\mu_{21}\)` | `\(\mu_{22}\)` | `\(\mu_{23}\)` | `\(\mu_{2.}\)` | | Uncontrollable Noise | `\(\mu_{31}\)` | `\(\mu_{32}\)` | `\(\mu_{33}\)` | `\(\mu_{3.}\)` | | Marginal | `\(\mu_{.1}\)` | `\(\mu_{.2}\)` | `\(\mu_{.3}\)` | `\(\mu_{..}\)` | The two main effects and the interaction represent three independent questions we can ask about the data. We have three null hypotheses to test. One null hypothesis refers to the marginal row means. $$ `\begin{aligned} \large H_0&: \mu_{1.} = \mu_{2.} = \dots = \mu_{R.}\\ H_1&: \text{Not true that }\mu_{1.} = \mu_{2.} = \dots = \mu_{R.} \end{aligned}` $$ --- ### Null Hypotheses | | Slow | Medium | Fast | Marginal | |:-|:-:|:-:|:-:|:-:| | No Noise | `\(\mu_{11}\)` | `\(\mu_{12}\)` | `\(\mu_{13}\)` | `\(\mu_{1.}\)` | | Controllable Noise | `\(\mu_{21}\)` | `\(\mu_{22}\)` | `\(\mu_{23}\)` | `\(\mu_{2.}\)` | | Uncontrollable Noise | `\(\mu_{31}\)` | `\(\mu_{32}\)` | `\(\mu_{33}\)` | `\(\mu_{3.}\)` | | Marginal | `\(\mu_{.1}\)` | `\(\mu_{.2}\)` | `\(\mu_{.3}\)` | `\(\mu_{..}\)` | We can state this differently (it will make stating the interaction null hypothesis easier when we get to it). $$ `\begin{aligned} \large \alpha_r&= \mu_{r.} - \mu_{..} \\ \large H_0&: \alpha_1 = \alpha_2 = \dots = \alpha_R = 0\\ H_1&: \text{At least one }\alpha_r \neq 0 \end{aligned}` $$ --- ### Null Hypotheses | | Slow | Medium | Fast | Marginal | |:-|:-:|:-:|:-:|:-:| | No Noise | `\(\mu_{11}\)` | `\(\mu_{12}\)` | `\(\mu_{13}\)` | `\(\mu_{1.}\)` | | Controllable Noise | `\(\mu_{21}\)` | `\(\mu_{22}\)` | `\(\mu_{23}\)` | `\(\mu_{2.}\)` | | Uncontrollable Noise | `\(\mu_{31}\)` | `\(\mu_{32}\)` | `\(\mu_{33}\)` | `\(\mu_{3.}\)` | | Marginal | `\(\mu_{.1}\)` | `\(\mu_{.2}\)` | `\(\mu_{.3}\)` | `\(\mu_{..}\)` | The main effect for dot speed (column marginal means) can be stated similarly: $$ `\begin{aligned} \large \beta_c&= \mu_{.c} - \mu_{..} \\ \large H_0&: \beta_1 = \beta_2 = \dots = \beta_C = 0\\ H_1&: \text{At least one }\beta_c \neq 0 \end{aligned}` $$ --- ### Null Hypothesis | | Slow | Medium | Fast | Marginal | |:-|:-:|:-:|:-:|:-:| | No Noise | `\(\mu_{11}\)` | `\(\mu_{12}\)` | `\(\mu_{13}\)` | `\(\mu_{1.}\)` | | Controllable Noise | `\(\mu_{21}\)` | `\(\mu_{22}\)` | `\(\mu_{23}\)` | `\(\mu_{2.}\)` | | Uncontrollable Noise | `\(\mu_{31}\)` | `\(\mu_{32}\)` | `\(\mu_{33}\)` | `\(\mu_{3.}\)` | | Marginal | `\(\mu_{.1}\)` | `\(\mu_{.2}\)` | `\(\mu_{.3}\)` | `\(\mu_{..}\)` | The interaction null hypothesis can then be stated as follows: $$ `\begin{aligned} \large (\alpha\beta)_{rc}&= \mu_{rc} - \alpha_r - \beta_c - \mu_{..} \\ \large H_0&: (\alpha\beta)_{11} = (\alpha\beta)_{12} = \dots = (\alpha\beta)_{RC} = 0\\ H_1&: \text{At least one }(\alpha\beta)_{rc} \neq 0 \end{aligned}` $$ --- ### Variability As was true for the simpler one-way ANOVA, we will partition the total variability in the data matrix into two basic parts. One part will represent variability **within groups**. This within-group variability is variability that has nothing to do with the experimental conditions (all participants within a particular group experience the same experimental conditions). The other part will be **between-group variability**. This part will include variability due to experimental conditions. We will further partition this between-group variability into parts due to the two main effects and the interaction. --- ### Variability $$ `\begin{aligned} \large SS_{\text{total}} &= \sum_{r=1}^R\sum_{c=1}^C\sum_{i=1}^{N_{rc}}(Y_{rci}-\bar{Y}_{...})^2 \\ \large SS_{\text{Within}} &= \sum_{r=1}^R\sum_{c=1}^C\sum_{i=1}^{N_{rc}}(Y_{rci}-\bar{Y}_{rc.})^2 \\ \large SS_R &= CN\sum_{r=1}^R(\bar{Y}_{r..}-\bar{Y}_{...})^2\\ SS_C &= RN\sum_{c=1}^C(\bar{Y}_{.c.}-\bar{Y}_{...})^2\\ \large SS_{RC} &= \sum_{r=1}^R\sum_{c=1}^C\sum_{i=1}^{N_{rc}}(\bar{Y}_{rc.}-\bar{Y}_{r..}-\bar{Y}_{.c.}+\bar{Y}_{...})^2 \\ \end{aligned}` $$ --- ### Variability $$ `\begin{aligned} \large SS_{\text{total}} &= \sum_{r=1}^R\sum_{c=1}^C\sum_{i=1}^{N_{rc}}(Y_{rci}-\bar{Y}_{...})^2 \\ \large SS_{\text{Within}} &= \sum_{r=1}^R\sum_{c=1}^C\sum_{i=1}^{N_{rc}}(Y_{rci}-\bar{Y}_{rc.})^2 \\ \large SS_R &= CN\sum_{r=1}^R(\bar{Y}_{r..}-\bar{Y}_{...})^2\\ SS_C &= RN\sum_{c=1}^C(\bar{Y}_{.c.}-\bar{Y}_{...})^2\\ \large SS_{RC} &= N\sum_{r=1}^R\sum_{c=1}^C(\bar{Y}_{rc.}-\bar{Y}_{r..}-\bar{Y}_{.c.}+\bar{Y}_{...})^2 \\ \end{aligned}` $$ --- ### Variability If the design is balanced (equal cases in all conditions), then: `$$\large SS_{\text{total}} = SS_{\text{within}} + SS_R + SS_C + SS_{RxC}$$` `\(df\)`, `\(MS\)`, and `\(F\)` ratios are defined in the same way as they were for one-way ANOVA. We just have more of them. $$ `\begin{aligned} \large df_R &= R-1 \\ \large df_C &= C-1 \\ \large df_{RxC} &= (R-1)(C-1) \\ \large df_{within} &= N-G \\ &= N-(R-1)-(C-1)-[(R-1)(C-1)]-1\\ &= df_{total} - df_{R} - df_C - df_{RxC} \end{aligned}` $$ --- ### Variability If the design is balanced (equal cases in all conditions), then: `$$\large SS_{\text{total}} = SS_{\text{within}} + SS_R + SS_C + SS_{RxC}$$` `\(df\)`, `\(MS\)`, and `\(F\)` ratios are defined in the same way as they were for one-way ANOVA. We just have more of them. .pull-left[ $$ `\begin{aligned} \large MS_R &= \frac{SS_R}{df_R} \\ \large MS_C &= \frac{SS_C}{df_C} \\ \large MS_{RxC} &= \frac{SS_{RxC}}{df_{RxC}} \\ \large MS_{within} &= \frac{SS_{within}}{df_{within}} \\ \end{aligned}` $$ ] .pull-right[ Each mean square is a variance estimate. `\(MS_{within}\)` is the pooled estimate of the within-groups variance. It represents only random or residual variation. `\(MS_R\)`, `\(MS_C\)`, and `\(MS_{RxC}\)` also contain random variation, but include systematic variability too. ] --- ### F-statistics If the design is balanced (equal cases in all conditions), then: `$$\large SS_{\text{total}} = SS_{\text{within}} + SS_R + SS_C + SS_{RxC}$$` `\(df\)`, `\(MS\)`, and `\(F\)` ratios are defined in the same way as they were for one-way ANOVA. We just have more of them. .pull-left[ $$ `\begin{aligned} \large F_R &= \frac{MS_R}{MS_{within}} \\ \\ \large F_C &= \frac{MS_C}{MS_{within}} \\ \\ \large F_{RxC} &= \frac{MS_{RxC}}{MS_{within}} \\ \end{aligned}` $$ ] .pull-right[ If the null hypotheses are true, these ratios will be ~1.00 because the numerator and denominator of each estimate the same thing. Departures from 1.00 indicate that systematic variability is present. If large enough, we reject the null hypothesis (each considered separately). ] --- ### Degrees of freedom The degrees of freedom for the different F ratios might not be the same. Different degrees of freedom define different theoretical F density distributions for determining what is an unusual value under the null hypothesis. Which is to say, you might get the same F-ratio for two different tests, but they could have different p-values, if they represent different numbers of groups. --- ### Interpretation of significance tests ```r fit = lm(Time ~ Speed*Noise, data = Data) anova(fit) ``` ``` ## Analysis of Variance Table ## ## Response: Time ## Df Sum Sq Mean Sq F value Pr(>F) ## Speed 2 2805871 1402936 109.3975 < 2.2e-16 *** ## Noise 2 341315 170658 13.3075 4.252e-06 *** ## Speed:Noise 4 295720 73930 5.7649 0.0002241 *** ## Residuals 171 2192939 12824 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ``` Interpretation? -- All three null hypotheses are rejected. This only tells us that systemic differences among the means are present; follow-up comparisons are necessary to determine the nature of the differences. --- ### Interpretation of significance tests ```r fit = lm(Time ~ Speed*Noise, data = Data) anova(fit) ``` ``` ## Analysis of Variance Table ## ## Response: Time ## Df Sum Sq Mean Sq F value Pr(>F) ## Speed 2 2805871 1402936 109.3975 < 2.2e-16 *** ## Noise 2 341315 170658 13.3075 4.252e-06 *** ## Speed:Noise 4 295720 73930 5.7649 0.0002241 *** ## Residuals 171 2192939 12824 ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ``` Both main effects and the interaction are significant. The significant interaction qualifies the main effects: - The magnitude of the speed main effect varies across the noise conditions. - The magnitude of the noise main effect varies across the speed conditions. --- ### Visualizing main effects and interactions Different combinations of main effects and interactions yield different shapes when plotted. An important skill is recognizing how plots will change based on the presence or absence of specific effects. Main effects are tests of differences in means; a significant main effect will yield a difference -- the mean of Group 1 will be different than the mean of Group 2, for example. Interactions are tests of the differences of differences of means -- is the difference between Group 1 and Group 2 different in Condition A than that difference is in Condition B, for example. --- ### Visualizing main effects and interactions ![](16-interactions_files/figure-html/unnamed-chunk-13-1.png)<!-- --> ??? No effect of A Main effect of B No interaction --- ### Visualizing main effects and interactions ![](16-interactions_files/figure-html/unnamed-chunk-14-1.png)<!-- --> ??? Main effect of A Main effect of B Interaction --- ### Visualizing main effects and interactions ![](16-interactions_files/figure-html/unnamed-chunk-15-1.png)<!-- --> ??? No effect of A No effect of B Interaction --- ### Visualizing main effects and interactions How would you plot.... * A main effect of A, no main effect of B, and no interaction? * A main effect of A, a main effect of B, and no interaction? * No main effect of A, a main effect of B, and an interaction? --- ## Effect size All of the effects in the ANOVA are statistically significant, but how big are they? An effect size, `\(\eta^2\)`, provides a simple way of indexing effect magnitude for ANOVA designs, especially as they get more complex. `$$\large \eta^2 = \frac{SS_{\text{effect}}}{SS_{\text{total}}}$$` If the design is balanced... `$$\large SS_{\text{total}} = SS_{\text{speed}} + SS_{\text{noise}}+SS_{\text{speed:noise}}+SS_{\text{within}}$$` --- <table> <thead> <tr> <th style="text-align:left;"> Source </th> <th style="text-align:right;"> SS </th> <th style="text-align:right;"> `\(\eta^2\)` </th> <th style="text-align:right;"> `\(\text{partial }\eta^2\)` </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Speed </td> <td style="text-align:right;"> 2805871.4 </td> <td style="text-align:right;width: 10em; "> 0.50 </td> <td style="text-align:right;"> 0.56 </td> </tr> <tr> <td style="text-align:left;"> Noise </td> <td style="text-align:right;"> 341315.2 </td> <td style="text-align:right;width: 10em; "> 0.06 </td> <td style="text-align:right;"> 0.13 </td> </tr> <tr> <td style="text-align:left;"> Speed:Noise </td> <td style="text-align:right;"> 295719.7 </td> <td style="text-align:right;width: 10em; "> 0.05 </td> <td style="text-align:right;"> 0.12 </td> </tr> <tr> <td style="text-align:left;"> Residuals </td> <td style="text-align:right;"> 2192938.9 </td> <td style="text-align:right;width: 10em; "> </td> <td style="text-align:right;"> </td> </tr> <tr> <td style="text-align:left;"> Total </td> <td style="text-align:right;"> </td> <td style="text-align:right;width: 10em; "> </td> <td style="text-align:right;"> </td> </tr> </tbody> </table> The Speed main effect accounts for 8 to 9 times as much variance in the outcome as the Noise main effect and the Speed x Noise interaction. --- ![](images/eta_sq.jpg) --- ### `\(\eta^2\)` .pull-left[ **If the design is balanced:** There is no overlap among the independent variables. They are uncorrelated. The variance accounted for by any effect is unique. There is no ambiguity about the source of variance accounted for in the outcome. The sum of the `\(\eta^2\)` for effects and residual is 1.00. ] .pull-right[ ![](images/eta_sq.jpg) ] --- ### `\(\eta^2\)` One argument against `\(\eta^2\)` is that its magnitude depends in part on the magnitude of the other effects in the design. If the amount of variability due to Noise or Speed x Noise changes, so to does the effect size for Speed. `$$\large \eta^2_{\text{speed}} = \frac{SS_{\text{speed}}}{SS_{\text{speed}} + SS_{\text{noise}} + SS_{\text{speed:noise}}+ SS_{\text{within}}}$$` An alternative is to pretend the other effects do not exist and reference the effect sum of squares to residual variability. `$$\large \text{partial }\eta^2_{\text{speed}} = \frac{SS_{\text{speed}}}{SS_{\text{speed}} + SS_{\text{within}}}$$` --- ### `\(\eta^2\)` One rationale for partial `\(\eta^2\)` is that the residual variability represents the expected variability in the absence of any treatments or manipulations. The presence of any treatments or manipulations only adds to total variability. Viewed from that perspective, residual variability is a sensible benchmark against which to judge any effect. `$$\large \text{partial }\eta^2_{\text{effect}} = \frac{SS_{\text{effect}}}{SS_{\text{effect}} + SS_{\text{within}}}$$` Partial `\(\eta^2\)` is sometimes described as the expected effect size in a study in which the effect in question is the only effect present. --- <table> <thead> <tr> <th style="text-align:left;"> Source </th> <th style="text-align:right;"> SS </th> <th style="text-align:right;"> `\(\eta^2\)` </th> <th style="text-align:right;"> `\(\text{partial }\eta^2\)` </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Speed </td> <td style="text-align:right;"> 2805871.4 </td> <td style="text-align:right;width: 10em; "> 0.50 </td> <td style="text-align:right;"> 0.56 </td> </tr> <tr> <td style="text-align:left;"> Noise </td> <td style="text-align:right;"> 341315.2 </td> <td style="text-align:right;width: 10em; "> 0.06 </td> <td style="text-align:right;"> 0.13 </td> </tr> <tr> <td style="text-align:left;"> Speed:Noise </td> <td style="text-align:right;"> 295719.7 </td> <td style="text-align:right;width: 10em; "> 0.05 </td> <td style="text-align:right;"> 0.12 </td> </tr> <tr> <td style="text-align:left;"> Residuals </td> <td style="text-align:right;"> 2192938.9 </td> <td style="text-align:right;width: 10em; "> </td> <td style="text-align:right;"> </td> </tr> <tr> <td style="text-align:left;"> Total </td> <td style="text-align:right;"> </td> <td style="text-align:right;width: 10em; "> </td> <td style="text-align:right;"> </td> </tr> </tbody> </table> Partial `\(\eta^2\)` will be larger than `\(\eta^2\)` if the ignored effects account for any variability. The sum of partial `\(\eta^2\)` does not have a meaningful interpretation.