The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
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[@]dogado.de.
GenerateModelCP function dynamically generates a
Structural Equation Model (SEM) formula to analyze models with a single
chained mediator and multiple parallel mediators 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}}\)): For the chained mediator (\(M_1\)): \[ M_{1\text{diff}} = a_1 + \epsilon_1 \] For parallel mediators (\(M_2, \dots, M_{N+1}\)): \[ M_{i\text{diff}} = a_i + b_{1i} M_{1\text{diff}} + d_{1i} M_{1\text{avg}} + \epsilon_i \]
Where: - \(cp\): Direct effect of the independent variable. - \(b_1, b_i\): Effects of the chained and parallel mediators. - \(d_1, d_i, d_{1i}\): Moderating effects of mediator averages. - \(\epsilon_i\): Residuals.
For each mediator, the indirect effects are calculated as:
Single-Mediator Effects: For the chained mediator: \[ \text{indirect}_1 = a_1 \cdot b_1 \] For the parallel mediators (\(M_2, \dots, M_{N+1}\)): \[ \text{indirect}_i = a_i \cdot b_i \]
Chained Path Effects: For paths from the chained mediator through the parallel mediators: \[ \text{indirect}_{1i} = a_1 \cdot b_{1i} \cdot b_i \]
Total Indirect Effect: The total indirect effect is the sum of all individual indirect effects: \[ \text{total_indirect} = \text{indirect}_1 + \sum_{i=2}^{N+1} \left( \text{indirect}_i + \text{indirect}_{1i} \right) \]
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}_{12} = a_1 \cdot b_{12} \cdot b_2 \]
\[ \text{indirect}_{13} = a_1 \cdot b_{13} \cdot b_3 \]
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}12} = \text{indirect}_1 - \text{indirect}_{12} \]
\[ CI_{1\text{vs}13} = \text{indirect}_1 - \text{indirect}_{13} \]
\[ CI_{2\text{vs}3} = \text{indirect}_2 - \text{indirect}_3 \]
\[ CI_{2\text{vs}12} = \text{indirect}_2 - \text{indirect}_{12} \]
\[ CI_{2\text{vs}13} = \text{indirect}_2 - \text{indirect}_{13} \]
\[ CI_{3\text{vs}12} = \text{indirect}_3 - \text{indirect}_{12} \]
\[ CI_{3\text{vs}13} = \text{indirect}_3 - \text{indirect}_{13} \]
\[ CI_{12\text{vs}13} = \text{indirect}_{12} - \text{indirect}_{13} \]
C2-Measurement Coefficient (\(X1_{b,i}\)): \[ X1_{b,i} = b_i + d_i/2 \]
C1-Measurement Coefficient (\(X0_{b,i}\)): \[ X0_{b,i} = X1_{b,i} - d_i \]
Mediator \(M_1\):
\[ X1_{b,1} = b_1 + d_1/2 \]
\[ X0_{b,1} = X1_{b,1} - d_1 \]
Mediator \(M_2\):
\[ X1_{b,2} = b_2 + d_2/2 \]
\[ X0_{b,2} = X1_{b,2} - d_2 \]
Mediator \(M_3\):
\[ X1_{b,3} = b_3 + d_3/2 \]
\[ X0_{b,3} = X1_{b,3} - d_3 \]
Chained Path (\(M_1 \to M_2\)):
\[ X1_{b,12} = b_{12} + d_{12}/2 \]
\[ X0_{b,12} = X1_{b,12} - d_{12} \]
Chained Path (\(M_1 \to M_3\)):
\[ X1_{b,13} = b_{13} + d_{13}/2 \]
\[ X0_{b,13} = X1_{b,13} - d_{13} \]
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 + \epsilon_1 \]
\[ M_{i\text{diff}} = a_i + b_{1i} M_{1\text{diff}} + d_{1i} M_{1\text{avg}} + \epsilon_i \]
\[ \text{indirect}_1 = a_1 \cdot b_1 \]
\[ \text{indirect}_i = a_i \cdot b_i \]
\[ \text{indirect}_{1i} = a_1 \cdot b_{1i} \cdot b_i \]
\[ 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/2 \]
\[ X0_{b,i} = X1_{b,i} - d_i \]
This comprehensive approach supports models with both chained and parallel mediators, enabling detailed analysis of their effects and interactions.
GenerateModel*() constructs the unstandardized model
syntax. Request standardized estimates when fitting with
wsMed(..., standardized = TRUE). PrepareData()
uses condition-2 minus condition-1 differences and centered mediator
averages. Differences are scaled without recentering; centering the
average component changes the intercept, not the slopes above.
Let \(s_{D M_i}\), \(s_{A M_i}\) and \(s_{D Y}\) denote the marginal model-implied SDs of mediator differences, centered mediator averages and the outcome difference. Then
\[ a_i^*=a_i/s_{D M_i},\quad b_i^*=b_i s_{D M_i}/s_{D Y},\quad d_i^*=d_i s_{A M_i}/s_{D Y},\quad c'^*=c'/s_{D Y}. \]
A mediator-to-mediator coefficient uses its own source and destination SDs. Intermediate SDs cancel in a serial indirect-effect product, so every complete indirect effect satisfies \(IE^*(w)=IE(w)/s_{D Y}\). The same common marginal outcome SD applies across moderator values and categorical groups. Sum all model-implied indirect paths when computing the total indirect effect.
With moderators, use result$moderation_std for
standardized conditional effects and retain
result$moderation for raw effects. MP selects
requested interactions and focal paths; already-fitted moderator main
effects also enter conditional intercepts even when the corresponding
a or cp is absent from MP. See Standardized moderated
mediation for continuous and categorical examples, joint-draw
intervals and plots.
The condition-specific slopes above are reconstructed on the raw scale: \(X1_b=b+d/2\) and \(X0_b=b-d/2\). Do not apply this reconstruction directly to standardized \(b^*\) and \(d^*\), whose predictor scale factors differ. A difference between two indirect effects is a contrast estimate; its confidence interval must be computed from the joint sampling distribution.
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.
Health stats visible at Monitor.