When computing a moderated mediation, one assesses whether an indirect effect changes according a moderator value (Muller et al., 2005). mdt_moderated makes it easy to assess moderated mediation, but it does not allow accessing the indirect effect for a specific moderator values. compute_indirect_effect_for fills this gap.

compute_indirect_effect_for(
mediation_model,
Mod = 0,
times = 5000,
level = 0.05
)

## Arguments

mediation_model

A moderated mediation model fitted with mdt_moderated.

Mod

The moderator value for which to compute the indirect effect. Must be a numeric value, defaults to 0.

times

Number of simulations to use to compute the Monte Carlo indirect effect confidence interval. Must be numeric, defaults to 5000.

level

Alpha threshold to use for the indirect effect's confidence interval. Defaults to .05.

## Details

The approach used by compute_indirect_effect_for is similar to the approach used for simple slope analyses. Specifically, it will fit a new moderated mediation model, but with a data set with a different variable coding. Behind the scenes, compute_indirect_effect_for adjusts the moderator variable coding, so that the value we want to compute the indirect effect for is now 0.

Once done, a new moderated mediation model is applied using the new data set. Because of the new coding, and because of how one interprets coefficients in a linear regression, $$a \times b$$ is now the indirect effect we wanted to compute (see the Models section).

Thanks to the returned values of $$a$$ and bb ($$b_51$$ and $$b_64$$, see the Models section), it is now easy to compute $$a \times b$$. compute_indirect_effect_for uses the same approach than the add_index function. A Monte Carlo simulation is used to compute the indirect effect index (MacKinnon et al., 2004).

## Models

In a moderated mediation model, three models are used. compute_indirect_effect_for uses the same model specification as mdt_moderated:

• $$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 ith observation, $$X_i$$, the predictor value for the ith observation, $$Mo_i$$, the moderator value for the ith observation, and $$M_i$$, the mediator value for the ith 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).

## Examples

# compute an indirect effect index for a specific value in a moderated
# mediation.
data(ho_et_al)
ho_et_al$condition_c <- build_contrast(ho_et_al$condition,
"Low discrimination",
"High discrimination")
moderated_mediation_model <- mdt_moderated(data = ho_et_al,
DV = hypodescent,
IV = condition_c,