zaro

What is the Formula for Covariance in Excel?

Published in Statistical Formulas 4 mins read

The primary Excel formula for calculating the covariance of a population is =COVARIANCE.P(array1, array2). Excel also provides a function for sample covariance, which is =COVARIANCE.S(array1, array2). These functions are essential for understanding the linear relationship between two sets of data.

Understanding the COVARIANCE.P Function

The COVARIANCE.P function calculates the population covariance, assuming that your provided data sets represent the entire population. It measures how two variables change together.

The syntax for the COVARIANCE.P function is:

=COVARIANCE.P(array1, array2)
  • array1: This is the first range of cells containing your set of numerical data.
  • array2: This is the second range of cells containing your second set of numerical data. Both arrays must have the same number of data points.

Example:
If you have data in columns C and D, say from row 5 to row 16, you would calculate the population covariance using:
=COVARIANCE.P(C5:C16,D5:D16)

In this formula, C5:C16 represents the first set of values and D5:D16 represents the second. Excel internally processes these ranges, considering the average of values in each set, to determine how deviations from these averages in one set relate to deviations in the other.

COVARIANCE.P vs. COVARIANCE.S: Key Differences

Excel offers two distinct functions for calculating covariance, depending on whether your data represents an entire population or just a sample from a larger population. The choice between these functions is crucial for accurate statistical analysis.

Function Description Formula Type
COVARIANCE.P Population Covariance: Calculates covariance for the entire population. It uses N (the number of data points) in its denominator. This function is appropriate when your two data arrays represent all possible observations for the variables you are analyzing. Population
COVARIANCE.S Sample Covariance: Calculates covariance for a sample of data. It uses N-1 (where N is the number of data points) in its denominator, which is a common adjustment for sample statistics to provide an unbiased estimate of the population covariance. Use this function when your data is a subset of a larger population and you want to infer characteristics about that larger population. Sample

For more detailed information, you can refer to the official Microsoft documentation for COVARIANCE.P and COVARIANCE.S.

How to Use Covariance Functions in Excel

Using the covariance functions in Excel is straightforward:

  1. Open your Excel worksheet: Ensure your two sets of numerical data are organized in columns or rows.
  2. Select an empty cell: Choose the cell where you want the covariance result to appear.
  3. Enter the formula:
    • For population covariance, type =COVARIANCE.P(.
    • For sample covariance, type =COVARIANCE.S(.
  4. Select the first data range: Click and drag to select the cells for array1 (e.g., A2:A10).
  5. Add a comma: Type ,.
  6. Select the second data range: Click and drag to select the cells for array2 (e.g., B2:B10).
  7. Close the parenthesis and press Enter: Type ) and then press the Enter key.

Excel will immediately display the calculated covariance value in the selected cell.

Interpreting Covariance Results

The result of a covariance calculation indicates the direction of the linear relationship between two variables:

  • Positive Covariance: If the covariance is a positive number, it suggests that as one variable increases, the other variable also tends to increase. Conversely, as one decreases, the other tends to decrease. They move in the same direction.
  • Negative Covariance: If the covariance is a negative number, it indicates that the variables tend to move in opposite directions. As one variable increases, the other tends to decrease, and vice versa.
  • Zero or Near-Zero Covariance: A covariance value close to zero suggests there is little to no linear relationship between the two variables. This does not necessarily mean there is no relationship at all, just no linear one.

It's important to note that while covariance shows the direction of the relationship, its magnitude is not standardized and can be influenced by the scale of the data. For assessing the strength of the linear relationship, the correlation coefficient (calculated using functions like CORREL or PEARSON in Excel) is generally more informative.