class: center, middle, inverse, title-slide .title[ # I’m OuttR Love! ] .subtitle[ ##
The Awakening: Metanoia Mediations
] .author[ ### Dr Danielle Evans ] .date[ ### 25 April 2024 ] --- <style type="text/css"> a { color: #009af5; font-weight: bold; } a.glossary { font-weight: bold; color: #8e7df1; cursor: help; position: relative; } .remark-inline-code { font-size: var(--code-inline-font-size); color: #4266ff; padding: 2px; } strong { font-weight: bold; color: black; } .remark-slide-number { color: black; opacity: 1; font-size: 0.9rem; } .hljs-github .hljs-string, .hljs-github .hljs-doctag { color: #333; } .hljs-github .hljs-literal { color: #333; } .hiddenFrame{ height:1px; width:1px; opacity: 0; } .red.remark-slide-content { background-color: #000000; font-size: 1rem; padding: 0; width: 100%; height: 100%; } <!-- .remark-container { --> <!-- background: #000000; --> <!-- margin: 0; --> <!-- overflow: hidden; --> <!-- } --> </style> ## Overview - **Quick Mediation Recap** + Total effects, indirect effects, & direct effects - **1-Mediator Model** + Defining our model + Fitting our model + Summarising our model + Interpreting our model + Building our model - **2-Mediator Model** + Defining our model + Fitting our model + Summarising our model + Interpreting our model + Building our model ??? --- ## Mediation Recap - <a class='glossary' title='Mediation analysis is a statistical method used to explore the indirect effect of a predictor variable on an outcome variable through one (or more) intervening variables, known as mediators. In other words, it examines the mechanism or pathway through which the predictor influences the outcome.'>Mediation</a> occurs when the relationship between a **predictor** and an **outcome**, can be **explained** by their relationship to a third variable: the **mediator** - 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** - With **mediation**, we're interested in **pathways** between variables: <br> .center[ <img src="data:image/png;base64,#img/09_2.png" width="60%" /> ] ??? --- ## Mediation Recap - 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/09_5.png" width="70%" /> ] ??? --- ## Mediation Recap - We then partition this **Total Effect** into: + An **Indirect Effect** which is the effect of the **predictor** on the **outcome**, through the **mediator** (path a * path b) + & 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/09_6.png" width="60%" /> ] ??? --- ## Mediation Recap - 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> .center[ <img src="data:image/png;base64,#img/med_flow.png" width="85%" /> ] ??? --- ## Mediation in R - Relatively straightforward to do in **R** with a 3-step process: + **Define model** + **Fit model** + **Summarise model** - We can then **interpret** our results and **build** our model! --- ## Today's Mediation: - Since beginning my dating experiments, alllll for **your** educational purposes... - I've noticed I'm increasingly more sad and my self-esteem is in the TRASH [you know the drill: **everybody say 'awww'**] -- - So I'm starting to think there might be a link between <a class='glossary' title='AKA hell in virtual form'>online dating/dating apps</a> and <a class='glossary' title='Self-esteem refers to the subjective evaluation of one’s own worth, value, and capabilities. It encompasses feelings of confidence, self-respect, and self-acceptance, influencing how individuals perceive and interact with themselves, others, and the world around them.'>self-esteem</a> - And that this link might be explained by worsening <a class='glossary' title='Body image issues refer to negative perceptions, thoughts, feelings, and beliefs individuals may have about their physical appearance. These perceptions often involve dissatisfaction or distress regarding one’s body shape, size, weight, or specific features.'>body image issues</a>: <br> .center[ <img src="data:image/png;base64,#img/se1.png" width="80%" /> ] --- ## Step 1: Define Model - We define our model by writing out the paths as a **string of text** - We then save it into an **object** ('**my_mod**') that we can call on when we fit our model in step 2... + The code looks scarier than it really is, we're just **labelling** and **defining** each **pathway**: <div style="line-height:50%;"> <br> </div> ```r my_mod <- 'outcome ~ c*predictor + b*mediator mediator ~ a*predictor indirect_effect := a*b total_effect := c + (a*b) ' ``` <div style="line-height:50%;"> <br> </div> <div class="mb" style="font-size:90%"> <p><b>Woah!</b> The weird symbols in the model definition code mean different things: '<b>~</b>' means '<b>is predicted from</b>' and '<b>:=</b>' means '<b>is created from</b>' </p> </div> ??? --- ## Step 1: Define Model - So, we can use this syntax, replacing the '**outcome**', '**predictor**' and '**mediator**' with the names of the **variables** in our data: <br> ```r my_mod <- 'self_esteem ~ c*online_dating + b*body_image body_image ~ a*online_dating indirect_effect := a*b total_effect := c + (a*b) ' ``` <br><br><br><br> <div class="tu" style="font-size:90%"> <p><b>Top Tip!</b> We don't need to change the second part of the code because we create the <b>a</b>, <b>b</b>, and <b>c</b> labels in the first 2 lines!</p> </div> --- ## Step 1: Define Model - So, we can use this syntax, replacing the '**outcome**', '**predictor**' and '**mediator**' with the names of the **variables** in our data: <br> ```r my_mod <- 'self_esteem ~ c*online_dating + b*body_image body_image ~ a*online_dating indirect_effect := a*b total_effect := c + (a*b) ' ``` <br><br><br><br><br> <div class="pc" style="font-size:90%"> <p><b>Demo!</b> Fitting our Model in R!</p> </div> --- ## Step 2: Fit Model - To fit our mediation model we use the `sem()` function from the `lavaan` package - Here we specify the name of the model we just defined in **step 1**, the name of our data, how we want to handle missing data, and the estimation method we want to use... <br> ```r my_fit <- lavaan::sem(my_mod, data = my_data, missing = "something", estimator = "something") ``` ??? --- ## A Missing Data Detour... - By default, the `sem()` function will use <a class='glossary' title='Listwise deletion is a method in statistics used to handle missing data by removing any observations that have missing values across all variables.'>listwise deletion</a> to deal with any missing data - <a class='glossary' title='Listwise deletion is a method in statistics used to handle missing data by removing any observations that have missing values across all variables.'>Listwise deletion</a> is where an entire participant is excluded from analysis if any single variable is missing - A better method to use that's available in the `sem()` function is **full information maximum likelihood** estimation (aka **FIML** - *no, not FML...*) - **FIML** produces unbiased **parameter estimates** and **standard errors** where there are missing data 🥳 + We would use `missing = "FIML"` in the previous code to change this option! <br> <div class="swr" style="font-size:90%"> <p><b>Don't Do It!!!</b> Listwise deletion is a bad method of dealing with missing data, much better ones include <b><a href = "https://drive.google.com/file/d/1UKKPW_qgfDobDrqnQCd02zTyyuTxmoAU/view">FIML</a></b> and <b><a href = "https://drive.google.com/file/d/1UKKPW_qgfDobDrqnQCd02zTyyuTxmoAU/view">multiple imputation</a></b>!</p> </div> ??? --- ## A Missing Data Detour... - We can only use **FIML** when we use **maximum likelihood** estimators - **Maximum likelihood** estimators work by choosing the parameters that make the data most likely to have happened - We would use `estimator = "ML"` in the previous code to change this option! - We can also use `estimator = "MLR"` instead to get **robust standard errors** (always a good idea!) - So our code becomes: <br> ```r my_fit <- lavaan::sem(my_mod, data = my_data, missing = "FIML", estimator = "MLR") ``` ??? --- ## Step 3: Summarise Model - Once we've fit our model using appropriate methods for handling missing data, we can **summarise** it with a few different functions(): - `broom::glance()` allows us to look at how good our model is - the **model fit statistics**: ```r broom::glance(my_fit) ``` <BR> - `broom::tidy()` allows us to look at our actual effects - the **model parameters**: ```r broom::tidy(my_fit, conf.int = TRUE) ``` ??? --- ## Step 4: Interpret Model - The output of `broom::tidy()` is the part we're most interested in! <br> <table class="table" style="font-size: 11px; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;background-color: #3f51b5; color: #fff; !important;"> term </th> <th style="text-align:left;background-color: #3f51b5; color: #fff; !important;"> op </th> <th style="text-align:left;background-color: #3f51b5; color: #fff; !important;"> label </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> estimate </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> std.error </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> statistic </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> p.value </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> conf.low </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> conf.high </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> std.lv </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> std.all </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> std.nox </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> self_esteem ~ online_dating </td> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> ~ </td> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> c </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.12 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 8.95 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.10 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.15 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.12 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.35 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.02 </td> </tr> <tr> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> self_esteem ~ body_image </td> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> ~ </td> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> b </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.72 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.06 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 11.25 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.59 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.84 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.72 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.49 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.49 </td> </tr> <tr> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> body_image ~ online_dating </td> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> ~ </td> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> a </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.07 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 6.73 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.05 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.09 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.07 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.30 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> self_esteem ~~ self_esteem </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~~ </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 34.32 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 2.37 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 14.47 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 29.67 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 38.97 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 34.32 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.54 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.54 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> body_image ~~ body_image </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~~ </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 27.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 1.88 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 14.33 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 23.31 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 30.69 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 27.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.91 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.91 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> online_dating ~~ online_dating </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~~ </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 523.71 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 523.71 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 523.71 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 523.71 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 1.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 523.71 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> self_esteem ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 3.68 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 2.61 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 1.41 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.16 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> -1.44 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 8.80 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 3.68 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.46 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.46 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> body_image ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 39.94 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.74 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 53.93 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 38.49 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 41.39 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 39.94 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 7.33 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 7.33 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> online_dating ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 55.29 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 55.29 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 55.29 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 55.29 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 2.42 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 55.29 </td> </tr> <tr> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> indirect_effect := a*b </td> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> := </td> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> indirect_effect </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.05 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 5.24 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.03 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.07 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.05 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.15 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> </tr> <tr> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> total_effect := c+(a*b) </td> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> := </td> <td style="text-align:left;background-color: #c8d0ff; color: #black; !important;"> total_effect </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.17 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 12.28 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.15 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.20 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.17 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.50 </td> <td style="text-align:right;background-color: #c8d0ff; color: #black; !important;"> 0.02 </td> </tr> </tbody> </table> ??? --- ## Step 4: Interpret Model - The key parts are in **bold**: <br> <table class="table" style="font-size: 11px; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;background-color: #3f51b5; color: #fff; !important;"> term </th> <th style="text-align:left;background-color: #3f51b5; color: #fff; !important;"> op </th> <th style="text-align:left;background-color: #3f51b5; color: #fff; !important;"> label </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> estimate </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> std.error </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> statistic </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> p.value </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> conf.low </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> conf.high </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> std.lv </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> std.all </th> <th style="text-align:right;background-color: #3f51b5; color: #fff; !important;"> std.nox </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> self_esteem ~ online_dating </td> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> ~ </td> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> c </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.12 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 8.95 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.10 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.15 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.12 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.35 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.02 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> self_esteem ~ body_image </td> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> ~ </td> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> b </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.72 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.06 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 11.25 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.59 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.84 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.72 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.49 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.49 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> body_image ~ online_dating </td> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> ~ </td> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> a </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.07 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 6.73 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.05 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.09 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.07 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.30 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> self_esteem ~~ self_esteem </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~~ </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 34.32 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 2.37 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 14.47 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 29.67 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 38.97 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 34.32 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.54 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.54 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> body_image ~~ body_image </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~~ </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 27.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 1.88 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 14.33 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 23.31 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 30.69 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 27.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.91 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.91 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> online_dating ~~ online_dating </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~~ </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 523.71 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 523.71 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 523.71 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 523.71 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 1.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 523.71 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> self_esteem ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 3.68 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 2.61 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 1.41 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.16 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> -1.44 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 8.80 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 3.68 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.46 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.46 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> body_image ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 39.94 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.74 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 53.93 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 38.49 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 41.39 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 39.94 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 7.33 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 7.33 </td> </tr> <tr> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> online_dating ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> ~1 </td> <td style="text-align:left;background-color: #e4eaff; color: #black; !important;"> </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 55.29 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> NA </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 55.29 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 55.29 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 55.29 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 2.42 </td> <td style="text-align:right;background-color: #e4eaff; color: #black; !important;"> 55.29 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> indirect_effect := a*b </td> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> := </td> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> indirect_effect </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.05 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 5.24 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.03 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.07 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.05 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.15 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> total_effect := c+(a*b) </td> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> := </td> <td style="text-align:left;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> total_effect </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.17 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.01 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 12.28 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.00 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.15 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.20 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.17 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.50 </td> <td style="text-align:right;font-weight: bold;background-color: #c8d0ff; color: #black; !important;"> 0.02 </td> </tr> </tbody> </table> ??? --- ## Step 5: Build Model - We can use `semPlot::semPaths()` to build a diagram of our model, but making it look pretty is quite tricky - Instead we can use any other software to create it (Word, PowerPoint etc.) - We can take each of the estimates from our `broom::tidy(my_fit, conf.int = TRUE)` summary, putting them into the correct paths: <br> .center[ <img src="data:image/png;base64,#img/full_model1.png" width="85%" /> ] ??? --- ## 2-Mediator Model - We can extend our mediation model to include an **additional mediator** .center[ <img src="data:image/png;base64,#img/2med1.png" width="55%" /> ] - Following our first mediation, I'm now pretty interested in the relationship between dating app use and body image issues, and potential mediators of that relationship! ??? --- ## 2-Mediator Model in R - To give this a go in **R**, let's have a look at the following model: <div style="line-height:50%;"> <br> </div> .center[ <img src="data:image/png;base64,#img/2med2.png" width="65%" /> ] <div style="line-height:50%;"> <br> </div> - Here our predictor is **online dating frequency**, our outcome is **body image issues**, our first mediator is **comparison to others**, and our second mediator is **experiences of rejection** - So we're saying the relationship between online dating and body image issues can be explained by comparison to others and rejection experiences ??? --- ## 2-Mediator Model in R - With 2 mediators, our model is largely the same - we just have to add in another **a** pathway, another **indirect** pathway, & model the **relationship** between our two mediators ```r my_mod_2 <- "outcome ~ c*predictor + b1*med_1 + b2*med_2 med_1 ~ a1*predictor med_2 ~ a2*predictor indirect_med_1 := a1*b1 indirect_med_2 := a2*b2 total_effect := c + (a1*b1) + (a2*b2) med_1 ~~ med_2 " ``` - We just need to change the **labels** to match the **variables** in our dataset like we did before! ??? -- <div class="pc" style="font-size:90%"> <p><b>Demo!</b> 2-Mediator Model in <b>R</b> </p> </div> ??? ```r "maths_att ~ c*maths_anx + b1*gen_anx + b2*test_anx gen_anx ~ a1*maths_anx test_anx ~ a2*maths_anx indirect_gen := a1*b1 indirect_test := a2*b2 total_effect := c + (a1*b1) + (a2*b2) gen_anx ~~ test_anx " ``` --- ## 2-Mediator Model Interpretation - The interpretation of our mediation is the same as before: + We can look at the **parameter estimates**, **confidence intervals**, and ***p*-values** to see if we have a **mediation effect** -- <br> .center[ <img src="data:image/png;base64,#img/med2full.png" width="70%" /> ] <p style="text-align:left; font-size:50%">*all results are fictional 😉</p> ??? --- ## *That's all - foreveR!* 😱💔 <br> <br> <img src="data:image/png;base64,#./img/aa.gif" width="80%" style="display: block; margin: auto;" /> .center[ [Give session feedback here!](https://forms.gle/ZyXAB7kZzUUyct9n6) 😀 ]