How to Create a Covariance Matrix in Excel?
Last Updated :
26 Jul, 2024
Covariance is a statistical term that signifies the direction of the linear relationship between two variables. The direction usually refers to whether the variables vary directly or inversely to each other. It should be remembered that covariance only measures how two variables change together, it does not explain the dependency of one variable over another variable. When the two variables vary in the same direction (directly) then the covariance is said to be positive covariance. Conversely, when the two variables vary in the opposite direction (inversely) then the covariance is said to be negative covariance.
The mathematical formula for Covariance of a population is given as:
Cov(x,y) = \frac{\sum_{i=1}^{n} (x_i-\overline{x})(y_i-\overline{y})}{n}Â
Â
Where, x,y is the array of first and second variable respectively, \overline{x}Â
 and \overline{y}Â
 are the mean values of x and y respectively and n is the no. of elements in the array.
On the other hand, the mathematical formula for Covariance of a sample is given as:
Cov(x,y) = \frac{\sum_{i=1}^{n} (x_i-\overline{x})(y_i-\overline{y})}{n-1}
The value of covariance lies in the range (-\infty ,\infty)Â
. The crux of the matter is the numerical value of significance holds no value since it is unit dependent, hence only the sign/polarity associated with the numerical value matters. If the sign is positive, both the variables vary in the same direction else if the sign is negative, we can infer both the variables vary inversely with one another.
What is a covariance matrix?
A covariance matrix is typically a square matrix representing covariance between each pair of elements in a random array. The covariance matrix is symmetrical along the diagonals.
Creating a covariance matrix in ExcelÂ
We can create a covariance matrix in Excel using the Covariance function present inside the data analysis tool available under the data analysis the toolpak add-in package.
Suppose, we have a group of students and we want to create a covariance matrix for finding the covariance between marks obtained by each student in various subjects. The marks obtained by each student in the different subject is given as :

Step 1: Click the Data ribbon in the excel menu and select the Data Analysis tool option.

Step 2: A data analysis tool dialog box will appear on the screen. From all the available options in the dialog box, select the Covariance option and click OK.

Step 3: A Covariance dialog box will pop up on the screen. Inside the dialog box, in the input range field pass the data array. Here, We want to compare the marks, hence, the cell range from B1 to D7 is passed. Now, since our data is grouped by columns, therefore, we select the Columns radio button under the Grouped by field and our data has labels in the first row, therefore, we click the appropriate checkbox. Now, we want to place the covariance matrix in the same worksheet, we will select the cell in which we want to place the covariance matrix and give the cell address in the output range field here cell A10 is passed. Â Then click the OK button.

Step 4: The covariance matrix will get generated from the A10 cell as shown in the figure below.Â

So this is how we create a covariance matrix in Excel.
Similar Reads
How to Create a Covariance Matrix in R?
In this article, we will discuss how to create a Covariance Matrix in the R Programming Language.Covariance is the statistical measure that depicts the relationship between a pair of random variables that shows how the change in one variable causes changes in another variable. It is a measure of the
2 min read
How to Create an Exchange Matrix in R
In this article, we will discuss how to create an exchange matrix in R Programming Language. The exchange matrix is a square matrix with ones on the anti-diagonal and zeros on all other elements. We can say that the exchange matrix is a combination of the identity matrix and the anti-diagonal matrix
1 min read
How to Create a Contingency Table in Excel
A contingency table, also known as a crosstab is used to show the relationship between two categorical variables. In Excel, we can make a contingency table using the pivot table function. They are best for summarizing the relationship between categorical variables. A contingency table is just like a
4 min read
How to Create a Thermometer Chart in Excel?
The Thermometer chart in Excel can be used to depict specific data based on the actual value and the target value. It can be used in a wide range of scenarios such as representing the past performance of horses in horse racing or the global temperature and it's variation throughout decades etc. In t
2 min read
How To Create a Tornado Chart In Excel?
Tornado charts are a special type of Bar Charts. They are used for comparing different types of data using horizontal side-by-side bar graphs. They are arranged in decreasing order with the longest graph placed on top. This makes it look like a 2-D tornado and hence the name. Creating a Tornado Char
2 min read
How to Create a Bar Chart in Excel?
To learn how to create a Column and Bar chart in Excel, let's use a simple example of marks secured by some students in Science and Maths that we want to show in a chart format. Note that a column chart is one that presents our data in vertical columns. A bar graph is extremely similar in terms of t
4 min read
How to create a matrix in R
In this article, we will discuss What is a matrix and various methods to create a matrix by using R Programming Language. What is a matrix?A matrix is a two-dimensional data set that collects rows and columns. The matrix stores the data in rows and columns format. It is possible to access the data i
3 min read
How to Create Anscombeâs Quartet in Excel?
Anscombe Quartet developed a situation that, despite the different datasets, with different scatter charts, data could have the same correlation values among them. Anscombe Quartet is famous to provide four data sets that tell us the importance of graphing and trend lines in the data. In this articl
4 min read
How to Create a Distance Matrix in R?
A distance matrix is a matrix that contains the distance between each pair of elements in a dataset. In R Programming Language, there are several functions available for creating a distance matrix such as dist(), daisy(), and vegdist() from the stats, cluster, and vegan packages respectively. Distan
8 min read
How To Create Interactive Charts in Excel?
In MS Excel, we can draw various charts, but among them today, we will see the interactive chart. By name, we can analyze that the chart, which is made up of interactive features, is known as an interactive chart. In general, this chart makes the representation in a better and more user-friendly way
9 min read