+ - 0:00:00
Notes for current slide
Notes for next slide

Lecture 10: Mediation & Moderation

Guess who’s back, back R-gain

Dr Danielle Evans

31 March 2022

1 / 45

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

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

Post your Qs on this Padlet...

2 / 45

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:


  • 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:

  • Change in the predictor = change in the mediator = change in the outcome
3 / 45

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:


  • 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:

  • Change in the predictor = change in the mediator = change in the outcome
4 / 45

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!


Easy Error! Even in a mediation, correlation does not equal causation!!

5 / 45

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:






  • It might help to think of it as being the overall relationship between your two variables...
6 / 45

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

7 / 45

Mediation: Pathways








8 / 45

Mediation: Pathways





9 / 45

Mediation: Pathways





10 / 45

Mediation: Partitions


11 / 45

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)




Easy Error! People often get 'Direct Effect' & 'Total Effect' muddled up!! The total effect does not adjust for any other variables - the direct effect does..

12 / 45

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:



  • 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...
13 / 45

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:



  • We're testing whether SES predicts maths ability, and if/how much of this relationship can be explained by parental involvement in education
14 / 45

Doing a Mediation

  • Step 1. Does the predictor predict the outcome (Total Effect)

    • We could test this with a simple regression in R





15 / 45

Doing a Mediation

  • Step 2a: Separate the Total Effect into an Indirect Effect (path ab) by first working out path a:


  • We could test this with another simple regression in R

Top Tip! The Indirect Effect is the product of paths a and b - we can just multiply the estimates together to get the Indirect Effect)

16 / 45

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:


  • 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
17 / 45

Doing a Mediation

  • Step 3: See whether our predictor still predicts our outcome path c (the Direct Effect), after accounting for the Indirect Effect:


  • We could test this with a multiple regression in R where we adjust for our mediator
18 / 45

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!
# 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)

Don't Panic! We'll go over the code in the discovr_10 tutorial & in the skills labs!

19 / 45

Mathsy Mediation in R

  • Our mathsy mediation model in R with ses (predictor), parent_inv (mediator), and maths_att (outcome):
# 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)
20 / 45

Mathsy Mediation in R

  • We can see the parameter estimates (unstandardized betas) for each pathway in the estimate column below:
# step 3: summarize the model
broom::tidy(my_fit, conf.int = TRUE)
term op label estimate std.error statistic p.value conf.low conf.high
maths_att ~ ses ~ c 4.071 0.455 8.951 0 3.179 4.962
maths_att ~ parent_inv ~ b 71.906 6.394 11.245 0 59.373 84.439
parent_inv ~ ses ~ a 0.024 0.004 6.731 0 0.017 0.031
maths_att ~~ maths_att ~~ 343190.477 23717.965 14.470 0 296704.119 389676.835
parent_inv ~~ parent_inv ~~ 27.000 1.884 14.331 0 23.307 30.692
ses ~~ ses ~~ 4713.358 0.000 NA NA 4713.358 4713.358
maths_att ~1 ~1 2077.997 325.090 6.392 0 1440.833 2715.161
parent_inv ~1 ~1 50.027 0.848 58.991 0 48.365 51.689
ses ~1 ~1 -254.129 0.000 NA NA -254.129 -254.129
indirect_effect := a*b := indirect_effect 1.727 0.330 5.240 0 1.081 2.373
total_effect := c+(a*b) := total_effect 5.798 0.472 12.281 0 4.873 6.724
21 / 45

Building our Model

  • We can use the estimates (betas) and the label (the path) to build a diagram of our model:





*these results are fictional

22 / 45

Interpreting Results

We can interpret the bs 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

23 / 45

Interpreting Results

  • To see if we have a significant mediation, we look at the size, the bootstrapped 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?

24 / 45

Interpreting Results

  • So, based on our mathsy mediation:


  • SES predicts maths ability directly (b = 4.07)
  • SES predicts maths ability indirectly through parental involvement (b = 1.73)


*these results are fictional

25 / 45

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% BCa CI [1.08, 2.37], p < .001."


Pet Peeve! Your result is NOT 'insignificant' - it is nonsignificant!!

26 / 45

Post Your Mediation Questions!

Made with Padlet
27 / 45

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


28 / 45

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 you encountered in Discovering Statistics last term - we run a moderation in the same way as a linear model with 3 predictors:


29 / 45

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




Easy Error! Predictors and moderators are mathematically the same in our model - the only differences are conceptual!

30 / 45

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, when helping with maths homework can increase their child's maths anxiety, and parents without maths anxiety have a less negative impact

  • So, our conceptual model is:

31 / 45

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



  • 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

32 / 45

The Catch

  • When using a linear model with multiple predictors, each of the effects (bs) 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 bs for the main effects are usually uninterpretable

33 / 45

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

  • 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 bs, 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!


Easy Error! You can use centring in any model where it makes sense, we need to use it in moderations for interpretation but we can use it elsewhere too!

34 / 45

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:
# 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)
35 / 45

Mathsy Moderation in R

  • Our results would look like this where we have 2x main effects, and 1x interaction effect:

term estimate std.error statistic p.value conf.low conf.high
(Intercept) 40.598 0.310 130.958 0 39.988 41.207
parent_maths_anx 0.507 0.018 28.099 0 0.471 0.542
parent_hw_help -166.756 39.805 -4.189 0 -245.052 -88.460
parent_maths_anx:parent_hw_help 23.955 3.962 6.046 0 16.161 31.749

  • If our interaction is significant then we have a moderation effect, it would also means we're no longer that interested in the lower-order/main effects because they change at different levels of our moderator

Top Tip! Higher-order effects refer to interactions, and lower-order effects refer to the main effects!

*these results are fictional

36 / 45

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

37 / 45

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 (0), and high parental homework help (+1 SD)

  • 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

38 / 45

Simple Slopes Analysis

  • The interactions plot displays this same information much nicer:

  • 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 (0), 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

39 / 45

Johnson-Neyman Interval

  • 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

JOHNSON-NEYMAN INTERVAL
When parent_hw_help is OUTSIDE the interval [-0.03, -0.02], the slope of parent_hw_help is p < .05.

  • The black line is where the relationship between our predictor and outcome is 0, above it is positive, below it is negative
40 / 45

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:

"At the mean of parental homework help, there was a significant positive relationship between parental maths anxiety and child maths anxiety, b = 0.51, t = 28.10, p < .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, b = -166.75, t = -4.19, p < .001, 95% CI [-245.05, -88.46].

The interaction between parental maths anxiety and parental homework help was significantly related to child maths anxiety, b = 23.96, t = 6.05, p < .001, 95% CI [16.16, 31.75].

When parental homework help is low (-1 SD), there is a significant positive relationship between parental maths anxiety and child maths anxiety, b = 0.34, 95% CI [0.27, 0.40 ], t = 9.97, p < .001. At the mean of parental homework help, there is a significant positive relationship between parental maths anxiety and child maths anxiety, b = 0.51, 95% CI [0.47, 0.54 ], t = 30.04, p < .001. When parental homework help is high (+1 SD), there is a significant positive relationship between parental maths anxiety and child maths anxiety, b = 0.68, 95% CI [0.62, 0.73 ], t = 22.6, p < .001."


Top Tip! If we're using grand mean centring, the effects should be interpreted at the mean values of the variables!

41 / 45

Reporting Moderations

  • We could also include a table of our results, something like this:


Predictor b SE B t p
Intercept 40.598 0.310 130.958 <.001
Parental Maths Anxiety 0.507 0.018 28.099 <.001
Parental Homework Help -166.756 39.805 -4.189 <.001
Parental Maths Anxiety x Parental Homework Help 23.955 3.962 6.046 <.001
42 / 45

Post Your Moderation Questions!

Made with Padlet
43 / 45

Summary

  • Mediation occurs when the relationship between two variables can be explained (either in part or in full), by another variable

    • In a mediation model, we start with a total effect (the simple relationship between predictor and outcome), and we partition this into a direct effect and 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 can test for moderation using a linear model - all the same assumptions apply, but we should centre our predictor and moderator before analysis to make the bs 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!!

44 / 45

That's all - happy modelling!




Give session feedback here... 😀

45 / 45

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

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

Post your Qs on this Padlet...

2 / 45
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow