The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
This vignette reports a moderated mediation analysis. This will help getting familiar with the several helpers JSmediation offers to conduct moderated mediation analysis.
Simple mediation refers to the pattern of statistical relationships in which the effect of a variable on another goes through a third variable. Sometimes, this indirect relationship is conditional to a fourth variable—a moderator. In such a case, we talk about moderated mediation. The JSmediation package offers a collection of tools to conduct and report a moderated mediation analysis (Muller et al., 2005).
The Introduction to JSmediation vignette uses a data set collected by Ho et al. (2017) to illustrate simple mediation. This data set contains the result of an experiment in which Ho et al. focus on hypodescent among Black Americans. To illustrate how JSmediation can be used to conduct a moderated mediation analysis, we will expand on this example.
Hypodescent refers to a rule observed in multiracial categorization. Research shows that majority group social perceivers (i.e., White Americans) typically associate Black-White multiracials with their lower status group rather than with their higher group (i.e., with Black Americans rather than with White Americans). This phenomenon is called the hypodescent rule and it was retrieved in the Black Americans population by Ho et al. (2017). The hypothesis is that such categorization occurs because of a sentiment of linked fate between Black Americans and Black-White multiracials.
This observation was supported by data showing that Black Americans felt a stronger sentiment of linked fate between them and Black-White multiracials when they read about an article discussing how Black-White multiracials were likely to suffer from discrimination (compared to an article discussing how they were not). The higher sentiment of linked fate was associated with a higher use of the hypodescent rule in multiracial categorization. In other words, the effect of a discrimination condition on hypodescent rule was mediated by the feeling of linked fate.
In the current vignette, we will investigate whether this indirect effect is moderated by social dominance orientation (SDO). Indeed, SDO correlates with preferences for intergroup equality—higher levels indicates resistance to intergroup equality and support for maintaining status quo, lower levels indicates support for intergroup equality and reducing hierarchy (Ho et al., 2017). Ho et al. (2017) assumed that the indirect effect will be stronger for Black Americans showing lower levels of SDO. They should feel a higher sentiment of linked fate when presented information related to the high discrimination of Black-White multiracials.
While this vignette was written to illustrate features from the
JSmediation package, we will use functions from other packages
(e.g., dplyr), but make it explicit when we do so. In other
words, rather than calling library(dplyr)
to attache the
dplyr package and then calling its function (e.g.,
mutate
), we will use dplyr::mutate
,
mutate
will suffice.
The data set collected by Ho et al. (2017) contains the information necessary for
the test of our hypothesis of moderated mediation. It contains a
condition
column indicating whether participants were read
about the high or low discrimination of Black-White multiracials and a
hypodescent
column. The data set also contains a
linkedfate
column indicating the feeling of linked fate
participants felt in the experimental situation. The simple mediation
analysis in the Introduction to
JSmediation vignette shows that participants in high discrimination
conditions tend to feel a higher level of linked fate which results in
higher hypodescent. We will now investigate whether this indirect effect
is more likely to be observed among participants who show higher levels
of SDO (thanks to the sdo
column).
head(ho_et_al)
#> id condition sdo linkedfate hypodescent
#> 1 2 Low discrimination 1.8125 6.000 2.333333
#> 2 3 High discrimination 1.5625 5.875 6.000000
#> 3 4 High discrimination 1.7500 6.625 6.000000
#> 4 5 Low discrimination 4.2500 5.125 5.666667
#> 5 6 Low discrimination 1.9375 4.375 4.000000
#> 6 9 High discrimination 2.8750 3.750 4.000000
Before we run the moderated mediation analysis, we must tweak the
data set a little bit. Muller et al. (2005) recommend centering the continuous
predictors and contrast-coding the categorical ones.
JSmediation offers helpers like build_contrast
or
standardize_variable
to do so.
ho_et_al <-
ho_et_al %>%
standardize_variable(c(sdo, linkedfate), suffix = "c") %>%
dplyr::mutate(condition_c = build_contrast(condition,
"Low discrimination",
"High discrimination")
)
head(ho_et_al)
#> # A tibble: 6 × 8
#> id condition sdo linkedfate hypodescent sdo_c linkedfate_c condition_c
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 2 Low discri… 1.81 6 2.33 -0.470 0.636 -0.5
#> 2 3 High discr… 1.56 5.88 6 -0.707 0.538 0.5
#> 3 4 High discr… 1.75 6.62 6 -0.529 1.13 0.5
#> 4 5 Low discri… 4.25 5.12 5.67 1.84 -0.0525 -0.5
#> 5 6 Low discri… 1.94 4.38 4 -0.351 -0.643 -0.5
#> 6 9 High discr… 2.88 3.75 4 0.538 -1.13 0.5
The first function we used, standardize_variable
, allows
us to center and reduce (to standardize) a set of variables (here:
sdo
and linkedfate
). The suffix
argument of this function is used to name the standardized variables.
Here, because we set suffix = "c"
, the new variables are
named sdo_c
and linkedfate_c
. When the suffix
argument is blank, original variables are overwritten. Because
JSmediation was designed to fit within the tidyverse,
standardize_variable
is especially useful in a
dplyr chain.
Here, we also used a second function from JSmediation:
build_contrast
. This function takes a character vector as a
first argument and, then, returns a contrast-coded variables. It is
designed for variables with two conditions, which is the case of
condition
. Because we want to include the transformed
variable in ho_et_al
, we can use the
dplyr::mutate
function which creates (or modify)
variables. With this method, we contrast-coded the
condition
variable.
ho_et_al %>%
dplyr::select(dplyr::starts_with("condition"))
#> # A tibble: 824 × 2
#> condition condition_c
#> <chr> <dbl>
#> 1 Low discrimination -0.5
#> 2 High discrimination 0.5
#> 3 High discrimination 0.5
#> 4 Low discrimination -0.5
#> 5 Low discrimination -0.5
#> 6 High discrimination 0.5
#> 7 High discrimination 0.5
#> 8 Low discrimination -0.5
#> 9 Low discrimination -0.5
#> 10 High discrimination 0.5
#> # ℹ 814 more rows
We will now run our moderated mediation analysis. Remember, we are
testing whether participants in high discrimination condition show
higher level of hypodescent because of a higher perception of linked
fate, and whether this indirect effect is higher among people with high
level of SDO. In other words, we are testing whether SDO moderates the
mediation of the effect on condition on hypodescent through linked fate
perception. To test this moderated mediation, we will use the
mdt_moderated
function.
Muller et al. (2005) provide an accessible introduction on how to conduct a moderated mediation analysis using the joint-significance methods. In a nutshell, one will fit several linear models to the data set, and, depending on the significance of some coefficients, one will be able to assess moderated mediation.
To better understand the process of testing a moderated mediation, we can glance at the equation describing the moderation of the indirect effect of X on Y. Such moderation can be described as follows:
\[ c \times Mod = c' \times Mod + (a \times Mod) \times b + a \times (b \times Mod) \]
with \(c \times Mod\) the total moderation of the indirect effect, \(c' \times Mod\) the moderation of the direct effect, \((a \times Mod) \times b\), the moderation of the indirect effect passing by the moderation of \(a\), and \(a \times (b \times Mod)\), the moderation of the indirect effect passing by the moderation of \(b\) (see Models section; Muller et al., 2005).
Either both \(a \times Mod\) and \(b\) or both \(a\) and \(b \times Mod\) need to be simultaneously significant for the moderation of the indirect effect to be claimed (Muller et al., 2005).
mdt_moderated
mdt_moderated
works like every mdt_*
function. It will be fit the necessary linear models (see the Models
section in the help page of mdt_moderated
) and returns the
relevant coefficient in a nicely formatted output.
To use the function, we will have to describe the role of the
variable in the ho_et_al
data set.
moderated_mediation_fit <-
mdt_moderated(data = ho_et_al,
IV = condition_c,
DV = hypodescent,
M = linkedfate_c,
Mod = sdo_c)
Most of the math occurs when mdt_moderated
is evaluated.
The moderated_mediation_fit
that we just computed contains
every linear model useful to assess moderated mediation, as described in
Muller et al. (2005).
As we can see, it is possible to see \(a\), \(a \times
Mod\), \(b\), and \(b \times Mod\) in the
mdt_moderated
output.
moderated_mediation_fit
#> Test of mediation (moderated mediation)
#> ==============================================
#>
#> Variables:
#>
#> - IV: condition_c
#> - DV: hypodescent
#> - M: linkedfate_c
#> - Mod: sdo_c
#>
#> Paths:
#>
#> ======== ============== ===== =======================
#> Path Point estimate SE APA
#> ======== ============== ===== =======================
#> a 0.569 0.063 t(820) = 9.01, p < .001
#> a * Mod -0.268 0.063 t(820) = 4.25, p < .001
#> b 0.161 0.043 t(818) = 3.75, p < .001
#> b * Mod -0.066 0.042 t(818) = 1.57, p = .117
#> c 0.131 0.078 t(820) = 1.67, p = .095
#> c * Mod -0.037 0.078 t(820) = 0.47, p = .640
#> c' 0.021 0.082 t(818) = 0.25, p = .800
#> c' * Mod 0.037 0.081 t(818) = 0.46, p = .645
#> ======== ============== ===== =======================
#>
#> Indirect effect index:
#>
#> Indirect effect index is not computed by default.
#> Please use add_index() to compute it.
#>
#> Fitted models:
#>
#> - X * Mod -> Y
#> - X * Mod -> M
#> - (X + M) * Mod -> Y
If a moderated mediation model is significant, Yzerbyt et al. (2018) recommend reporting the moderated
mediation index. To compute this index, JSmediation offers the
add_index
method. In the case of moderated mediation, we
will have to specify whether we are in a scenario where we assume that
the moderator impacts the relation between or IV and the mediator (i.e.,
both \(a \times Mod\) and \(b\) are significant), the relation between
the moderator and the DV (i.e., both \(a\) and \(b
\times Mod\) are significant), or both. To do so, we must use the
stage
argument.
The output of the new object now contains the index.
moderated_mediation_fit_w_index
#> Test of mediation (moderated mediation)
#> ==============================================
#>
#> Variables:
#>
#> - IV: condition_c
#> - DV: hypodescent
#> - M: linkedfate_c
#> - Mod: sdo_c
#>
#> Paths:
#>
#> ======== ============== ===== =======================
#> Path Point estimate SE APA
#> ======== ============== ===== =======================
#> a 0.569 0.063 t(820) = 9.01, p < .001
#> a * Mod -0.268 0.063 t(820) = 4.25, p < .001
#> b 0.161 0.043 t(818) = 3.75, p < .001
#> b * Mod -0.066 0.042 t(818) = 1.57, p = .117
#> c 0.131 0.078 t(820) = 1.67, p = .095
#> c * Mod -0.037 0.078 t(820) = 0.47, p = .640
#> c' 0.021 0.082 t(818) = 0.25, p = .800
#> c' * Mod 0.037 0.081 t(818) = 0.46, p = .645
#> ======== ============== ===== =======================
#>
#> Indirect effect index:
#>
#> - type: Mediated moderation index (First stage)
#> - point estimate: -0.0432
#> - confidence interval:
#> - method: Monte Carlo (5000 iterations)
#> - level: 0.05
#> - CI: [-0.0763; -0.0162]
#>
#> Fitted models:
#>
#> - X * Mod -> Y
#> - X * Mod -> M
#> - (X + M) * Mod -> Y
The moderated_mediation_fit_w_index
object that we
computed contains every bit of information to report a moderated
mediation in an analysis, following Yzerbyt et al.’s (2018) recommendations:
To assess whether SDO moderates the indirect effect of discrimination condition on hypodescent through linked fate perception, we conducted a moderated mediation analysis (Muller et al., 2005). This analysis first revealed that SDO moderates the effect of condition on linked fate perception, t(820) = 4.25, p < .001. It also revealed that the effect of linked fate perception for a mean level of SDO, and controlling for the effect of the condition and for the moderation of the condition by SDO, predicted significantly hypodescent, t(818) = 3.75, p < .001. This pattern reveals the existence of a moderated mediation. We also computed the first stage moderated mediation index consistent with our joint-significant analysis and it confirmed the moderated mediation, -0.0432, CI95% [-0.0778; -0.0171] (Monte Carlo simulation, 5000 simulations; Yzerbyt et al., 2018).
When reporting a moderated mediation analysis, it is sometimes useful
to know what the indirect effect is for several values of the moderator.
The compute_indirect_effect_for
function serves that
purpose.
compute_indirect_effect_for
takes as the first argument
a moderated mediation model for which we want to compute the indirect
effect at a specific value of the moderator and as the second argument
the value of the moderator.
In our example, we standardized our moderator. A mean value of the
moderator therefore is sdo_c = 0
. If we wanted to compute
the effect of condition on hypodescent through linked fate for a mean
value of SDO, we would have to run the following:
compute_indirect_effect_for(moderated_mediation_fit, Mod = 0)
#> - type: Conditional simple mediation index (Mod = 0)
#> - point estimate: 0.0916
#> - confidence interval:
#> - method: Monte Carlo (5000 iterations)
#> - level: 0.05
#> - CI: [0.0411; 0.145]
We could also compute this indirect effect for participants who score one standard deviation above the mean in terms of SDO.
compute_indirect_effect_for(moderated_mediation_fit, Mod = 1)
#> - type: Conditional simple mediation index (Mod = 1)
#> - point estimate: 0.0286
#> - confidence interval:
#> - method: Monte Carlo (5000 iterations)
#> - level: 0.05
#> - CI: [-0.0062; 0.0749]
As we can see, the indirect effect estimate decreases when the SDO increases. This result is consistent with the negative value of the moderated mediation index.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.