class: center, middle, inverse, title-slide #
Categorical Interactions 1
## Data Analysis for Psychology in R 2
### Tom Booth and Alex Doumas ### Department of Psychology
The University of Edinburgh ### AY 2020-2021 --- # Weeks Learning Objectives 1. Estimate and interpret interactions in factorial designs. 2. Visualize and probe interactions in factorial designs. 3. Understand how to calculate analogous estimates to those typically reported in ANOVA analyses. --- # Topics for today - Interactions! - Different kinds of interactions and how to interpret them. - Simple visualsiations for understanding interactions. --- # Introduction - Today we're going to focus on interpretting interactions in factorial designs. - We'll focus on how to understanding and how to read interaction plots. - In these plots we have two categorical variables, each of which has two levels. Here I am going to call them: - `cond1` with levels A and B - `cond2` with levels C and D - It's the simplest case for a factorial design, and so it is an obvious choice for getting used to looking at such plots! --- # Refresher - When viewing the plots, we need to remember that each point represents a group mean. - For the sake of these plots, we can assume that each group has the same number of participants. - So what we are doing is plotting our 2x2 tables of means. --- # Refresher ``` ## C D Mean ## A 20 10 15 ## B 10 20 15 ## Mean 15 15 15 ``` - **Cell mean**: Average score for the participants in that particular experimental condition. So the group of people in condition A-C have a mean of 20. etc. - **Marginal mean**: The average for a level of one condition *across level* of the other. So, the average score of people in condition A (so A-C and A-D) is 15. - **Simple effect**: Is a test across one condition at a single level of the other. So A test of the difference between A and B within level C. - **Main effect**: Average across all simple effects. - **Interaction**: Test of the difference in effect across levels of the other variable. So, is the effect of condition1 (difference in A-B), different for level C and D of condition 2. - Put differently: Are simple effects changing across levels of the second variable. ??? Remember also when looking at this document, we are not talking in terms of inference and statistical significance. We are simply trying to put across what indicative patterns in data would look like in a given plot. This should allow you to interpret plots, and cross-check these against results - either in your own work or published work. --- # Interaction plots - Let's look at how to interpret interactions using the easiest tool at our disposal, the interaction plot. - An interaction plot basically shows us the effects of one IV1 on the DV as a function of the different levels of IV1. - On the y-axis we have the DV. - On the x-axis we have levels of IV1. - We have different lines representing the levels of IV2. - We'll look at a concrete example now... - Let's start by considering a case where we have no main effect, but we do have an interaction... --- # No main effects, but an interaction .pull-left[ - Let's start with some data each time: ``` ## C D Mean ## A 20 10 15 ## B 10 20 15 ## Mean 15 15 15 ``` ] .pull-right[ - And now let's look at the plot: ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-4-1.png)<!-- --> ] --- # No main effects, but an interaction .pull-left[ - First, consider the main effect of `cond1`. - The black dots in this plot represent the marginal means for level A and level B of `cond1`. - The main effect here concerns whether these means are different. - The magnitude of the difference can be judged by the distance between the dashed horizontal lines when they meet the y-axis. - The dashed horizontal line runs through both points, and clearly shows they are not different! There appears to be no main effect of `cond1` ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-5-1.png)<!-- --> ] --- # No main effects, but an interaction .pull-left[ - Next, consider the main effect of `cond2`. - Again, the black dot represent the marginal means for levels C and D of `cond2`. - These are the same value, so the points overlay one another. - Again, the dashed line runs through each point, but is overlayed. There appears to be no difference in these means, so no main effect. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-6-1.png)<!-- --> ] --- # No main effects, but an interaction .pull-left[ - Finally the interaction. - When thinking about the interactions, we are thinking about the differences between conditions C and D within conditions A and B. - Let's highlight the differences of C-D within A and within B. - It's clear that these values are different (10 and -10). - This difference indicates to us that there is an interation. - In this case, the interaction is **disordinal** in other words, the lines cross. The name disordinal points to the fact that the ranking of C and D change order in A and B. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-7-1.png)<!-- --> ] --- ## Main effect cond2, with an interaction .pull-left[ - We will start with some data... ``` ## C D Mean ## A 12.00 14.00 13.00 ## B 20.00 5.00 12.50 ## Mean 16.00 9.50 12.75 ``` ] .pull-right[ - And let's look at the plot: ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-10-1.png)<!-- --> ] --- ## Main effect cond2, with an interaction .pull-left[ - Let's consider the main effect of `cond1`. - The dots are at the means of each level across levels of `cond2`, and the dashed lines run through each dot. As we can see, they are very close together. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-11-1.png)<!-- --> ] --- ## Main effect cond2, with an interaction .pull-left[ - And the main effect of `cond2`. - For `cond2` you can see that there is a difference in the outcome variable across these conditions that is more substantial. This would indicate a potential effect. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-12-1.png)<!-- --> ] --- ## Main effect cond2, with an interaction .pull-left[ - And finally, the interaction. - We see some indication of the interaction. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-13-1.png)<!-- --> ] --- ## Main effect of cond1, with an interaction .pull-left[ - We will start with some data... ```r dat3 <- tibble( cond1 = c("A", "A", "B", "B"), cond2 = c("C", "D", "C", "D"), score = c(20, 25, 10, 5) ) ``` ``` ## C D Mean ## A 20.0 25.0 22.5 ## B 10.0 5.0 7.5 ## Mean 15.0 15.0 15.0 ``` ] .pull-right[ And let's look at the plot: ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-16-1.png)<!-- --> ] --- ## Main effect of cond1, with an interaction .pull-left[ - Let's consider the main effect of `cond1`. - In this plot we can see a large difference (distance between the lines) in score for level A and level B of `cond1`. Indicating there is a main effect present. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-17-1.png)<!-- --> ] --- ## Main effect of cond1, with an interaction .pull-left[ - And the main effect of `cond2`. - Again, the dashed line runs through each point, but is overlayed. In short, there appears to be no difference in these means, so no main effect of `cond2`. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-18-1.png)<!-- --> ] --- ## Main effect of cond1, with an interaction .pull-left[ - And finally the interaction. - We see some indication of the interaction. - Think through the idea that within level A, people in condition D score better than C, and in level B, this is reversed. So we are seeing a change in the effect of one variable asd a function of the other. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-19-1.png)<!-- --> ] --- ## Main effect of cond1 and cond2, with an interaction .pull-left[ Let's do this one quickly as hopefully you are getting the hang of it... ``` ## C D Mean ## A 25.0 27.0 26.0 ## B 18.0 2.0 10.0 ## Mean 21.5 14.5 18.0 ``` ] .pull-right[ And let's look at the plot: ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-22-1.png)<!-- --> ] --- ## Main effect of cond1 and cond2, with an interaction .pull-left[ - First, let's consider the main effect of `cond1`. - Dashed lines differ! ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-23-1.png)<!-- --> ] --- ## Main effect of cond1 and cond2, with an interaction .pull-left[ - And the main effect of `cond2`. - Dashed lines differ! ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-24-1.png)<!-- --> ] --- ## Main effect of cond1 and cond2, with an interaction .pull-left[ - And finally the interaction. - Again, when thinking about the interactions, we are thinking about the differences between conditions C and D with conditions A and B, so we'll annotate the plots with the value of C-D within A and within B. - Should see indication of an interaction. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-25-1.png)<!-- --> ] --- ## Main effect cond1, no main effect cond2 or interaction .pull-left[ - We start with some data each time... ``` ## C D Mean ## A 20.0 19.0 19.5 ## B 10.0 9.0 9.5 ## Mean 15.0 14.0 14.5 ``` ] .pull-right[ And now let's look at the plot: ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-28-1.png)<!-- --> ] --- ## Main effect cond1, no main effect cond2 or interaction .pull-left[ So let's consider the main effect of `cond1`. There appears to be no main effect of `cond1`. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-29-1.png)<!-- --> ] --- ## Main effect cond1, no main effect cond2 or interaction .pull-left[ And the main effect of `cond2`. Lines are very close, likely no effect of `cond2`. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-30-1.png)<!-- --> ] --- ## Main effect cond1, no main effect cond2 or interaction .pull-left[ - And the interaction. - So this is our only no interaction example. Note the value of the differences is the same, and the lines are parallel. ] .pull-right[ ![](dapR2_lec25_CatInteractions1_files/figure-html/unnamed-chunk-31-1.png)<!-- --> ] --- # Summary of today - Interactions mean a difference in the relatative effects of one IV at different levels of another. - If the difference in the levels of IV1 are different when you're at one level of IV2 vs another, then you're looking at an interaction. - The easiest way to visualise an interaction and it's implications are with an interaction plot.