Tutorials › Probability Theory (Graduate) › Conditional Variance Decomposition

Conditional Expectation · Tutorial 245 of 946

Conditional Variance Decomposition

Learn how variability splits into within-group and between-group components, both conditionally and unconditionally.

Intermediate 10 min read

What You'll Learn

  • Define conditional variance using conditional expectation and verify its equivalent second-moment formula.
  • Prove the conditional variance decomposition for nested sigma-algebras.
  • Derive the law of total variance from the nested identity.
  • Calculate within-group and between-group variance in finite examples.
  • Recognize the integrability assumptions and the role of almost-sure equality.

Why Decompose Variance?

Variance measures the spread of a random variable around its mean. When information is available, part of that spread may be explained by what is known, while the remaining spread reflects variability even after conditioning on that information. Conditional variance makes this distinction precise.

The resulting decomposition is useful whenever data or outcomes fall into groups. One term measures average variability within the groups; the other measures variability between their conditional means. Both terms are nonnegative, so the decomposition also identifies exactly how much of the total variance is attributable to each source.

Definition and Basic Formula

Let \(X\) be a real-valued random variable with finite second moment, so that \(\mathbb{E}[X^2]<\infty\), and let \(\mathcal{G}\) be a sigma-algebra. The conditional expectation \(\mathbb{E}[X\mid\mathcal{G}]\) is square-integrable. The conditional variance is defined by centering \(X\) at this conditional expectation and then taking the conditional expectation of the squared deviation.

Definition: The conditional variance of \(X\) given \(\mathcal{G}\) is the \(\mathcal{G}\)-measurable random variable \(\operatorname{Var}(X\mid\mathcal{G})=\mathbb{E}[(X-\mathbb{E}[X\mid\mathcal{G}])^2\mid\mathcal{G}]\). It is defined up to almost-sure equality.

It is nonnegative almost surely, since it is the conditional expectation of a nonnegative random variable. Expanding the square gives a useful equivalent expression:

$$ \operatorname{Var}(X\mid\mathcal{G}) = \mathbb{E}[X^2\mid\mathcal{G}] - \mathbb{E}[X\mid\mathcal{G}]^2 \quad\text{almost surely}. $$

To verify the formula, put \(M=\mathbb{E}[X\mid\mathcal{G}]\). By the pull-out property, \(\mathbb{E}[XM\mid\mathcal{G}]=M\mathbb{E}[X\mid\mathcal{G}]=M^2\), and \(\mathbb{E}[M^2\mid\mathcal{G}]=M^2\). Therefore, conditioning the expansion \(X^2-2XM+M^2\) gives \(\mathbb{E}[X^2\mid\mathcal{G}]-M^2\), as claimed.

When \(\mathcal{G}\) represents known information, \(\mathbb{E}[X\mid\mathcal{G}]\) is the conditional center, and \(\operatorname{Var}(X\mid\mathcal{G})\) is the remaining squared spread around that center. Both are random variables: their values can depend on what the conditioning information reveals.

Worked Example: A Bernoulli Outcome with Two Possible Success Rates

Let \(Z\) take values \(0\) and \(1\), each with probability \(1/2\). Conditional on \(Z=0\), let \(X\) be Bernoulli with success probability \(1/4\); conditional on \(Z=1\), let it be Bernoulli with success probability \(3/4\). Given \(Z\), the conditional mean and variance are \(p_Z\) and \(p_Z(1-p_Z)\), where \(p_0=1/4\) and \(p_1=3/4\).

The overall mean is \(\mathbb{E}[X]=(1/2)(1/4)+(1/2)(3/4)=1/2\). Since \(X\) is itself Bernoulli with success probability \(1/2\), its variance is \((1/2)(1-1/2)=1/4\). The average conditional variance is

$$ \mathbb{E}[\operatorname{Var}(X\mid\sigma(Z))] = \frac12\left(\frac14\cdot\frac34\right) + \frac12\left(\frac34\cdot\frac14\right) = \frac{3}{16}. $$

The conditional mean is \(1/4\) or \(3/4\), each with probability \(1/2\). Its variance is \(\frac12(1/4-1/2)^2+\frac12(3/4-1/2)^2=1/16\). Thus the within-state and between-state contributions add to the total:

$$ \frac{3}{16}+\frac{1}{16}=\frac14=\operatorname{Var}(X). $$

The outcome has variability both within each state and because the success rate changes between states.

Conditional Variance Decomposition

Suppose \(\mathcal{G}\subseteq\mathcal{H}\), so that \(\mathcal{H}\) represents at least as much information as \(\mathcal{G}\). The decomposition compares the variation remaining after conditioning on the coarser information with two contributions: expected variation after the finer information is known, and variation in the finer conditional mean as seen from the coarser information.

Theorem (Conditional variance decomposition): Let \(X\) be square-integrable, and let \(\mathcal{G}\subseteq\mathcal{H}\) be sigma-algebras. Then \(\operatorname{Var}(X\mid\mathcal{G})=\mathbb{E}[\operatorname{Var}(X\mid\mathcal{H})\mid\mathcal{G}]+\operatorname{Var}(\mathbb{E}[X\mid\mathcal{H}]\mid\mathcal{G})\) almost surely.

Proof. Write \(U=\mathbb{E}[X\mid\mathcal{H}]\) and \(V=\mathbb{E}[X\mid\mathcal{G}]\). The tower property gives \(\mathbb{E}[U\mid\mathcal{G}]=V\). Decompose the deviation from the coarser conditional mean as \(X-V=(X-U)+(U-V)\), then square and condition on \(\mathcal{G}\).

$$ \operatorname{Var}(X\mid\mathcal{G}) = \mathbb{E}[(X-U)^2\mid\mathcal{G}] + 2\mathbb{E}[(X-U)(U-V)\mid\mathcal{G}] + \mathbb{E}[(U-V)^2\mid\mathcal{G}]. $$

All terms are integrable: \(X,U,V\) are square-integrable, and products of square-integrable random variables are integrable. Since \(U-V\) is \(\mathcal{H}\)-measurable, the pull-out property and \(\mathbb{E}[X-U\mid\mathcal{H}]=0\) imply \(\mathbb{E}[(X-U)(U-V)\mid\mathcal{H}]=0\). Applying the tower property shows that the cross term conditioned on \(\mathcal{G}\) is also zero.

For the first term, apply the tower property to condition first on \(\mathcal{H}\). Its inner conditional expectation is \(\operatorname{Var}(X\mid\mathcal{H})\). The last term is the conditional variance of \(U\) given \(\mathcal{G}\), because \(\mathbb{E}[U\mid\mathcal{G}]=V\). Substitution proves the identity:

$$ \operatorname{Var}(X\mid\mathcal{G}) = \mathbb{E}[\operatorname{Var}(X\mid\mathcal{H})\mid\mathcal{G}] + \operatorname{Var}(U\mid\mathcal{G}). \qquad\square $$

The Law of Total Variance

The unconditional identity is a direct special case, but the choice of sigma-algebras matters. In the conditional theorem, take the coarser sigma-algebra \(\mathcal{G}=\{\varnothing,\Omega\}\), and take \(\mathcal{H}\) to be an arbitrary sigma-algebra. Conditioning on the trivial sigma-algebra gives constant random variables, equal almost surely to their expectations. Thus the conditional decomposition becomes the law of total variance.

Theorem (Law of total variance): If \(X\) is square-integrable and \(\mathcal{H}\) is a sigma-algebra, then \(\operatorname{Var}(X)=\mathbb{E}[\operatorname{Var}(X\mid\mathcal{H})]+\operatorname{Var}(\mathbb{E}[X\mid\mathcal{H}])\).

Proof. Apply the conditional variance decomposition with the trivial sigma-algebra as \(\mathcal{G}\) and the given \(\mathcal{H}\) as the finer sigma-algebra. The left side is the constant \(\operatorname{Var}(X)\); the first term on the right is the constant \(\mathbb{E}[\operatorname{Var}(X\mid\mathcal{H})]\); and the second is the constant variance of \(\mathbb{E}[X\mid\mathcal{H}]\). Equating these constants gives the result.

$$ \operatorname{Var}(X) = \mathbb{E}[\operatorname{Var}(X\mid\mathcal{H})] + \operatorname{Var}(\mathbb{E}[X\mid\mathcal{H}]). \qquad\square $$

The first term is the expected conditional variance, or average within-group variation. The second is the variance of the conditional mean, or between-group variation. The formula is also a useful check on calculations: omitting either contribution generally understates the total variance.

Discrete Calculations

For a finite partition, conditioning is especially concrete. The conditional expectation is constant on each partition cell with positive probability, and equals the average of \(X\) on that cell. The conditional variance on that cell is the average squared deviation from that cell's conditional mean. Cells of probability zero do not affect any of these identities; conditional expectations and variances are specified only up to almost-sure equality.

Worked Example: A Die Conditioned on Its Parity

Let \(X\) be the result of a fair six-sided die, and let \(\mathcal{G}\) record whether the result is odd or even. Given an odd result, the possible values \(1,3,5\) have mean \(3\) and variance \(\big((1-3)^2+(3-3)^2+(5-3)^2\big)/3=8/3\). Given an even result, the values \(2,4,6\) have mean \(4\) and variance \(\big((2-4)^2+(4-4)^2+(6-4)^2\big)/3=8/3\). Hence \(\mathbb{E}[\operatorname{Var}(X\mid\mathcal{G})]=8/3\).

The conditional mean is \(3\) or \(4\), each with probability \(1/2\), so its variance is \(\frac12(3-7/2)^2+\frac12(4-7/2)^2=1/4\). Directly, \(\mathbb{E}[X]=7/2\) and \(\mathbb{E}[X^2]=(1+4+9+16+25+36)/6=91/6\), giving \(\operatorname{Var}(X)=91/6-(7/2)^2=35/12\). The decomposition agrees:

$$ \frac{8}{3}+\frac{1}{4}=\frac{32}{12}+\frac{3}{12}=\frac{35}{12}. $$

Worked Example: A Finer Partition Within Two Groups

Let \(\Omega=\{1,2,3,4\}\) have equal probabilities, and define \(X(1)=0\), \(X(2)=2\), \(X(3)=1\), and \(X(4)=5\). Let \(\mathcal{G}\) distinguish the groups \(\{1,2\}\) and \(\{3,4\}\), and let \(\mathcal{H}\) be the full sigma-algebra. Since \(\mathcal{H}\) reveals the outcome exactly, \(\operatorname{Var}(X\mid\mathcal{H})=0\) and \(\mathbb{E}[X\mid\mathcal{H}]=X\).

On \(\{1,2\}\), the conditional mean is \(1\) and the conditional variance is \(((0-1)^2+(2-1)^2)/2=1\). On \(\{3,4\}\), the mean is \(3\) and the variance is \(((1-3)^2+(5-3)^2)/2=4\). Thus \(\operatorname{Var}(X\mid\mathcal{G})\) takes values \(1\) and \(4\), each with probability \(1/2\).

In the conditional decomposition, the expected variance given \(\mathcal{H}\) is zero. The conditional variance of \(\mathbb{E}[X\mid\mathcal{H}]=X\), given \(\mathcal{G}\), is \(1\) on the first group and \(4\) on the second, exactly matching \(\operatorname{Var}(X\mid\mathcal{G})\). For the unconditional identity, the overall mean is \(2\), and the second moment is \((0+4+1+25)/4=15/2\), so \(\operatorname{Var}(X)=15/2-4=7/2\). The average group variance is \((1+4)/2=5/2\), while the variance of the group means \(1\) and \(3\) is \(1\). Therefore:

$$ \frac{5}{2}+1=\frac{7}{2}=\operatorname{Var}(X). $$

Interpretation and a Common Pitfall

The decomposition separates two kinds of uncertainty without asserting that either component is constant. In the conditional identity, each side is a \(\mathcal{G}\)-measurable random variable: the equality holds almost surely, cell by cell when conditioning on a finite partition. In the unconditional identity, taking expectations averages the within-group component, while the variance of the conditional mean quantifies differences between groups.

A common error is to use \(\mathbb{E}[X\mid\mathcal{H}]\) in the between-group term but forget that its variance is taken with respect to the original probability measure. Another is to confuse \(\mathbb{E}[\operatorname{Var}(X\mid\mathcal{H})]\) with \(\operatorname{Var}(X\mid\mathcal{H})\): the former is a number, while the latter is generally a random variable. Keep the levels of conditioning visible, and check that both terms have the same status as the left side.

Square-integrability is important: it ensures that the variances and the products in the proof are integrable. The identities are statements about equivalence classes up to almost-sure equality, as is standard for conditional expectations. They do not require a particular pointwise choice of versions.

Check Your Understanding

Use the definitions and decompositions to answer the following questions.

  1. Why is the conditional variance nonnegative almost surely?
  2. In the nested decomposition, which sigma-algebra represents the coarser information?
  3. For the die conditioned on parity, what are the within-group and between-group contributions to the total variance?
  4. When deriving the unconditional law of total variance from the conditional identity, what should \(\mathcal{G}\) and \(\mathcal{H}\) be?
  5. Why must \(X\) be square-integrable for the stated variance decomposition?
Clinical Biostats