class: center, middle, inverse, title-slide .title[ # Lecture 10: Mediation & Moderation ] .subtitle[ ##
Same same but different
] .author[ ### Dr Danielle Evans ] .date[ ### 22 March 2023 ] --- <style type="text/css"> a { color: #f77b00; } </style> ## Overview **Part 1: Mediation Analysis - The How...** - What is it? + Total effects, direct effects, & indirect effects - How do we use it? - Reporting it in APA style <br> **Part 2: Moderation Analysis - The When...** - What is it? + Main effects & interactions - How do we use it? + Grand mean centring - Reporting it in APA style --- ## Mediation - **Mediation** occurs when the relationship between a **predictor** and an **outcome**, can be **explained** by their relationship to a third variable: the **mediator** - Previously, we've looked at simple relationships between a **predictor** and an **outcome**: <br><br><br><br><br> .center[ <img src="data:image/png;base64,#img/lm.png" width="70%" /> ] --- ## Mediation - With **mediation**, we're looking at **how** variables are related, we're attempting to further our understanding by **explaining** the relationship between the **predictor** and the **outcome** - we're interested in **pathways**: <br><br> .center[ <img src="data:image/png;base64,#img/med.png" width="70%" /> ] <br> - Change in the **predictor** = change in the **mediator** = change in the **outcome** --- ## Mediation - So, we can extend our simpler model between **predictor** and **outcome**: <br> .center[ <img src="data:image/png;base64,#img/new1.png" width="70%" /> ] <br> - To examine the **pathways** that might **explain** that relationship: .center[ <img src="data:image/png;base64,#img/new2.png" width="70%" /> ] --- ## Mediation - We can use a **mediation model** whenever we use a **linear model** + A mediation is essentially a few linear models! - Can be used in **correlational** or **experimental** designs - The mediator used and the pathways should be **theoretically driven** + We can investigate further to check if our decisions are appropriate - But we need to be careful with our interpretations & conclusions: + With **mediation** we're implying there is a **directional path** between our variables, but without a **causal design**, we cannot infer causality from our results! <br> <div class="sweat" style="font-size:90%"> <p><b>Easy Error!</b> Even in a mediation, <b>correlation does not equal causation</b>!! </p> </div> --- ## Mediation: Pathways - We start with the **Total Effect**, which is the simple relationship between **predictor** and **outcome**, where we're not adjusting for any other variables: <br><br> .center[ <img src="data:image/png;base64,#img/te.png" width="70%" /> ] <br> <br> <br> - It might help to think of it as being the overall relationship between your two variables... --- ## Mediation: Pathways - We then partition this **Total Effect** into: + An **Indirect Effect** which is the effect of the **predictor** on the **outcome**, through the **mediator** + & a **Direct Effect** which is the effect of the **predictor** on the **outcome**, adjusting for the **mediator** .center[ <img src="data:image/png;base64,#img/ef.png" width="60%" /> ] --- ## Mediation: Pathways <br> .pull-left[ <img src="data:image/png;base64,#img/P1.png" width="80%" /> ] .pull-right[ <br> <br> <br> <br> <br> <br> <img src="data:image/png;base64,#img/PF1.png" width="100%" /> ] --- ## Mediation: Pathways <br> .pull-left[ <img src="data:image/png;base64,#img/P2.png" width="80%" /> ] .pull-right[ <br> <br> <br> <img src="data:image/png;base64,#img/PF2.png" width="100%" /> ] --- ## Mediation: Pathways <br> .pull-left[ <img src="data:image/png;base64,#img/P3.png" width="80%" /> ] .pull-right[ <br> <br> <br> <img src="data:image/png;base64,#img/PF3.png" width="100%" /> ] --- ## Mediation: Partitions <br> .center[ <img src="data:image/png;base64,#img/flooow.png" width="85%" /> ] --- ## Mediation: Partitions - The terms for each of these pathways can feel counter-intuitive... - The **Total Effect** is comprised of the **Indirect Effect** AND the **Direct Effect** - Even though we call it the **Total Effect**, it's still just the simple relationship between **predictor** and **outcome** - we haven't accounted for any other variables - By adding in a mediator, we can see how much of this **Total Effect** is a **Direct Effect** of our predictor, and how much can be explained by our mediator (i.e., the **Indirect Effect**) <br> <br> <br> <div class="sweat" style="font-size:90%"> <p><b>Easy Error!</b> People often get 'Direct Effect' & 'Total Effect' muddled up!! The total effect does not adjust for any other variables - the direct effect <i>does..</i></p> </div> ??? the direct effect adjusts!!!! --- ## A Mathsy Mediation Example - **SES** is a predictor of **children's maths attainment** (Evans et al., 2018, 2020a, 2020b, 2020c) - There are many possible mechanisms underlying this relationship, which is what we are trying to uncover with mediation - So, starting with the simple relationship between predictor and outcome, we have the **Total Effect** of SES on children's maths ability: <br> .center[ <img src="data:image/png;base64,#img/ma1.png" width="75%" /> ] <br> - We can then include a mediator in our model to see *how* SES is related to children's maths ability, and whether this relationship can be explained by another variable... --- ## A Mathsy Mediation Example - You should use theory and research to decide what the mediator might be in this scenario - For today, **parental involvement in educational activities** seems to be a sensible mediator - And so our **mediation model** is: <div style="line-height:5%;"> <br> </div> .center[ <img src="data:image/png;base64,#img/med3.png" width="75%" /> ] <div style="line-height:5%;"> <br> </div> - We're testing whether SES predicts maths ability, and if/how much of this relationship can be explained by parental involvement in education --- ## Doing a Mediation - Step 1. Does the predictor predict the outcome (**Total Effect**) + We could theoretically test this with a simple regression in **R** <div style="line-height:65%;"> <br> </div> <br> <br> <br> <br> .center[ <img src="data:image/png;base64,#img/ma1.png" width="75%" /> ] --- ## Doing a Mediation - Step 2a: Separate the **Total Effect** into an **Indirect Effect** (path *ab*) by first working out **path** **_a_**: <br> .center[ <img src="data:image/png;base64,#img/m1.png" width="75%" /> ] - We could theoretically test this with another simple regression in **R** <div style="line-height:40%;"> <br> </div> <div class="tu" style="font-size:90%"> <p><b>Top Tip!</b> The Indirect Effect is the product of paths <i>a</i> and <i>b</i> - we can just multiply the estimates together to get the Indirect Effect) </p> </div> --- ## Doing a Mediation - Step 2b: Separate the **Total Effect** into an **Indirect Effect** (path *ab*) by first working out path *a*, and then **path** **_b_**, adjusting for the predictor: <br> .center[ <img src="data:image/png;base64,#img/ad.png" width="75%" /> ] - We could test this with a multiple regression in **R** where we adjust for our predictor + We need to adjust for the predictor because if we don't control for it the outcome and the mediator could be correlated just because our predictor is related to them both --- ## Doing a Mediation - Step 3: See whether our predictor still predicts our outcome **path** **_c_** (the **Direct Effect**), after accounting for the Indirect Effect: <br> .center[ <img src="data:image/png;base64,#img/med3.png" width="75%" /> ] - We could test this with a multiple regression in **R** where we adjust for our mediator --- ## Mediation in R - To run a mediation in R we use the `sem()` function from the `lavaan` package + The code looks pretty scary, but there's no reason to be afraid! ```r # step 1: define the model my_mod <- 'outcome ~ c*predictor + b*mediator mediator ~ a*predictor indirect_effect := a*b total_effect := c + (a*b) ' # step 2: fit the model with FIML and robust SEs my_fit <- lavaan::sem(my_mod, data = my_data, missing = "FIML", estimator = "MLR") # step 3: summarize the model broom::glance(my_fit) broom::tidy(my_fit, conf.int = TRUE) ``` <div style="line-height:1%;"> <br> </div> <div class="sweat" style="font-size:90%"> <p><b>Don't Panic!</b> We'll go over the code in the discovr_10 tutorial & in the skills labs!</p> </div> --- ## Mathsy Mediation in R - Our mathsy mediation model in **R** with ses (predictor), parent_inv (mediator), and maths_att (outcome): ```r # step 1: define the model my_mod <- 'maths_att ~ c*ses + b*parent_inv parent_inv ~ a*ses indirect_effect := a*b total_effect := c + (a*b) ' # step 2: fit the model with FIML and robust SEs my_fit <- lavaan::sem(my_mod, data = my_data, missing = "FIML", estimator = "MLR") # step 3: summarize the model broom::glance(my_fit) broom::tidy(my_fit, conf.int = TRUE) ``` --- ## Mathsy Mediation in R - We can see the **parameter estimates** (unstandardized betas) for each pathway in the **estimate** column below: ```r # step 3: summarize the model broom::tidy(my_fit, conf.int = TRUE) ``` <table class="table" style="font-size: 14px; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;background-color: #003b49; color: #fff; !important;"> term </th> <th style="text-align:left;background-color: #003b49; color: #fff; !important;"> op </th> <th style="text-align:left;background-color: #003b49; color: #fff; !important;"> label </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> estimate </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> std.error </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> statistic </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> p.value </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> conf.low </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> conf.high </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> maths_att ~ ses </td> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> ~ </td> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> c </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 4.071 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0.455 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 8.951 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 3.179 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 4.962 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> maths_att ~ parent_inv </td> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> ~ </td> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> b </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 71.906 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 6.394 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 11.245 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 59.373 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 84.439 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> parent_inv ~ ses </td> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> ~ </td> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> a </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0.024 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0.004 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 6.731 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0.017 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0.031 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> maths_att ~~ maths_att </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> ~~ </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 343190.490 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 23717.969 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 14.470 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 0 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 296704.125 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 389676.854 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> parent_inv ~~ parent_inv </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> ~~ </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 27.000 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 1.884 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 14.331 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 0 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 23.307 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 30.692 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> ses ~~ ses </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> ~~ </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 4713.358 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 0.000 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 4713.358 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 4713.358 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> maths_att ~1 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> ~1 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 2077.997 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 325.089 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 6.392 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 0 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 1440.834 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 2715.160 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> parent_inv ~1 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> ~1 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 50.027 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 0.848 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 58.991 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 0 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 48.365 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 51.689 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> ses ~1 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> ~1 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;"> </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> -254.129 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> 0.000 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> -254.129 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;"> -254.129 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> indirect_effect := a*b </td> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> := </td> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> indirect_effect </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 1.727 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0.330 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 5.240 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 1.081 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 2.373 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> total_effect := c+(a*b) </td> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> := </td> <td style="text-align:left;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> total_effect </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 5.798 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0.472 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 12.281 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 0 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 4.873 </td> <td style="text-align:right;font-weight: bold;background-color: #b6ccd1; color: #black; !important;"> 6.724 </td> </tr> </tbody> </table> --- ## Building our Model - We can use the estimates (betas) and the label (the path) to build a diagram of our model: <br> .center[ <img src="data:image/png;base64,#img/out.png" width="85%" /> ] <br><br><br> <p style="text-align:left; font-size:50%">*these results are fictional</p> --- ## Interpreting Results We can interpret the __*b*__s in the same way as we would with a linear model: + Path __*a*__ tells us the effect for the predictor on the mediator + Path __*b*__ tells us the effect for the mediator on the outcome adjusting for the predictor + Path __*c*__ (**Direct Effect**) tells us the effect for the predictor on the outcome adjusting for the mediator + The **Indirect Effect** tells us whether there is a mediation + The **Total Effect** tells us the effect of the predictor on the outcome, NOT adjusting for the mediator --- ## Interpreting Results - To see if we have a significant mediation, we look at the size, the confidence interval, and the *p*-value of the **Indirect Effect** + If the confidence intervals do not contain 0 and if the *p*-value is less than .05 then we can say there is a **mediation effect** - We can have different types of mediation: + **Partial mediation** is when the Direct Effect (*c*) is reduced but still significant - there's both an indirect and direct effect of the predictor on the outcome + **Full mediation** is when Direct Effect (*c*) reduced to non-significance - the effect of the predictor on the outcomes goes entirely through the mediator - It's generally best to avoid thinking of mediations as being full or partial when based on *p*-values because of the all-or-nothing conclusions drawn from significance tests, instead, it's better to ask: **is the size of the mediation effect substantial enough to care about it?** <!-- - We can use the **index of mediation** as a way of standardising the *b* for the **Indirect Effect** to compare it across studies and measures, or we can look in the **std.all** column of the output for the standardised estimates --> --- ## Interpreting Results - So, based on our mathsy mediation: <br> .center[ <img src="data:image/png;base64,#img/out.png" width="85%" /> ] - SES predicts maths ability directly (*b* = 4.07) - SES predicts maths ability indirectly through parental involvement (*b* = 1.73) <br> <p style="text-align:left; font-size:50%">*these results are fictional</p> --- ## Reporting Mediations - To report the results of our **mediation** in **APA style**, we could write something like the below, along with a diagram displaying the **parameter estimates** for each effect/pathway: **"There was a significant indirect effect of SES, on children's maths attainment, through parental involvement in educational activities, *b* = 1.73, 95% CI [1.08, 2.37], *p* < .001."** .center[ <img src="data:image/png;base64,#img/res.png" width="65%" /> ] <div style="line-height:1%;"> <br> </div> <div class="swr" style="font-size:90%"> <p><b>Pet Peeve!</b> Your result is NOT 'insignificant' - it is <b>nonsignificant!!</b> </p> </div> --- ## Moderation - So we've looked at *how* variables are related with **mediation** - With **moderation** we're looking at *when* variables are related - With **moderation** we can investigate whether the effect of our predictor is the same for all people or whether it differs under different conditions depending on the value of another variable – the **moderator** - Differences could be the **presence** of an effect, the **size** of the effect, or the **direction** of the effect <br> .center[ <img src="data:image/png;base64,#img/mod1.png" width="65%" /> ] --- ## Moderation - A **moderator** is a variable that affects the relationship between two others - it **modifies** it - Can be used in **correlational** or **experimental** designs with continuous or categorical variables - It's mathematically the same as the **interactions** we encountered in **Discovering Statistics** last term - we run a moderation in the same way as a linear model with 3 predictors: <br> .center[ <img src="data:image/png;base64,#img/mod2.png" width="65%" /> ] --- ## Moderation - The key conceptual difference is that you are implying a variable (the **moderator**) alters the relationship between the other two variables - The moderator chosen should be **theoretically driven** - the same as a mediation - However, the same issues around causation apply here too - We are implying a directional relationship (i.e., the moderator modifies the relationship) but **correlation does not equal causation** unless you have a causal design <br> <br> <br> <div class="sweat" style="font-size:90%"> <p><b>Easy Error!</b> Predictors and moderators are mathematically the same in our model - the only differences are conceptual!</p> </div> --- ## A Mathsy Moderation Example - **Parental maths anxiety** is a predictor of **children's maths anxiety** - But research suggests that when parents help with maths homework, the effects might be **different** for parents experiencing maths anxiety, and that under certain conditions helping might actually be harmful - One idea is that when parents have maths anxiety, helping with maths homework can increase their **child's maths anxiety**, and parents that don't help have a less negative impact - So, our conceptual model is: .center[ <img src="data:image/png;base64,#img/mod4.png" width="70%" /> ] ??? we're hypothesising that the relationship between parental maths anx and childrens maths anx, changes due to how many hours parents help with hw could be presence, size, or direction --- ## A Mathsy Moderation Example - We can run a linear model with 3 predictors to test this idea - Where we have two **main effects** and one **interaction effect** <div style="line-height:5%;"> <br> </div> .center[ <img src="data:image/png;base64,#img/mod3.png" width="70%" /> ] <div style="line-height:5%;"> <br> </div> - We must include the **main effects** for both the predictor and moderator otherwise the interaction and main effects are confounded & a significant interaction can’t be interpreted - If the interaction is significant, then that is evidence of moderation --- ## The Catch - When using a **linear model** with multiple predictors, each of the effects (*b*s) are interpreted when the other variables in the model are 0 - So if we had parental maths anxiety and parental homework help as predictors in a non-moderated linear model, we would interpret the *b* of parental maths anxiety when parental homework help is at 0, and vice versa - In some scenarios this interpretation isn't problematic because 0 is a plausible and meaningful score + I.e., a child *could* get a score of 0 on our maths anxiety measure meaning they have no anxiety at all - But often it doesn't make sense for a predictor to be interpreted in this way because a score of 0 isn't possible or doesn't make sense + Imagine we measured parental anxiety by measuring heart rate, here, a score of 0 would indicate something is very wrong with our participant - The interaction term in our moderation means that the *b*s for the main effects are usually uninterpretable... ??? with an interaction, we're saying that the effect of our predictor changes, at different levels of our moderator, so if we have an interaction effect, the beta we get for the predictors wil change depending on the values of the other variables in our model When there is no interaction, this doesn’t matter because the b parameter doesn’t change at different levels of our moderator --- ## Grand Mean Centring - So, to make interpretation easier, we **centre** our variables by transforming them into deviations around a fixed point - in **grand mean centring** this 'fixed point' is the overall mean of that measure - We can then interpret our effects at average levels of the other variable - This applies to our **predictor** and **moderator** only + We don't need to centre our outcome because we interpret the effects of our predictors at specific values of our *b*s, with grand mean centring, this 'specific value' becomes the mean of the other variable(s) - Centring is super easy to do in **R** with **mutate()** and **mean()**, we're just taking the overall mean away from each participants individual score - we'll go over the code in your skills lab this week! <div style="line-height:5%;"> <br> </div> <div class="sweat" style="font-size:90%"> <p><b>Easy Error!</b> You can use centring in any model where it makes sense, we <b>need</b> to use it in moderations for interpretation but we can use it elsewhere too!</p> </div> --- ## Grand Mean Centring - So what happens is that our data now **shifts** to have a **mean of 0** but the overall distribution stays the same: <br> .center[ <img src="data:image/png;base64,#img/dist.png" width="75%" /> ] --- ## Mathsy Moderation in R - To do a moderation in R, we'll be using the same code as we have done before with a linear model: ```r # step 1: fit model with our centred variables math_anx_lm <- lm(child_maths_anx ~ parent_maths_anx*parent_hw_help, data = ma_data) # step 2: summarize the model with robust SEs broom::tidy(math_anx_lm, conf.int = TRUE) parameters::model_parameters(math_anx_lm, robust = TRUE, vcov.type = "HC4", digits = 3) ``` --- ## Mathsy Moderation in R - Our results would look like this where we have **2x main effects**, and **1x interaction effect**: <div style="line-height:50%;"> <br> </div> <table class="table" style="font-size: 16px; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;background-color: #003b49; color: #fff; !important;"> term </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> estimate </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> std.error </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> statistic </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> p.value </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> conf.low </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;"> conf.high </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;"> (Intercept) </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 40.598 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 0.310 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 130.958 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 0 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 39.988 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 41.207 </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;"> parent_maths_anx </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 0.507 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 0.018 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 28.099 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 0 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 0.471 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 0.542 </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;"> parent_hw_help </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> -166.756 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 39.805 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> -4.189 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 0 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> -245.052 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> -88.460 </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;"> parent_maths_anx:parent_hw_help </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 23.955 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 3.962 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 6.046 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 0 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 16.161 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;"> 31.749 </td> </tr> </tbody> </table> <div style="line-height:50%;"> <br> </div> - If our interaction is significant then we have a moderation effect, it would also mean we're no longer that interested in the lower-order/main effects because they **change at different levels of our moderator** <div style="line-height:5%;"> <br> </div> <div class="tu" style="font-size:90%"> <p><b>Top Tip!</b> <b>Higher-order effects</b> refer to interactions, and <b>lower-order effects</b> refer to the main effects!</p> </div> <p style="text-align:left; font-size:50%">*these results are fictional</p> --- ## Probing Interactions - If we find a significant moderation effect, we need to follow it up to understand *how* the relationship between the predictor and the outcome changes at different values of the moderator + Remember that a moderation can occur from differences in effect **size**, **direction**, or **presence**... + Without probing the interaction further, we don't know what's actually happening in this relationship - We can use two techniques to follow up a significant interaction effect: + **Simple slopes analysis** + **Johnson-Neyman interval** - These tell us the coefficient for our predictor (i.e., the effect it has on our outcome) at different values of our moderator --- ## Simple Slopes Analysis - Here we compare the relationship between our predictor and our outcome, at low, mean, and high levels of our moderator (using SDs) - We get models of parental maths anxiety and children's maths anxiety at **low** parental homework help (-1 SD), **mean** parental homework help, and **high** parental homework help (+1 SD) .pull-left[ - We can then look at the **significance** of these slopes, the **value/size** of our *b*, and the **direction** to see how the relationship between parental maths anxiety and children's maths anxiety changes at different levels of our moderator parental homework help ] .pull-right[ <img src="data:image/png;base64,#img/slopes.png" width="100%" /> ] --- ## Simple Slopes Analysis - The interactions plot displays this same information much nicer: .pull-left[ <img src="data:image/png;base64,#index_files/figure-html/unnamed-chunk-39-1.png" width="100%" /> ] .pull-right[ + When homework help is high (+1 SD from mean), parental maths anxiety is strongly positively related to children's anxiety scores + At the mean of homework help, parental maths anxiety is positively related related to children's anxiety scores + When homework help is low (-1SD), parental maths anxiety is more weakly positively related to children's anxiety scores ] --- ## Johnson-Neyman Interval .pull-left[ - Instead of only looking at low, mean, and high values of our moderator, we can look at many values of it with the **Johnson-Neyman Interval** - This interval estimates the model of our predictor and outcome, at lots of different values of our moderator - We get a 'zone of significance', i.e., the interval in which the relationship between our predictor and outcome is significant ] .pull-right[ <p style="text-align:left; font-size:75%">JOHNSON-NEYMAN INTERVAL<br> When parent_hw_help is OUTSIDE the interval [-0.03, -0.02], the slope of parent_hw_help is p < .05.</p> <img src="data:image/png;base64,#index_files/figure-html/unnamed-chunk-41-1.png" width="90%" /> ] - The black line is where the relationship between our predictor and outcome is 0, above it is positive, below it is negative --- ## Reporting Moderations - There's 3 key pieces of information to report for a moderation: the **main effects**, the **interaction effect**, and then a **simple slopes analysis**/**Johnson-Neyman interval** if a moderation was found: <p style="font-size:75%"> "At the mean of parental homework help, there was a significant positive relationship between parental maths anxiety and child maths anxiety, <i>b</i> = 0.51, <i>t</i> = 28.10, <i>p</i> < .001, 95% CI [0.47, 0.54]. At the mean of parental maths anxiety, there was a significant negative relationship between parental homework help and child maths anxiety, <i>b</i> = -166.75, <i>t</i> = -4.19, <i>p</i> < .001, 95% CI [-245.05, -88.46]. <br><br> The interaction between parental maths anxiety and parental homework help was significantly related to child maths anxiety, <i>b</i> = 23.96, <i>t</i> = 6.05, <i>p</i> < .001, 95% CI [16.16, 31.75]. <br><br> When parental homework help is low (-1 SD), there is a significant positive relationship between parental maths anxiety and child maths anxiety, <i>b</i> = 0.34, 95% CI [0.27, 0.40 ], <i>t</i> = 9.97, <i>p</i> < .001. At the mean of parental homework help, there is a significant positive relationship between parental maths anxiety and child maths anxiety, <i>b</i> = 0.51, 95% CI [0.47, 0.54 ], <i>t</i> = 30.04, <i>p</i> < .001. When parental homework help is high (+1 SD), there is a significant positive relationship between parental maths anxiety and child maths anxiety, <i>b</i> = 0.68, 95% CI [0.62, 0.73 ], <i>t</i> = 22.6, <i>p</i> < .001." </p> <div style="line-height:5%;"> <br> </div> <div class="tu" style="font-size:90%"> <p><b>Top Tip!</b> If we're using grand mean centring, the effects should be interpreted at the mean values of the variables!</p> </div> --- ## Reporting Moderations - We could also include a table of our results, something like this: <br> .center[ <table class="table" style="font-size: 16px; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;background-color: white; color: #black; !important;"> Predictor </th> <th style="text-align:right;background-color: white; color: #black; !important;"> b </th> <th style="text-align:right;background-color: white; color: #black; !important;"> SE B </th> <th style="text-align:right;background-color: white; color: #black; !important;"> t </th> <th style="text-align:left;background-color: white; color: #black; !important;"> p </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;background-color: white; color: #black; !important;"> Intercept </td> <td style="text-align:right;background-color: white; color: #black; !important;"> 40.598 </td> <td style="text-align:right;background-color: white; color: #black; !important;"> 0.310 </td> <td style="text-align:right;background-color: white; color: #black; !important;"> 130.958 </td> <td style="text-align:left;background-color: white; color: #black; !important;"> <.001 </td> </tr> <tr> <td style="text-align:left;background-color: white; color: #black; !important;"> Parental Maths Anxiety </td> <td style="text-align:right;background-color: white; color: #black; !important;"> 0.507 </td> <td style="text-align:right;background-color: white; color: #black; !important;"> 0.018 </td> <td style="text-align:right;background-color: white; color: #black; !important;"> 28.099 </td> <td style="text-align:left;background-color: white; color: #black; !important;"> <.001 </td> </tr> <tr> <td style="text-align:left;background-color: white; color: #black; !important;"> Parental Homework Help </td> <td style="text-align:right;background-color: white; color: #black; !important;"> -166.756 </td> <td style="text-align:right;background-color: white; color: #black; !important;"> 39.805 </td> <td style="text-align:right;background-color: white; color: #black; !important;"> -4.189 </td> <td style="text-align:left;background-color: white; color: #black; !important;"> <.001 </td> </tr> <tr> <td style="text-align:left;background-color: white; color: #black; !important;"> Parental Maths Anxiety x Parental Homework Help </td> <td style="text-align:right;background-color: white; color: #black; !important;"> 23.955 </td> <td style="text-align:right;background-color: white; color: #black; !important;"> 3.962 </td> <td style="text-align:right;background-color: white; color: #black; !important;"> 6.046 </td> <td style="text-align:left;background-color: white; color: #black; !important;"> <.001 </td> </tr> </tbody> </table> ] --- ## Summary - **Mediation** occurs when the relationship between two variables can be explained (either in part or in full), by another variable - We start with a total effect (the simple relationship between predictor and outcome), and we partition this into a direct effect & an indirect effect - We can test for mediation by investigating the size of an indirect effect - if the effect is significant and the CIs don't include 0, we assume a mediation effect does exist - **Moderation** occurs when the relationship between two variables changes as a function of a third variable - We should centre our predictor and moderator before analysis to make the *b*s interpretable - If a moderation effect is found we can use simple slopes analysis to explore the relationship between our predictor and outcome, at different levels of our moderator - & finally, **correlation doesn't equal causation!!** --- ## *That's all - happy modelling!* <br> <br> .center[ <iframe src="https://giphy.com/embed/k83fBZ8YfpGLzJwXvx" width="576" height="319" frameBorder="0" class="giphy-embed" allowFullScreen></iframe><p></p> <br> [Give session feedback here!](https://forms.gle/ZyXAB7kZzUUyct9n6) 😀 ]