The Covariance Matrix

For a random vector with multiple components, the covariance matrix collects all pairwise variances and covariances into a single symmetric square matrix. This lesson defines the covariance matrix, builds 2x2 and 3x3 examples from given variances and covariances, and reads variances, standard deviations, covariances, and correlation coefficients back out of a given covariance matrix.

Step 1 of 157%

Tutorial

Introduction

Often we want to track the variability and pairwise relationships of several random variables at once. The covariance matrix packages all of this information into a single square matrix.

Given a random vector X=(X1,X2,,Xn)T,\mathbf{X} = (X_1, X_2, \ldots, X_n)^T, its covariance matrix is the n×nn \times n matrix Σ\Sigma whose entry in row ii and column jj is the covariance between XiX_i and Xj:X_j{:}

Σij=Cov(Xi,Xj).\Sigma_{ij} = \text{Cov}(X_i, X_j).

Written out, this is

Σ=[Cov(X1,X1)Cov(X1,X2)Cov(X1,Xn)Cov(X2,X1)Cov(X2,X2)Cov(X2,Xn)Cov(Xn,X1)Cov(Xn,X2)Cov(Xn,Xn)].\Sigma = \begin{bmatrix} \text{Cov}(X_1, X_1) & \text{Cov}(X_1, X_2) & \cdots & \text{Cov}(X_1, X_n) \\ \text{Cov}(X_2, X_1) & \text{Cov}(X_2, X_2) & \cdots & \text{Cov}(X_2, X_n) \\ \vdots & \vdots & \ddots & \vdots \\ \text{Cov}(X_n, X_1) & \text{Cov}(X_n, X_2) & \cdots & \text{Cov}(X_n, X_n) \end{bmatrix}.

Two facts make this matrix easy to read off:

  • Diagonal entries are variances. Since Cov(Xi,Xi)=Var(Xi),\text{Cov}(X_i, X_i) = \text{Var}(X_i), the main diagonal lists the variances Var(X1),Var(X2),,Var(Xn).\text{Var}(X_1), \text{Var}(X_2), \ldots, \text{Var}(X_n).

  • The matrix is symmetric. Since Cov(Xi,Xj)=Cov(Xj,Xi),\text{Cov}(X_i, X_j) = \text{Cov}(X_j, X_i), the entry in row i,i, column jj equals the entry in row j,j, column i.i.

For two random variables XX and YY with Var(X)=2,\text{Var}(X) = 2, Var(Y)=8,\text{Var}(Y) = 8, and Cov(X,Y)=1,\text{Cov}(X, Y) = -1, the covariance matrix is

Σ=[Var(X)Cov(X,Y)Cov(Y,X)Var(Y)]=[2118].\Sigma = \begin{bmatrix} \text{Var}(X) & \text{Cov}(X, Y) \\ \text{Cov}(Y, X) & \text{Var}(Y) \end{bmatrix} = \begin{bmatrix} 2 & -1 \\ -1 & 8 \end{bmatrix}.
navigate · Enter open · Esc close · ⌘K/Ctrl K toggle