6 Expectation, Variance, and Covariance
This section presents random variable definitions, cdf/pdf/pmf tools, expectations, variances, covariance, and distributional transformations used in applied theory and empirical work.
6.1 Expectation
6.1.1 Expectation of a discrete random variable
The expectation (or expected value, or mean) of a discrete random variable \(X\) is defined as:
\[ E(X) = \sum_{x_i \in \text{Support of } X} x_i P(X = x_i) \]
where \(P(X = x_i)\) is the probability that the random variable \(X\) takes on the value \(x_i\).
6.1.2 Expectation of a continuous random variable
The expectation (or expected value, or mean) of a continuous random variable \(X\) is defined as:
\[ E(X) = \int_{-\infty}^{\infty} x f_X(x) dx \]
where \(f_X(x)\) is the probability density function of the random variable \(X\).
6.1.3 Expectation of a transformation of a random variable
We have random variable \(X\) and density \(f(x)\), and we define a new random variable \(Y = g(X)\), where \(g\) is some function. Then the expectation of \(Y\) is:
\[ E(Y) = E(g(X)) = \int_{-\infty}^{\infty} g(x) f_X(x) dx \]
So if \(Y = g(X) = aX + b\), then
\[ E(Y) = E(aX + b) = \int_{-\infty}^{\infty} (ax + b) f_X(x) dx = a \int_{-\infty}^{\infty} x f_X(x) dx + b \int_{-\infty}^{\infty} f_X(x) dx = aE(X) + b \]
Note that expectation is a linear operator.
6.2 Variance
6.2.1 Variance of a discrete random variable
The variance of a discrete random variable \(X\) is defined as:
\[ Var(X) = E[(X - E(X))^2] = \sum_{x_i \in \text{Support of } X} (x_i - E(X))^2 P(X = x_i) \]
where \(E(X)\) is the expectation of \(X\).
6.2.2 Variance of a continuous random variable
The variance of a continuous random variable \(X\) is defined as:
\[ Var(X) = E[(X - E(X))^2] = \int_{-\infty}^{\infty} (x - E(X))^2 f_X(x) dx \]
where \(f_X(x)\) is the probability density function of \(X\).
6.2.3 Variance transformation of a random variable
Suppose \(Y = g(X) = X \cdot \delta + \gamma\), then the variance of \(Y\) is:
\[ Var(Y) = Var(g(X)) = Var(X \cdot \delta + \gamma) = \delta^2 Var(X) \]
6.2.4 Variance decomposition
Total variance is equal to the sum of the expected conditional variance and the variance of the conditional expectation:
\[ Var(X) = E(Var(X|Y)) + Var(E(X|Y)) \]
We can write these out in integral form:
\[ Var(X) = \int \int \left(x - \int x dF(x|y) \right)^2 dF(x|y) dF(y) + \int \left( \int x dF(x|y) - \int x dF(x) \right)^2 dF(y) \]
6.2.5 Variance decomposition derivation
There is a sample with \(N\) individuals, where \(P(n)\) is the sample weight such that \(\sum_{n=1}^N P(n)=1\). These individuals belong to \(S>1\) mutually exclusive and exhaustive counties in the United States, denoted as \(\left\{C_s\right\}_{s=1}^S\), where \(s\) is the county-index. This means that \(\cup_{s=1}^{S} C_s = \left\{ n \in \mathbb{N} : 0 < n \le N \right\}\) and \(C_s \cap C_{s'} = \emptyset\) for all \(s\neq s'\).
Alternatively, we can think of \(N\) as the count for all locations in a world (degree square by longitude and latitude for example), \(P(n)\) is the share of population in each location among world population, and \(S\) is the number of countries in the world, with \(C_s\) as the set containing all locations for each country.
As another example, we can think of \(N\) as the count for all counties in a country, \(P(n)\) is the share of population in each county with respect to the country. And \(S\) is the number of regions in the country.
Let \(\mu = \sum_{s=1}^{S} \sum_{n\in C_s} P(n)\cdot X_n\) be the overall weighted mean. And let \(\mu_s\) be the weighted mean for group \(s\):
\[ \begin{aligned} \mu_s = \sum_{n\in C_s} \frac{P(n)}{\sum_{\widehat{n}\in C_s} P(\widehat{n})} \cdot X_n \end{aligned} \]
The overall variance can be decomposed as follows:
\[ \begin{aligned} \sum_{s=1}^{S} \sum_{n\in C_s} P(n) \left(X_n - \mu \right)^2 = \sum_{s=1}^{S} \sum_{n\in C_s} P(n) \left(X_n - \mu_s\right)^2 + 2\sum_{s=1}^{S} \sum_{n\in C_s} P(n) \left(X_n - \mu_s\right)\left(\mu_s - \mu\right) + \sum_{s=1}^{S} \sum_{n\in C_s} P(n) \left(\mu_s - \mu\right)^2 \end{aligned} \]
The first term in the summation above is the within-group component of variance and is equal to the weighted sum across groups of each group-specific within-group variance:
\[ \begin{aligned} \sum_{s=1}^{S} \sum_{n\in C_s} P(n) \left(X_n - \mu_s\right)^2 = \sum_{s=1}^{S} \left(\sum_{n\in C_s} P(n)\right) \left( \sum_{n\in C_s} \frac{P(n)}{\sum_{\widehat{n}\in C_s} P(\widehat{n})} \left(X_n - \mu_s\right)^2 \right) \end{aligned} \]
The third term in the summation earlier provides the across-group component of variance and is equal to:
\[ \begin{aligned} &\sum_{s=1}^{S} \sum_{n\in C_s} P(n) \left(\mu_s - \mu\right)^2\\ =&\sum_{s=1}^{S} \left( \left(\mu_s - \mu\right)^2\cdot \sum_{n\in C_s} P(n) \right)\\ \end{aligned} \]
The middle term divided by \(2\) in the summation earlier is equal to zero, which means the overall variance is equal to the weighted sum of within-group variances and across-group variance just derived above. Specifically, the middle term divided by \(2\) is equal to zero as shown via the derivations below:
\[ \begin{aligned} &\sum_{s=1}^S \sum_{n\in C_s} P(n)\,(X_n - \mu_s)(\mu_s - \mu) \\ =& \sum_{s=1}^S (\mu_s - \mu) \sum_{n\in C_s} P(n)(X_n - \mu_s) \\ =& \sum_{s=1}^S (\mu_s - \mu) \left(\sum_{n\in C_s} P(n)X_n - \mu_s \sum_{n\in C_s} P(n)\right) \\ =& 0 \end{aligned} \]
This is because, by the definition of \(\mu_s\), \(\sum_{n\in C_s} P(n)X_n = \mu_s\sum_{n\in C_s} P(n)\) for each group \(s\), so each bracketed term is zero.
Therefore, the total variance is the weighted sum of within-group variances plus the across-group variance.
6.3 Covariance
6.3.1 Two random variables
There are two random variables that live in the same probability space.
6.3.2 Covariance of two discrete random variables
The covariance of two discrete random variables \(X\) and \(Y\) is defined as:
\[\begin{align*} &Cov(X, Y) \\ =& E[(X - E(X))(Y - E(Y))]\\ =& \sum_{x_i \in \text{Support of } X} \sum_{y_j \in \text{Support of } Y} (x_i - E(X))(y_j - E(Y)) P(X = x_i, Y = y_j) \end{align*}\]
where \(E(X)\) and \(E(Y)\) are the expectations of \(X\) and \(Y\), respectively.
6.3.3 Covariance of two continuous random variables
The covariance of two continuous random variables \(X\) and \(Y\) is defined as:
\[\begin{align*} &Cov(X, Y) \\ =& E[(X - E(X))(Y - E(Y))]\\ =& \int_{-\infty}^{\infty} \int_{-\infty}^{\infty} (x - E(X))(y - E(Y)) f_{X,Y}(x,y) dx dy \end{align*}\]
where \(E(X)\) and \(E(Y)\) are the expectations of \(X\) and \(Y\), respectively, and \(f_{X,Y}(x,y)\) is the joint density function of \(X\) and \(Y\).
6.3.4 Covariance transformation of a random variable
Suppose \(\widehat{X} = g(X) = X \cdot \delta_x + \gamma_x\), and \(\widehat{Z} = h(Y) = Y \cdot \delta_y + \gamma_y\) then the covariance of \(\widehat{X}\) and \(\widehat{Z}\) are:
\[ Cov(\widehat{X}, \widehat{Z}) = Cov(g(X), h(Y)) = Cov(X \cdot \delta_x + \gamma_x, Y \cdot \delta_y + \gamma_y) = \delta_x \delta_y Cov(X, Y) \]
6.3.5 Covariance and measurement system to identify factor loadings
Let \(i\) index children and \(j\in\{1,2,3\}\) index tests. Let \(M_{ij}\) be child \(i\)’s score on test \(j\), and let \(\theta_i\) be latent skill. Consider the measurement model:
Write down a system of measurement equations with test-specific factor loading and means. Make appropriate assumptions, and derive using the variance-covariance matrix of test scores as well as the mean scores the parameters of the child skill measurement equations.
\[ M_{ij} = \mu_j + \lambda_j \theta_i + \epsilon_{ij} \]
Assume \(E[\theta_i]=0\), \(E[\epsilon_{ij}]=0\), \(\operatorname{Var}(\theta_i)>0\), and \(\operatorname{Cov}(\theta_i,\epsilon_{ij})=0\). Also assume errors from different tests are uncorrelated: \(\operatorname{Cov}(\epsilon_{ij},\epsilon_{ik})=0\) for \(j\ne k\). These assumptions make \(\mu_j=E[M_{ij}]\).
Normalize the latent scale by setting \(\lambda_1=1\). The variance-covariance matrix then satisfies, for distinct tests \(j\) and \(k\),
\[ \operatorname{Cov}(M_{ij},M_{ik})=\lambda_j\lambda_k\operatorname{Var}(\theta_i). \]
Provided the relevant cross-test covariances are nonzero, the other loadings are identified by
\[ \lambda_2=\frac{\operatorname{Cov}(M_{i2},M_{i3})}{\operatorname{Cov}(M_{i1},M_{i3})}, \qquad \lambda_3=\frac{\operatorname{Cov}(M_{i2},M_{i3})}{\operatorname{Cov}(M_{i1},M_{i2})}. \]
The latent-skill variance is then
\[ \operatorname{Var}(\theta_i)= \frac{\operatorname{Cov}(M_{i1},M_{i2})\operatorname{Cov}(M_{i1},M_{i3})} {\operatorname{Cov}(M_{i2},M_{i3})}. \]
Finally, the test-specific error variances follow from \(\operatorname{Var}(\epsilon_{ij})=\operatorname{Var}(M_{ij})-\lambda_j^2\operatorname{Var}(\theta_i)\). The zero-mean normalization for \(\theta_i\) is needed for the means to identify \(\mu_j\); without a location normalization, the latent mean and intercepts are not separately identified.