class: center, middle, title-slide, inverse, no-scribble layout: false <audio controls> <source src="media/acdc_that_the_way.mp3" type="audio/mpeg"> <source src="media/acdc_that_the_way.ogg" type="audio/ogg"/> </audio> # Factorial designs and the GLM ## Professor Andy Field <div> <img style="vertical-align:middle; width:30px; height:30px" src="media/twitter_60.png"> <span style="line-height:40px;">@profandyfield</span> </div> <div> <img style="vertical-align:middle; width:60px" src="media/youtube.png"> <span style="line-height:40px;">www.youtube.com/user/ProfAndyField/</span> </div> <div> <img style="vertical-align:middle; width:30px; height:30px" src="media/ds_com_fav.png"> <span style="line-height:40px;">www.discoveringstatistics.com</span> </div> <div> <img style="vertical-align:middle; width:30px; height:30px" src="media/milton_grey_fav.png"> <span style="line-height:40px;">www.milton-the-cat.rocks</span> </div> <div> <img style="vertical-align:middle; width:30px; height:30px" src="media/discovr_fav.png"> <span style="line-height:40px;">www.discovr.rocks</span> </div> ??? Music: AC/DC That's the way I want to rock and roll h or ?: Toggle the help window j: Jump to next slide k: Jump to previous slide b: Toggle blackout mode m: Toggle mirrored mode. p: Toggle PresenterMode f: Toggle Fullscreen t: Reset presentation timer <number> + <Return>: Jump to slide <number> c: Create a clone presentation on a new window --- class: center  ??? We've seen this map of the process of fitting models before --- class: center  ??? Today we focus back on the model itself to look at the form of the model we're fitting. The faded stuff still applies though - we'll look at bias, robust models, and of course samples and estimation and so on. But they are the same as for other models, what is different is the form of the model we're fitting. --- # Learning outcomes * What is a factorial design? * Factorial designs and the GLM + Checking assumptions + Robust models * Moderation and interaction effects * Breaking down interactions + Plots + Simple effects analysis --- # Terminology * Variables in experimental designs + Predictor variables referred to as **independent variables (IV)** because their value is independent of (is not being predicted from) other variables. + Outcome variable referred to as the **dependent variables (DV)**, because their value 'depends' upon (is being predicted from) other variables. * **Factorial design**: Two or more predictor variables/IV have been manipulated * ***n*-way design**: The number of predictor variables/IVs manipulated + Two-way = 2 predictor variables/IVs manipulated + Three-way = 3 predictor variables/IVs manipulated * The allocation of participants + **Independent design** = different entities in all conditions + **Repeated measures design** = the same entities in all conditions + **Mixed design** = different entities in all conditions of at least one predictor/IV, the same entities in all conditions of at least one other predictor variable/IV --- class: center, middle, title-slide, inverse layout: false ## Moderation: Do video games lead to aggression? --- background-image: none background-color: #000000 class: no-scribble <video width="100%" height="100%" controls id="my_video"> <source src="media/warcraft_final.mp4" type="video/mp4"> </video> --- # Moderation * Is there a link between video games and aggression? + Outcome = aggressive behaviour (**aggress**) + Callus Unemotional Traits (**caunts**) + Video game Use (**vid_game**) ??? Imagine a scientist wanted to look at the relationship between playing violent video games such as Grand Theft Auto, MadWorld and Manhunt and aggression. She gathered data from 442 youths. She measured their aggressive behaviour (aggress), callous unemotional traits (caunts), and the number of hours per week they play video games (vid_game) --- # Moderation: The theoretical model  --- # Categorical moderator variable .center[ <!-- --> ] --- # Continuous moderator variable .center[  ] --- # Moderation: The statistical model <br/>  -- <br/> .center[.ong[ $$ `\begin{aligned} \text{aggression}_i = \hat{b}_0 + \hat{b}_1\text{video games}_i + \hat{b}_2\text{caunts}_i + \hat{b}_3\text{video games}\times\text{caunts}_i + e_i \end{aligned}` $$ ]] --- # Interactions in the linear model * An interaction term is literally the product of the two variables: .ong[$$\text{interaction} = \text{video_games} × \text{caunts}$$] -- * Interpreting interactions + If the interaction term is significant, we have a significant moderation effect + The parameter estimate (*b*) for the interaction quantifies the size of the interaction effect + The effect of one predictor is stronger at some levels of another predictor + In factorial designs, the effect of one predictor is stronger in certain categories of the other predictor + Simple effects analysis --- background-image: none background-color: #000000 class: no-scribble <video width="100%" height="100%" controls id="my_video"> <source src="media/wii_injuries.mp4" type="video/mp4"> </video> --- # A dangerous example * Injury severity (0-20) measured during video games -- * 40 Participants + 10 = Xbox One kinect (Static game) + 10 = Xbox One kinect (Active game) + 10 = Nintendo Switch (Static game) + 10 = Nintendo Switch (Active game) -- * Variables: + Predictor = Console (Xbox or Switch) + Predictor = Type of game (active or static) + Outcome = injury severity (0 = no injury, 20 = severe injury) -- * The model .center[.ong[ $$ `\begin{aligned} \text{injuries}_i = \hat{b}_0 + \hat{b}_1\text{game}_i + \hat{b}_2\text{console}_i + \hat{b}_3\text{game}\times\text{console}_i + e_i \end{aligned}` $$ ]] --- # Partitioning variance .center[  ] --- # Partitioning variance .center[  ] --- # Partitioning variance .center[  ] --- # Fitting the model * Remember that for *F*-statistics we typically want Type III sums of squares .pull-left[ * The `aov_4()` function from the `afex` package + An easier option + Automatically sets contrasts + Built in interaction plot with `afex_plot()` + But ... no parameter estimates, diagnostic plots, or robust methods ```r xbox_afx <- afex::aov_4(injury ~ game*console + (1|id), data = xbox_tib) ``` ] -- .pull-right[ * Use `lm()` + A trickier option (but you *can* do it) + Manually set contrasts + Easy parameter estimates, diagnostic plots, and robust methods ```r active_vs_static <- c(-1/2, 1/2) switch_vs_xbox <- c(-1/2, 1/2) contrasts(xbox_tib$game) <- active_vs_static contrasts(xbox_tib$console) <- switch_vs_xbox xbox_lm <- lm(injury ~ game*console, data = xbox_tib) car::Anova(xbox_lm, type = 3) ``` ] --- # Overall model summary ```r xbox_afx <- afex::aov_4(injury ~ game*console + (1|id), data = xbox_tib) ``` ```r active_vs_static <- c(-1/2, 1/2) switch_vs_xbox <- c(-1/2, 1/2) contrasts(xbox_tib$game) <- active_vs_static contrasts(xbox_tib$console) <- switch_vs_xbox xbox_lm <- lm(injury ~ game*console, data = xbox_tib) car::Anova(xbox_lm, type = 3) ``` <table> <thead> <tr> <th style="text-align:left;"> </th> <th style="text-align:right;"> Sum Sq </th> <th style="text-align:right;"> Df </th> <th style="text-align:right;"> F value </th> <th style="text-align:right;"> Pr(>F) </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> (Intercept) </td> <td style="text-align:right;"> 3240.0 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 453.147 </td> <td style="text-align:right;"> 0.000 </td> </tr> <tr> <td style="text-align:left;"> game </td> <td style="text-align:right;"> 184.9 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 25.860 </td> <td style="text-align:right;"> 0.000 </td> </tr> <tr> <td style="text-align:left;"> console </td> <td style="text-align:right;"> 25.6 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 3.580 </td> <td style="text-align:right;"> 0.067 </td> </tr> <tr> <td style="text-align:left;"> game:console </td> <td style="text-align:right;"> 36.1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 5.049 </td> <td style="text-align:right;"> 0.031 </td> </tr> <tr> <td style="text-align:left;"> Residuals </td> <td style="text-align:right;"> 257.4 </td> <td style="text-align:right;"> 36 </td> <td style="text-align:right;"> NA </td> <td style="text-align:right;"> NA </td> </tr> </tbody> </table> --- class: center # The data <!-- --> --- class: center # The data <!-- --> --- class: center # The main effect of console <!-- --> --- class: center # The main effect of console <!-- --> --- class: center # The main effect of console <!-- --> --- class: center # The main effect of console <!-- --> --- class: center # The main effect of game <!-- --> --- class: center # The main effect of game <!-- --> --- class: center # The main effect of game <!-- --> --- class: center # The interaction (moderation effect) .pull-left[ <!-- --> ] .pull-right[ ```r broom::tidy(xbox_lm) ``` <table class="table" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> term </th> <th style="text-align:right;"> estimate </th> <th style="text-align:right;"> std.error </th> <th style="text-align:right;"> statistic </th> <th style="text-align:right;"> p.value </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> (Intercept) </td> <td style="text-align:right;"> 9.0 </td> <td style="text-align:right;"> 0.42 </td> <td style="text-align:right;"> 21.29 </td> <td style="text-align:right;"> 0.00 </td> </tr> <tr> <td style="text-align:left;"> game1 </td> <td style="text-align:right;"> 4.3 </td> <td style="text-align:right;"> 0.85 </td> <td style="text-align:right;"> 5.09 </td> <td style="text-align:right;"> 0.00 </td> </tr> <tr> <td style="text-align:left;"> console1 </td> <td style="text-align:right;"> 1.6 </td> <td style="text-align:right;"> 0.85 </td> <td style="text-align:right;"> 1.89 </td> <td style="text-align:right;"> 0.07 </td> </tr> <tr> <td style="text-align:left;background-color: yellow !important;"> game1:console1 </td> <td style="text-align:right;background-color: yellow !important;"> 3.8 </td> <td style="text-align:right;background-color: yellow !important;"> 1.69 </td> <td style="text-align:right;background-color: yellow !important;"> 2.25 </td> <td style="text-align:right;background-color: yellow !important;"> 0.03 </td> </tr> </tbody> </table> ] ??? what does the b = 3.8 mean? (only for the coding scheme I have used) --- # Interpreting interactions ## Console moderating the effect of game .pull-left[ <!-- --> ] --- # Interpreting interactions ## Console moderating the effect of game .pull-left[ <!-- --> ] -- .pull-right[ .ong[ $$ `\begin{aligned} \text{game}_\text{Switch} &= \bar{X}_\text{active, Switch}-\bar{X}_\text{static, Switch} \\ &= 12.90 - 6.70 \\ &= 6.20 \end{aligned}` $$ ] </br> .ong[ $$ `\begin{aligned} \text{game}_\text{Xbox} &= \bar{X}_\text{active, Xbox}-\bar{X}_\text{static, Xbox} \\ &= 9.40 - 7.00 \\ &= 2.40 \end{aligned}` $$ ] </br> .ong[ $$ `\begin{aligned} \text{Interaction} &= \text{game}_\text{Switch} - \text{game}_\text{Xbox} \\ &= 6.2 - 2.40 \\ &= 3.8 \end{aligned}` $$ ] ] --- # Simple effects analysis ## The effect of type of game within consoles ```r emmeans::joint_tests(xbox_lm, "console") ``` ``` ## console = Xbox One: ## model term df1 df2 F.ratio p.value ## game 1 36 4.028 0.0523 ## ## console = Switch: ## model term df1 df2 F.ratio p.value ## game 1 36 26.881 <.0001 ``` * The effect of playing active vs. static games is less significant for the Xbox than the switch. -- * The difference in mean injuries between active and static games for the **Xbox** (*M*<sub>difference</sub> = 2.40) is not significantly different from 0 (*p* = 0.052) [but note the inherent daftness in this statement]. -- * The difference in mean injuries between active and static games for the the Nintendo **Switch** (*M*<sub>difference</sub> = 6.20) is significantly different from 0 (*p* < 0.0001). --- # Interpreting interactions ## Game moderating the effect of console .pull-left[ <!-- --> ] --- # Interpreting interactions ## Game moderating the effect of console .pull-left[ <!-- --> ] -- .pull-right[ .ong[ $$ `\begin{aligned} \text{console}_\text{active} &= \bar{X}_\text{active, Switch}-\bar{X}_\text{active, Xbox} \\ &= 12.90 - 9.4 \\ &= 3.5 \end{aligned}` $$ ] </br> .ong[ $$ `\begin{aligned} \text{console}_\text{static} &= \bar{X}_\text{static, Switch}-\bar{X}_\text{static, Xbox} \\ &= 6.7 - 7.00 \\ &= -0.3 \end{aligned}` $$ ] </br> .ong[ $$ `\begin{aligned} \text{Interaction} &= \text{console}_\text{active} - \text{console}_\text{static} \\ &= 3.5 - (-0.3) \\ &= 3.8 \end{aligned}` $$ ] ] --- # Simple effects analysis ## The effect of console within the type of game ```r emmeans::joint_tests(xbox_lm, "game") ``` ``` ## game = Static: ## model term df1 df2 F.ratio p.value ## console 1 36 0.063 0.8033 ## ## game = Active: ## model term df1 df2 F.ratio p.value ## console 1 36 8.566 0.0059 ``` * The effect of playing Xbox vs. Switch games is less significant for static games than active ones. -- * The difference in mean injuries between Xbox and Switch games that are **static** (*M*<sub>difference</sub> = -0.30) is not significantly different from 0 (*p* = 0.803). -- * The difference in mean injuries between Xbox and Switch games that are **active** (*M*<sub>difference</sub> = 3.50) is significantly different from 0 (*p* = 0.006). --- class: middle .eq_lrge[.warning[ <svg style="height: 1em; top:.04em; position: relative; fill: #CA3E34;" viewBox="0 0 576 512"><path d="M192,320h32V224H192Zm160,0h32V224H352ZM544,112H512a32.03165,32.03165,0,0,0-32,32v16H416V128h32a32.03165,32.03165,0,0,0,32-32V64a32.03165,32.03165,0,0,0-32-32H416a32.03165,32.03165,0,0,0-32,32H352a32.03165,32.03165,0,0,0-32,32v32H256V96a32.03165,32.03165,0,0,0-32-32H192a32.03165,32.03165,0,0,0-32-32H128A32.03165,32.03165,0,0,0,96,64V96a32.03165,32.03165,0,0,0,32,32h32v32H96V144a32.03165,32.03165,0,0,0-32-32H32A32.03165,32.03165,0,0,0,0,144V288a32.03165,32.03165,0,0,0,32,32H64v32a32.03165,32.03165,0,0,0,32,32h32v64a32.03165,32.03165,0,0,0,32,32h80a32.03165,32.03165,0,0,0,32-32V416a32.03165,32.03165,0,0,0-32-32h96a32.03165,32.03165,0,0,0-32,32v32a32.03165,32.03165,0,0,0,32,32h80a32.03165,32.03165,0,0,0,32-32V384h32a32.03165,32.03165,0,0,0,32-32V320h32a32.03165,32.03165,0,0,0,32-32V144A32.03165,32.03165,0,0,0,544,112ZM416,64h32V96H416ZM128,96V64h32V96ZM240,448H160V384h32v32h48Zm176,0H336V416h48V384h32ZM544,288H480v64H96V288H32V144H64V256H96V192h96V96h32v64H352V96h32v96h96v64h32V144h32Z"/></svg> Repeat the following mantra: **"It is never sensible to interpret main effects in the presence of a significant interaction effect."** ]] --- # Effect sizes .pull-left[ ## Raw effect size * We've seen that the difference in the mean number of injuries when playing active games compared to static ones on the Switch (6.20) is 3.8 injuries more than for the Xbox (2.40). * Alternatively, when playing Switch compared to Xbox there were 3.8 more injuries for active games compared to static ones. ] -- .pull-right[ ## Partial Omega squared `\(\omega_p^2\)` ```r xbox_afx |> effectsize::omega_squared(ci = 0.95) ``` ```r car::Anova(xbox_lm, type = 3) |> effectsize::omega_squared(ci = 0.95) ``` * The interaction explains 9% of the variance in injuries not attributable to other predictors ] <table> <thead> <tr> <th style="text-align:left;"> Parameter </th> <th style="text-align:right;"> Omega2_partial </th> <th style="text-align:right;"> CI </th> <th style="text-align:right;"> CI_low </th> <th style="text-align:right;"> CI_high </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> game </td> <td style="text-align:right;"> 0.38 </td> <td style="text-align:right;"> 0.95 </td> <td style="text-align:right;"> 0.18 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> console </td> <td style="text-align:right;"> 0.06 </td> <td style="text-align:right;"> 0.95 </td> <td style="text-align:right;"> 0.00 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> game:console </td> <td style="text-align:right;"> 0.09 </td> <td style="text-align:right;"> 0.95 </td> <td style="text-align:right;"> 0.00 </td> <td style="text-align:right;"> 1 </td> </tr> </tbody> </table> ??? These values show that the interaction (the effect we care about) explains 9% of the variance in injuries not attributable to other predictors. --- # Diagnostic plots .pull-left[ ```r library(ggfortify) ggplot2::autoplot(xbox_lm, which = c(1, 3, 2, 4), colour = "#5c97bf", smooth.colour = "#ef4836", alpha = 0.5, size = 1) + theme_minimal() ``` ] .pull-right[ <!-- --> ] --- # Robust models * If you use `lm()` you can fit any of the robust models we have discussed. ## Example: HC4 standard errors ```r parameters::model_parameters(xbox_lm, vcov = "HC4", digits = 3) ``` <table> <thead> <tr> <th style="text-align:left;"> Parameter </th> <th style="text-align:right;"> Coefficient </th> <th style="text-align:right;"> SE </th> <th style="text-align:right;"> CI </th> <th style="text-align:right;"> CI_low </th> <th style="text-align:right;"> CI_high </th> <th style="text-align:right;"> t </th> <th style="text-align:right;"> df_error </th> <th style="text-align:right;"> p </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> (Intercept) </td> <td style="text-align:right;"> 9.0 </td> <td style="text-align:right;"> 0.42 </td> <td style="text-align:right;"> 0.95 </td> <td style="text-align:right;"> 8.14 </td> <td style="text-align:right;"> 9.86 </td> <td style="text-align:right;"> 21.29 </td> <td style="text-align:right;"> 36 </td> <td style="text-align:right;"> 0.00 </td> </tr> <tr> <td style="text-align:left;"> game1 </td> <td style="text-align:right;"> 4.3 </td> <td style="text-align:right;"> 0.85 </td> <td style="text-align:right;"> 0.95 </td> <td style="text-align:right;"> 2.59 </td> <td style="text-align:right;"> 6.01 </td> <td style="text-align:right;"> 5.09 </td> <td style="text-align:right;"> 36 </td> <td style="text-align:right;"> 0.00 </td> </tr> <tr> <td style="text-align:left;"> console1 </td> <td style="text-align:right;"> 1.6 </td> <td style="text-align:right;"> 0.85 </td> <td style="text-align:right;"> 0.95 </td> <td style="text-align:right;"> -0.11 </td> <td style="text-align:right;"> 3.31 </td> <td style="text-align:right;"> 1.89 </td> <td style="text-align:right;"> 36 </td> <td style="text-align:right;"> 0.07 </td> </tr> <tr> <td style="text-align:left;"> game1:console1 </td> <td style="text-align:right;"> 3.8 </td> <td style="text-align:right;"> 1.69 </td> <td style="text-align:right;"> 0.95 </td> <td style="text-align:right;"> 0.37 </td> <td style="text-align:right;"> 7.23 </td> <td style="text-align:right;"> 2.25 </td> <td style="text-align:right;"> 36 </td> <td style="text-align:right;"> 0.03 </td> </tr> </tbody> </table> --- background-image: none background-color: #000000 class: no-scribble <video width="100%" height="100%" controls id="my_video"> <source src="media/lazinc_durt_the_time_is_here.mp4" type="video/mp4"> </video> --- class: center, middle, title-slide, inverse layout: false ## The beer goggles effect --- # A science reflecting art example .pull-left[ * The beer goggles effect: subjective perceptions of physical attractiveness become inaccurate after drinking alcohol * Chen et al., (2014)<sup>1</sup> + Alcohol consumption reduces accuracy in symmetry judgements + Symmetric faces have been shown to be rated as more attractive. + If the beer-goggles effect is driven by alcohol impairing symmetry judgements then you’d expect a stronger effect for unattractive (asymmetric) faces than attractive (symmetric) ones * Fictional data but matches Chen et al. findings ] .pull-right[ .center[  ] ] .footnote[ Chen, et al., (2014). The moderating effect of stimulus attractiveness on the effect of alcohol consumption on attractiveness ratings. Alcohol and Alcoholism, 49, 515–519. [https://doi.org/10.1093/alcalc/agu026](https://doi.org/10.1093/alcalc/agu026) ] --- # Study design .pull-left[ * 48 Participants (8 per group) * Predictor: **Alcohol** + **Placebo** group: 500 ml of alcohol-free beer + **Low-dose** group: 500 ml of beer (4% ABV); + **High-dose** group: 500 ml of beer (7% ABV). * Predictor: **Face type** + Rated 50 **unattractive** (asymmetric) faces + Rated 50 **attractive** (symmetric) faces * Outcome: + Median rating of the 50 photos on a scale from 0 (pass me a paper bag) to 10 (pass me their phone number) ] .pull-right[ .center[  ] ] --- # The data .center[ <!-- --> ] --- # Overall model summary ```r goggles_afx <- afex::aov_4(attractiveness ~ facetype*alcohol + (1|id), data = goggles_tib) ``` ```r alcohol_vs_none <- c(-2/3, 1/3, 1/3) low_vs_high <- c(0, -1/2, 1/2) contrasts(goggles_tib$alcohol) <- cbind(alcohol_vs_none, low_vs_high) contrasts(goggles_tib$facetype) <- c(-1/2, 1/2) goggles_lm <- lm(attractiveness ~ facetype*alcohol, data = goggles_tib) car::Anova(goggles_lm, type = 3) ``` <table> <thead> <tr> <th style="text-align:left;"> </th> <th style="text-align:right;"> Sum Sq </th> <th style="text-align:right;"> Df </th> <th style="text-align:right;"> F value </th> <th style="text-align:right;"> Pr(>F) </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> (Intercept) </td> <td style="text-align:right;"> 1541.333 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1125.843 </td> <td style="text-align:right;"> 0.000 </td> </tr> <tr> <td style="text-align:left;"> facetype </td> <td style="text-align:right;"> 21.333 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 15.583 </td> <td style="text-align:right;"> 0.000 </td> </tr> <tr> <td style="text-align:left;"> alcohol </td> <td style="text-align:right;"> 16.542 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 6.041 </td> <td style="text-align:right;"> 0.005 </td> </tr> <tr> <td style="text-align:left;background-color: yellow !important;"> facetype:alcohol </td> <td style="text-align:right;background-color: yellow !important;"> 23.292 </td> <td style="text-align:right;background-color: yellow !important;"> 2 </td> <td style="text-align:right;background-color: yellow !important;"> 8.507 </td> <td style="text-align:right;background-color: yellow !important;"> 0.001 </td> </tr> <tr> <td style="text-align:left;"> Residuals </td> <td style="text-align:right;"> 57.500 </td> <td style="text-align:right;"> 42 </td> <td style="text-align:right;"> NA </td> <td style="text-align:right;"> NA </td> </tr> </tbody> </table> --- # Simple effects: facetype within alcohol group ``` ## alcohol = Placebo: ## model term df1 df2 F.ratio p.value ## facetype 1 42 24.150 <.0001 ## ## alcohol = Low dose: ## model term df1 df2 F.ratio p.value ## facetype 1 42 7.715 0.0081 ## ## alcohol = High dose: ## model term df1 df2 F.ratio p.value ## facetype 1 42 0.730 0.3976 ``` --- # Simple effects: facetype within alcohol group .center[ <!-- --> ] --- # Simple effects: facetype within alcohol group .center[ <!-- --> ] --- # Simple effects: alcohol within facetype ``` ## facetype = Unattractive: ## model term df1 df2 F.ratio p.value ## alcohol 2 42 14.335 <.0001 ## ## facetype = Attractive: ## model term df1 df2 F.ratio p.value ## alcohol 2 42 0.213 0.8090 ``` --- # Simple effects: alcohol within facetype .center[ <!-- --> ] --- # Simple effects: alcohol within facetype .center[ <!-- --> ] --- # Diagnostic plots .pull-left[ ```r library(ggfortify) ggplot2::autoplot(goggles_lm, which = c(1, 3, 2, 4), colour = "#5c97bf", smooth.colour = "#ef4836", alpha = 0.5, size = 1) + theme_minimal() ``` ] .pull-right[ <!-- --> ] --- # Summary * Factorial designs: two or more predictor variables are manipulated * Moderation: Where the effect of one predictor differs at levels of another * Testing moderation (interaction effects) + The model: a linear model in which predictors are entered as well as their interaction + Interpret interactions using plots or simple effects analysis, which quantifies the effect of one predictor at each level of another + Test model assumptions with diagnostic plots + Fit robust variants * Main effects + Show the effect of one predictor variable collapsing across levels of other predictors + In the presence of a significant interaction main effects are uninteresting