---
title: "Model equations: serial mediation"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Model equations: serial mediation}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
**Purpose:** definitions and equations for `CN` (serial mediation).
For a first analysis, start with [Choose an analysis](AnalysisGuide.html#choose-your-model)
or [Get started](GetStarted.html). `GenerateModelCN()` creates the model syntax
used for this structure.
Every earlier mediator predicts every later mediator. With three mediators, this includes M1 to M3 as well as M1 to M2 and M2 to M3.
## Difference scores and centered averages
For mediator $i$, $M_{i1}$ and $M_{i2}$ are its measurements in conditions 1
and 2. Define
$$
M_{\mathrm{diff},i}=M_{i2}-M_{i1},\qquad
\widetilde M_{\mathrm{avg},i}=\frac{M_{i1}+M_{i2}}{2},\qquad
M_{\mathrm{avg},i}=\widetilde M_{\mathrm{avg},i}-\overline{\widetilde M}_{\mathrm{avg},i}.
$$
The bar denotes the sample mean used for centering. The outcome difference
is $Y_{\mathrm{diff}}=Y_2-Y_1$. `PrepareData()` constructs these variables:
`diff` is not centered, whereas `avg` is centered.
## Regression equations
The equations below show the regression part of the model without covariates
or an external moderator. All $N$ mediators predict the outcome difference:
$$
Y_{\mathrm{diff}}=c'+\sum_{i=1}^{N}\left(b_iM_{\mathrm{diff},i}+d_iM_{\mathrm{avg},i}\right)+e.
$$
The mediator equations determine the structure:
$$
M_{\mathrm{diff},i}=a_i+\sum_{j