Covariance Matrix
Covariance Matrix
Suppose there are two data sets X = {3, 2} and Y = {7, 4}. The sample
variance of dataset X = 0.5, and Y = 4.5. The covariance between X and Y
is 1.5. The covariance matrix is expressed as follows:
[0.51.51.54.5][0.51.51.54.5]
A detailed description of how to find the variance covariance matrix will
be covered in the upcoming sections.
Covariance Matrix Formula
To determine the covariance matrix, the formulas for variance and
covariance are required. Depending upon the type of data available, the
variance and covariance can be found for both sample data and
population data. These formulas are given below.
Population Variance:
Population Covariance:
Sample Variance:
Sample Covariance:
Using these formulas, the general form of a variance covariance matrix is
given as follows:
Covariance Matrix 2 × 2
A 2 × 2 matrix is one which has 2 rows and 2 columns. The formula for a 2
× 2 covariance matrix is given as follows:
Covariance Matrix 3 × 3
How To
Calculate Covariance Matrix?
1 92 80
Student Math (X) Science (Y)
2 60 30
3 100 70
The steps to calculate the covariance matrix for the sample are given
below:
Step 1: Find the mean of one variable (X). This can be done by
dividing the sum of all observations by the number of
observations. Thus, (92 + 60 + 100) / 3 = 84
Step 2: Subtract the mean from all observations; (92 - 84), (60 -
84), (100 - 84)
Step 3: Take the sum of the squares of the differences obtained
in the previous step. (92 - 84)2 + (60 - 84)2 + (100 - 84)2.
Step 4: Divide this value by 1 less than the total to get the
sample variance of the first variable (X). var(X) = [(92 - 84) 2 +
(60 - 84)2 + (100 - 84)2] / (3 - 1) = 448
Step 5: Repeat steps 1 to 4 to find the variances of all variables.
Using these steps, var(Y) = 700.
Step 6: Choose a pair of variables (X and Y).
Step 7: Subtract the mean of the first variable (X) from all
observations; (92 - 84), (60 - 84), (100 - 84).
Step 8: Repeat step 7 for the second variable (Y); (80 - 60), (30 -
60), (70 - 60).
Step 9: Multiply the corresponding observations. (92 - 84)(80 -
60), (60 - 84)(30 - 60), (100 - 84)(70 - 60).
Step 10: Add these values and divide them by (n - 1) to get
the covariance. cov(x, y) = cov(y, x) = [(92 - 84)(80 - 60) + (60 -
84)(30 - 60) + (100 - 84)(70 - 60)] / (3 - 1) = 520.
Step 11: Repeat steps 6 to 10 for different pairs of variables.
Step 12: Now using the general formula for covariance matrix
arrange these values in matrix form. Thus, the variance
covariance matrix for the example is given as
The same steps can be followed while calculating the covariance matrix
for a population. The only difference is that the population variance and
covariance formulas will be applied.
Properties of Covariance Matrix
Related Articles:
Types of Matrices
Covariance Calculator
Correlation Coefficient