Covariance Matrix (Variance-Covariance Matrix)

Calculate the variances and covariances of many variables at once. The diagonal holds each variable's variance and the other cells the sample covariance of two variables - the matrix used as input to principal component analysis and multivariate control charts.

1Data Table

Paste a table copied from Excel into a cell (Ctrl+V). Click a column header (A, B…) before pasting to use the first line as column names. Double-click a header to rename it, right-click to insert/delete rows and columns, and formulas such as =A1*2 work too.

2Covariance Matrix Options

Select the columns to use (at least 2, 3 or more recommended):

How to make a covariance matrix

  1. Copy the variable columns together with the header.
  2. Select 2 or more columns to use.
  3. Press Analyze and check the heatmap and interpretation. Hover over a cell to see the exact value.

Worked example with sample data

The sample data are the same 30 rows of process data as the correlation matrix (temperature, pressure, line speed, thickness, strength).

Covariance matrix heatmap of temperature, pressure, line speed, thickness and strength
Covariance matrix heatmap of temperature, pressure, line speed, thickness and strength

The diagonal holds the variance of each variable: strength 569.31, temperature 18.49, line speed 2.64, pressure 0.10, thickness 0.02. Strength has the largest variance because of its large unit (MPa), so the cells related to strength take up most of the color range.

The largest off-diagonal covariance is temperature-strength at 76.17 (positive direction). Yet the strongest relationship in the correlation matrix was line speed-thickness (r=-0.92), whose covariance is only -0.20. The size of a covariance depends on scale, so use the correlation matrix to compare strength.

The pressure-thickness cell shows 0.00, but the actual value is a very small 0.0045. Hover over the cell to see the exact value.

How it is calculated

Each cell is the sample covariance (divided by n-1) of the two columns, and the diagonal is the sample variance of that column. Missing values are handled pair by pair (pairwise, the same as pandas .cov()). Cells show two decimals, so small values may appear as 0.00 - hover to see the exact value.

Difference from the correlation matrix

A covariance matrix keeps the units and scale of each variable, so variables with large values (for example strength in MPa) tend to dominate the colors. To compare the strength of relationships, look at the unit-free correlation matrix too.

How to read a covariance matrix

  • The interpretation names the off-diagonal covariance with the largest absolute value and its direction (positive/negative).
  • The square root of a diagonal value (variance) is that variable's standard deviation.
  • A large covariance does not mean a strong relationship. The larger the scale of a variable, the larger its covariances.

Frequently asked questions

Can I see the population covariance (divided by n)?

Only the sample covariance (n-1) is provided. Multiply by (n-1)/n if you need the value divided by n.

Can I move the matrix values to Excel?

Hover over a cell to see the exact value, and save or copy the chart as an image.

Other chart tools