GenerateModelPC function dynamically generates a
Structural Equation Model (SEM) formula to analyze models with multiple
parallel mediators influencing a single chained mediator for ‘lavaan’
based on the prepared dataset. This document explains the mathematical
principles and the structure of the generated model.
`
For a single chained mediator \(M_1\) and \(N\) parallel mediators \(M_2, M_3, \dots, M_{N+1}\), the model is defined as:
Outcome Difference Model (\(Y_{\text{diff}}\)): \[ Y_{\text{diff}} = cp + b_1 M_{1\text{diff}} + \sum_{i=2}^{N+1} \left( b_i M_{i\text{diff}} + d_i M_{i\text{avg}} \right) + d_1 M_{1\text{avg}} + e \]
Mediator Difference Model (\(M_{i\text{diff}}\)):
Where: - \(cp\): Direct effect of the independent variable. - \(b_1, b_i, b_{i1}\): Effects of the chained and parallel mediators. - \(d_1, d_i, d_{i1}\): Moderating effects of mediator averages. - \(\epsilon_i\): Residuals.
For each mediator, the indirect effects are calculated as:
The total effect combines the direct effect and the total indirect effect: \[ \text{total_effect} = cp + \text{total_indirect} \]
Where \(cp\) is the direct effect.
When comparing the strengths of indirect effects, the contrast between two effects is calculated as: \[ CI_{\text{path}_1\text{vs}\text{path}_2} = \text{indirect}_{\text{path}_1} - \text{indirect}_{\text{path}_2} \]
Indirect Effects:
\[ \text{indirect}_1 = a_1 \cdot b_1 \]
\[ \text{indirect}_2 = a_2 \cdot b_2 \]
\[ \text{indirect}_3 = a_3 \cdot b_3 \]
\[ \text{indirect}_{21} = a_2 \cdot b_{21} \cdot b_1 \]
\[ \text{indirect}_{31} = a_3 \cdot b_{31} \cdot b_1 \]
Comparisons:
\[ CI_{1\text{vs}2} = \text{indirect}_1 - \text{indirect}_2 \]
\[ CI_{1\text{vs}3} = \text{indirect}_1 - \text{indirect}_3 \]
\[ CI_{1\text{vs}21} = \text{indirect}_1 - \text{indirect}_{21} \]
\[ CI_{1\text{vs}31} = \text{indirect}_1 - \text{indirect}_{31} \]
\[ CI_{2\text{vs}3} = \text{indirect}_2 - \text{indirect}_3 \]
\[ CI_{2\text{vs}21} = \text{indirect}_2 - \text{indirect}_{21} \]
\[ CI_{3\text{vs}31} = \text{indirect}_3 - \text{indirect}_{31} \]
\[ CI_{21\text{vs}31} = \text{indirect}_{21} - \text{indirect}_{31} \]
C2-Measurement Coefficient (\(X1_{b,i}\)): \[ X1_{b,i} = b_i + d_i \]
C1-Measurement Coefficient (\(X0_{b,i}\)): \[ X0_{b,i} = X1_{b,i} - d_i \]
Mediator \(M_1\):
\[ X1_{b,1} = b_1 + d_1 \]
\[ X0_{b,1} = X1_{b,1} - d_1 \]
Mediator \(M_2\):
\[ X1_{b,2} = b_2 + d_2 \]
\[ X0_{b,2} = X1_{b,2} - d_2 \]
Mediator \(M_3\):
\[ X1_{b,3} = b_3 + d_3 \]
\[ X0_{b,3} = X1_{b,3} - d_3 \]
Parallel to Chained Path (\(M_2 \to M_1\)):
\[ X1_{b,21} = b_{21} + d_{21} \]
\[ X0_{b,21} = X1_{b,21} - d_{21} \]
Parallel to Chained Path (\(M_3 \to M_1\)):
\[ X1_{b,31} = b_{31} + d_{31} \]
\[ X0_{b,31} = X1_{b,31} - d_{31} \]
This section summarizes all equations used in the model:
\[ Y_{\text{diff}} = cp + b_1 M_{1\text{diff}} + \sum_{i=2}^{N+1} \left( b_i M_{i\text{diff}} + d_i M_{i\text{avg}} \right) + d_1 M_{1\text{avg}} + e \]
\[ M_{1\text{diff}} = a_1 + \sum_{i=2}^{N+1} \left( b_{i1} M_{i\text{diff}} + d_{i1} M_{i\text{avg}} \right) + \epsilon_1 \]
\[ M_{i\text{diff}} = a_i + \epsilon_i \]
\[ \text{indirect}_1 = a_1 \cdot b_1 \]
\[ \text{indirect}_i = a_i \cdot b_i \]
\[ \text{indirect}_{i1} = a_i \cdot b_{i1} \cdot b_1 \]
\[ CI_{\text{path}_1\text{vs}\text{path}_2} = \text{indirect}_{\text{path}_1} - \text{indirect}_{\text{path}_2} \]
\[ X1_{b,i} = b_i + d_i \]
\[ X0_{b,i} = X1_{b,i} - d_i \]
This comprehensive approach supports models with parallel mediators influencing a chained mediator, enabling detailed analysis of their effects and interactions.