How to Calculate a Variance-Covariance Matrix

In statistics, a variance covariance matrix is a way of representing the relationships among a set of two or more variables. It is a square array of numbers, with as many rows and columns as there are variables. The variances are written on the main diagonal from upper left to lower right and the covariances in all other cells of the matrix.



The variance of a variable is a measure of how spread out its distribution is. The covariance between two variables is a measure of how strongly they are related.

Instructions

  1. Calculate the Variances

    • 1

      Find the mean of the first variable in your data set. The mean is the sum of all the values divided by the number of values. For example, if your data set has values for the heights, weights and ages of people, find the mean of height.

    • 2

      For each value, find the difference between the value and the mean for that variable.

    • 3

      Square the differences found in step 2.

    • 4

      Add the squares found in step 3. This is the variance for that variable.

    • 5

      Repeat steps 1 to 4 for each remaining variable.

    Calculate the Covariances

    • 6

      Multiply the values of the first two variables in your data set. In the example, multiply the height of each person by the weight of that person.

    • 7

      Find the mean of the product in step 1.

    • 8

      Multiply the mean of the first variable by the mean of the second variable. In the example, multiply the mean height by the mean weight that were found in section 1.

    • 9

      Subtract the product in step 3 from the product in step 2. This is the covariance of the first two variables (in the example, height and weight).

    • 10

      Repeat steps 1 through 4 for each remaining pair of variables. In the example, these would be height and age and weight and age.

    Assemble the Matrix

    • 11

      Make a table with one more row and one more column than the number of variables. In the example, this would equal four rows and four columns

    • 12

      Label the rows and columns with the variable names. In the example, the labels would be "height," "weight" and "age."

    • 13

      Write the variances in the main diagonal. In the example, write the variances of height, weight and age in the second, third and fourth cell along the main diagonal.

    • 14

      Write the covariances in the off-diagonal cells. Each covariance is written twice, in a symmetric fashion. In the example, write the covariance of height and weight in the cell for the height column and the weight row and also in the cell for the height row and the weight column. Do this for each pair of variables.

Learnify Hub © www.0685.com All Rights Reserved