Skip to contents

Introduction

The GenerateModelP function dynamically generates a Structural Equation Model (SEM) formula to analysis parallel mediation for ‘lavaan’ based on the prepared dataset. This document explains the mathematical principles and the structure of the generated model.

parallel within-subject mediation model

1.2 Difference Model for YdiffY_{\text{diff}}

Taking the difference between the two conditions: Ydiff=Y2Y1=(b20b10)+i=1Nbi2Mi2i=1Nbi1Mi1+(e2e1) Y_{\text{diff}} = Y_2 - Y_1 = (b_{20} - b_{10}) + \sum_{i=1}^N b_{i2} M_{i2} - \sum_{i=1}^N b_{i1} M_{i1} + (e_2 - e_1)

Define: - Δb0=b20b10\Delta b_0 = b_{20} - b_{10}: Difference in intercepts. - e=e2e1e = e_2 - e_1: Difference in residuals.

Substitute mediator difference and average: 1. Mediator difference: Mdiff,i=Mi2Mi1 M_{\text{diff},i} = M_{i2} - M_{i1}

  1. Mediator average: Mavg,i=Mi1+Mi22 M_{\text{avg},i} = \frac{M_{i1} + M_{i2}}{2}

Substitute Mi2=Mavg,i+Mdiff,i2M_{i2} = M_{\text{avg},i} + \frac{M_{\text{diff},i}}{2} and Mi1=Mavg,iMdiff,i2M_{i1} = M_{\text{avg},i} - \frac{M_{\text{diff},i}}{2} into the equation: Ydiff=Δb0+i=1N(bi1+bi22Mdiff,i+(bi2bi1)Mavg,i)+e Y_{\text{diff}} = \Delta b_0 + \sum_{i=1}^N \left( \frac{b_{i1} + b_{i2}}{2} \cdot M_{\text{diff},i} + (b_{i2} - b_{i1}) \cdot M_{\text{avg},i} \right) + e

Define: - bi=bi1+bi22b_i = \frac{b_{i1} + b_{i2}}{2}: Average effect of the ii-th mediator. - di=bi2bi1d_i = b_{i2} - b_{i1}: Difference in the effect of the ii-th mediator.

The final equation becomes: Ydiff=Δb0+i=1N(biMdiff,i+diMavg,i)+e Y_{\text{diff}} = \Delta b_0 + \sum_{i=1}^N \left( b_i M_{\text{diff},i} + d_i M_{\text{avg},i} \right) + e


1.3 Regression for MdiffM_{\text{diff}}

Each mediator difference Mdiff,iM_{\text{diff},i} is modeled as: Mdiff,i=ai+ϵi M_{\text{diff},i} = a_i + \epsilon_i

Where: - aia_i: Intercept term for the ii-th mediator difference. - ϵi\epsilon_i: Residual for Mdiff,iM_{\text{diff},i}.


2. Indirect Effects

For each mediator MiM_i, the indirect effect is defined as: indirecti=aibi \text{indirect}_i = a_i \cdot b_i

Where: - aia_i: Effect of the independent variable on mediator MiM_i. - bib_i: Average effect of mediator MiM_i on the dependent variable.

The total indirect effect is: total_indirect=i=1Nindirecti \text{total_indirect} = \sum_{i=1}^N \text{indirect}_i

The contrast between indirect effects of two mediators MiM_i and MjM_j is: CIi,j=indirectiindirectj CI_{i,j} = \text{indirect}_i - \text{indirect}_j


3. Total Effect

The total effect combines the direct effect and the total indirect effect: total_effect=cp+total_indirect \text{total_effect} = c_p + \text{total_indirect}

Where cpc_p is the direct effect of the independent variable on the dependent variable.


4. Comparison of Indirect Effects

When there are multiple mediators (M1,M2,,MNM_1, M_2, \dots, M_N), comparing their indirect effects provides insights into the relative influence of each mediator. This section details the formulas and interpretations for such comparisons.


4.1 Indirect Effect Definition

For a mediator MiM_i, the indirect effect is defined as: indirecti=aibi \text{indirect}_i = a_i \cdot b_i

Where: - aia_i: Effect of the independent variable on mediator MiM_i. - bib_i: Average effect of mediator MiM_i on the dependent variable.


4.2 Comparing Indirect Effects

To compare the indirect effects of two mediators MiM_i and MjM_j, we calculate the contrast: CIi,j=indirectiindirectj CI_{i,j} = \text{indirect}_i - \text{indirect}_j

Interpretation

  1. CIi,j>0CI_{i,j} > 0:
    • Mediator MiM_i has a stronger indirect effect than MjM_j.
  2. CIi,j<0CI_{i,j} < 0:
    • Mediator MjM_j has a stronger indirect effect than MiM_i.
  3. CIi,j=0CI_{i,j} = 0:
    • Both mediators contribute equally to the indirect effect.

5. C1- and C2-Measurement Coefficients

To compute C1- and C2-measurement coefficients X1b,iX1_{b,i} and X0b,iX0_{b,i}, consider two mediators M1M_1 and M2M_2:


5.1 Difference Model with Two Mediators

From the difference model: Ydiff=Δb0+(b11+b212)Mdiff+(b21b11)Mavg+e Y_{\text{diff}} = \Delta b_0 + \left(\frac{b_{11} + b_{21}}{2}\right) M_{\text{diff}} + \left(b_{21} - b_{11}\right) M_{\text{avg}} + e

Define: - b=b11+b212b = \frac{b_{11} + b_{21}}{2}: Average effect. - d=b21b11d = b_{21} - b_{11}: Difference in effect.


5.2 C2-Measurement Coefficients

The C2-measurement coefficient X1b,iX1_{b,i} is defined as: X1b,i=b+d X1_{b,i} = b + d

Substitute bb and dd: X1b,i=b11+b212+(b21b11)=b21 X1_{b,i} = \frac{b_{11} + b_{21}}{2} + (b_{21} - b_{11}) = b_{21}

Thus, X1b,iX1_{b,i} is the effect of MiM_i under Condition 2.


5.3 C1-Measurement Coefficients

The C1-measurement coefficient X0b,iX0_{b,i} is defined as: X0b,i=X1b,id X0_{b,i} = X1_{b,i} - d

Substitute X1b,i=b21X1_{b,i} = b_{21} and d=b21b11d = b_{21} - b_{11}: X0b,i=b21(b21b11)=b11 X0_{b,i} = b_{21} - (b_{21} - b_{11}) = b_{11}

Thus, X0b,iX0_{b,i} is the effect of MiM_i under Condition 1.

Additional Interpretation: The coefficient di=b2ib1id_i = b_{2i} - b_{1i} reflects the moderating effect of the within-subject variable X, capturing how the mediator’s influence differs across conditions.


6. Summary of Regression Equations

This section summarizes all the regression equations used in the analysis, including the difference model, indirect effects, mediator comparisons, and C1- and C2-measurement coefficients.


6.1 Difference Model

Ydiff=cp+i=1N(biMdiff,i+diMavg,i)+e Y_{\text{diff}} = cp + \sum_{i=1}^N \left( b_i M_{\text{diff},i} + d_i M_{\text{avg},i} \right) + e

Mdiff,i=ai+ϵi M_{\text{diff},i} = a_i + \epsilon_i


6.2 Defined parameters

indirecti=aibi \text{indirect}_i = a_i \cdot b_i

total_indirect=i=1Nindirecti \text{total_indirect} = \sum_{i=1}^N \text{indirect}_i

CIi,j=indirectiindirectj CI_{i,j} = \text{indirect}_i - \text{indirect}_j

X1b,i=bi+di X1_{b,i} = b_i + d_i

X0b,i=X1b,idi X0_{b,i} = X1_{b,i} - d_i


Summary

By combining these equations: 1. The difference model YdiffY_{\text{diff}} decomposes into contributions from mediator differences (MdiffM_{\text{diff}}) and averages (MavgM_{\text{avg}}). 2. Indirect effects and their contrasts provide insights into the mediators’ relative importance. 3. C1- and C2-measurement coefficients quantify the effects in specific conditions.