Code
time <- c(400, 500, 600)
mass_low <- c(.20, .50, .30)
mass_high <- c(.60, .30, .10)
mean_low <- sum(time * mass_low)
mean_high <- sum(time * mass_high)
marginal_mean <- .30 * mean_low + .70 * mean_high
c(mean_low, mean_high, marginal_mean)The expected value page averaged with respect to a complete distribution, while the marginal distribution page recovered a one-variable distribution by summing out another variable. Conditional expectation instead averages the response under one conditional distribution. Suppose Y is lexical decision time and X records whether the target word is highly predictable in context.
For low predictability, let the conditional PMF be
| decision time y | p_{Y\mid X}(y\mid\mathrm{low}) |
|---|---|
| 400 ms | .20 |
| 500 ms | .50 |
| 600 ms | .30 |
For high predictability, let it be
| decision time y | p_{Y\mid X}(y\mid\mathrm{high}) |
|---|---|
| 400 ms | .60 |
| 500 ms | .30 |
| 600 ms | .10 |
Each table is a complete distribution of Y within one value of X.
The expected decision time is
\begin{aligned} \mathbb{E}[Y\mid X=\mathrm{low}] &=400(.20)+500(.50)+600(.30)\\ &=80+250+180\\ &=510\text{ ms}. \end{aligned}
The corresponding expectation is
\begin{aligned} \mathbb{E}[Y\mid X=\mathrm{high}] &=400(.60)+500(.30)+600(.10)\\ &=240+150+60\\ &=450\text{ ms}. \end{aligned}
These values are conditional expectations. Each expectation uses the conditional distribution of Y at one declared value of X.
For discrete variables and a value x with p_X(x)>0, provided the absolute sum is finite,
\mathbb{E}[Y\mid X=x] \equiv\sum_y y\,p_{Y\mid X}(y\mid x).
When a conditional density f_{Y\mid X}(\,\cdot\mid x) exists and the absolute integral is finite,
\mathbb{E}[Y\mid X=x] \equiv\int y f_{Y\mid X}(y\mid x)\,\mathrm{d}y.
Define
m(x)\equiv\mathbb{E}[Y\mid X=x].
For the two predictability conditions,
m(\mathrm{low})=510
and
m(\mathrm{high})=450.
The function maps a predictor value to the center of the response distribution under that condition. Regression models later specify how this function changes with one or more predictors.
The conditional contrast is
m(\mathrm{high})-m(\mathrm{low}) =450-510 =-60\text{ ms}.
Under the constructed model, the conditional mean for high predictability is 60 ms lower than the conditional mean for low predictability.
Suppose high predictability contexts receive probability .70 and low predictability contexts receive .30. The marginal expectation is
\begin{aligned} \mathbb{E}[Y] &=.70(450)+.30(510)\\ &=315+153\\ &=468\text{ ms}. \end{aligned}
This is an application of iterated expectation:
\mathbb{E}[Y] =\mathbb{E}\!\left[\mathbb{E}[Y\mid X]\right].
The outer expectation averages the conditional means using the distribution of X.
time <- c(400, 500, 600)
mass_low <- c(.20, .50, .30)
mass_high <- c(.60, .30, .10)
mean_low <- sum(time * mass_low)
mean_high <- sum(time * mass_high)
marginal_mean <- .30 * mean_low + .70 * mean_high
c(mean_low, mean_high, marginal_mean)The returned values are 510, 450, and 468.
The marginal mean can change because the proportions of the conditions change, even when the conditional distributions remain fixed. If the share of high predictability contexts changes, the marginal mean changes even when both conditional PMFs remain fixed.
Report conditional means and the condition mixture separately. A marginal difference need not imply that the within condition response process changed.
Conditional expectation compares response centers across conditions. The next page summarizes whether paired deviations of two numerical variables tend to share a direction.