Given a data frame, a predictor (`IV`

), an outcome (`DV`

), a
mediator (`M`

), and a moderator (`Mod`

) conducts a joint-significant test
for moderated mediation (see Yzerbyt, Muller, Batailler, & Judd, 2018).You
can learn about moderated mediation in `vignette("moderated-mediation")`

`add_index.moderated_mediation`

computes the moderated mediation index.
`compute_indirect_effect_for`

is used to compute the indirect effect
index for a specific value of the moderator.

`mdt_moderated(data, IV, DV, M, Mod)`

- data
A data frame containing the variables in the model.

- IV
An unquoted variable in the data frame which will be used as the independent variable.

- DV
An unquoted variable in the data frame which will be used as the dependent variable.

- M
An unquoted variable in the data frame which will be used as the mediator.

- Mod
An unquoted variable in the data frame which will be used as the moderator.

Returns an object of class "`mediation_model`

".

An object of class "`mediation_model`

" is a list containing at least
the components:

- type
A character string containing the type of model that has been conducted (e.g.,

`"simple mediation"`

).- method
A character string containing the approach that has been used to conduct the mediation analysis (usually

`"joint significance"`

).- params
A named list of character strings describing the variables used in the model.

- paths
A named list containing information on each relevant path of the mediation model.

- indirect_index
A boolean indicating whether an indirect effect index has been computed or not. Defaults to

`FALSE`

. See`add_index`

to compute mediation index.- indirect_index_infos
(Optional) An object of class

`"indirect_index"`

. Appears when one applies`add_index`

to an object of class`"mediation_model"`

.- js_models
A list of objects of class

`"lm"`

. Contains every model relevant to joint-significance testing.- data
The original data frame that has been passed through

`data`

argument.

With moderated mediation analysis, one tests whether the indirect effect of \(X\) on \(Y\) through \(M\) is moderated by \(Mod\). The hypothesis behind this test is that \(X\) has an effect on \(M\) (\(a\)) which has an effect on \(Y\) (\(b\)), meaning that \(X\) has an indirect effect on \(Y\) through \(M\).

Total moderation of the indirect effect of \(X\) on \(Y\) can be described as follows:

\(c * Mod = c' * Mod + (a * Mod) * b + a * (b * Mod)\)

with \(c * Mod\) the total moderation of the indirect effect, \(c' * Mod\) the moderation of the direct effect, \((a * Mod) * b\), the moderation of the indirect effect passing by the moderation of \(a\), and \(a * (b * Mod)\), the moderation of the indirect effect passing by the moderation of \(b\) (see Models section; Muller et al., 2005).

Either both \(a * Mod\) and \(b\) or both \(a\) and \(b * Mod\) need to be simultaneously significant for a moderation of the indirect effect to be claimed (Muller et al., 2005).

In a moderated mediation model, three models will be used:

\(Y_i = b_{40} + \mathbf{b_{41}} X_i + b_{42} Mo_i + \mathbf{b_{43}} XMo_i \)

\(M_i = b_{50} + \mathbf{b_{51}} X_i + b_{52} Mo_i + \mathbf{b_{53} XMo_i}\)

\(Y_i = b_{60} + \mathbf{c'_{61}} X_i + b_{62} Mo_i + \mathbf{b_{63} Xmo_i} + \mathbf{b_{64} Me_i} + \mathbf{b_{65} MeMo_i}\)

with \(Y_i\), the outcome value for the *i*th observation,
\(X_i\), the predictor value for the *i*th observation,
\(Mo_i\), the moderator value for the *i*th observation, and
\(M_i\), the mediator value for the *i*th observation.

Coefficients associated with \(a\), \(a \times Mod\), \(b\), \(b \times Mod\), \(c\), \(c \times Mod\), \(c'\), and \(c' \times Mod\), paths are respectively \(b_{51}\), \(b_{53}\), \(b_{64}\), \(b_{65}\), \(b_{41}\), \(b_{43}\), \(b_{61}\), and \(b_{63}\) (see Muller et al., 2005).

Because joint-significance tests use linear models
behind the scenes, variables involved in the model have to be numeric.
`mdt_simple`

will give an error if non-numeric variables are
specified in the model.

If you need to convert a dichotomous categorical variable to a numeric one,
please refer to the `build_contrast`

function.

Note that variable coding is especially important in models with multiple
predictors as is the case in the model used to conduct a joint-significance
test of moderated mediation. Muller et al. (2005) recommend using variables
that are either contrast-coded or centered. Using `mdt_moderated`

with
a DV, a mediator, or a moderator that is neither contrast-coded nor
centered will give a warning message.

Muller, D., Judd, C. M., & Yzerbyt, V. Y. (2005). When moderation
is mediated and mediation is moderated. *Journal of Personality and
Social Psychology*, 89(6), 852-863. doi: 10.1037/0022-3514.89.6.852

Yzerbyt, V., Muller, D., Batailler, C., & Judd, C. M. (2018). New
recommendations for testing indirect effects in mediational models: The
need to report and test component paths. *Journal of Personality and
Social Psychology*, *115*(6), 929–943. doi: 10.1037/pspa0000132

Other mediation models:
`mdt_simple()`

,
`mdt_within()`