Why the Missingness Pattern Matters
Covariance summarizes how two variables vary together: positive covariance means that values above one variable’s mean tend to occur with values above the other’s mean, while negative covariance means that values above one mean tend to occur with values below the other. Its value depends on both the observed values and the way missing values are handled. In particular, mean imputation does not simply fill gaps while leaving the covariance calculation unchanged.
The central arithmetic fact is straightforward but consequential. After a missing value is replaced by that variable’s observed mean, its deviation from the completed-data mean is zero. Therefore, a row contributes zero to the centered cross-product if either variable was imputed on that row. Which rows are jointly observed determines which nonzero products remain.
This tutorial uses the sample-covariance denominator \(n-1\) for a completed data set with \(n\) rows. The covariance calculated only among rows where both variables were observed is a different quantity: it uses that subset’s means and its own sample-size denominator. Neither calculation by itself establishes that the covariance is an unbiased estimate of a population covariance.
Deriving the Completed-Data Formula
First note that the mean of each completed variable is its observed mean. For \(X\), the observed values sum to \(|S_X|\bar{x}_{\mathrm{obs}}\), and the \(n-|S_X|\) imputed values each equal \(\bar{x}_{\mathrm{obs}}\). Thus the completed sum is \(n\bar{x}_{\mathrm{obs}}\), so the completed mean is \(\bar{x}_{\mathrm{obs}}\). The same argument applies to \(Y\).
Write the completed values as \(x_i^*\) and \(y_i^*\). If \(i\) is missing \(X\), then \(x_i^*-\bar{x}_{\mathrm{obs}}=0\); if \(i\) is missing \(Y\), then \(y_i^*-\bar{y}_{\mathrm{obs}}=0\). In either case, the row’s centered cross-product is zero. Only rows in \(S_X\cap S_Y\), where both values were originally observed, can contribute a nonzero product. Consequently,
This is an exact arithmetic identity for variable-specific mean imputation, provided each variable has at least one observed value so its imputation mean exists, and \(n>1\). It does not require an assumption about the missingness mechanism. Statistical interpretation is a separate issue: the identity does not imply that the completed-data covariance estimates the covariance that would have been obtained if every value had been observed.
The identity also explains why the overlap pattern matters. When both variables are missing together, that row contributes zero. When only one is missing, the row still contributes zero because one centered value is zero. But the means in the products are calculated from all observed values of each variable, which need not be the means among jointly observed rows.
Worked Example: Both Variables Missing on the Same Row
Consider four hypothetical records. The first three have observed pairs \((1,2)\), \((2,4)\), and \((3,6)\); both values are missing on the fourth row. Calculate the covariance after mean imputation.
The observed means are \(\bar{x}_{\mathrm{obs}}=(1+2+3)/3=2\) and \(\bar{y}_{\mathrm{obs}}=(2+4+6)/3=4\). The fourth row is imputed as \((2,4)\), so the completed means remain 2 and 4.
The centered cross-products for the observed pairs are \((1-2)(2-4)=2\), \((2-2)(4-4)=0\), and \((3-2)(6-4)=2\). The imputed row contributes \((2-2)(4-4)=0\). Therefore,
The completed-data sample covariance is about \(1.333\) in the product of the units of \(X\) and \(Y\). For comparison, the covariance among the three jointly observed pairs is \(4/(3-1)=2\): it uses the same observed pairs here, but divides by \(3-1\), not \(4-1\). The two numbers answer different computational questions.
Different Patterns of Joint Observation
When missingness occurs in different variables on different rows, the set of rows contributing to the covariance is still the intersection \(S_X\cap S_Y\). However, the means used to center those contributing values include all observed values of each variable, even values from rows where the other variable is missing. That detail can make the completed-data covariance differ from a covariance computed within the jointly observed subset in more ways than just its denominator.
Worked Example: Only One Variable Is Missing
Suppose a hypothetical data set has \((X,Y)=(1,1)\) and \((3,5)\) on its first two rows. On the third row, \(X\) is missing and \(Y=3\) is observed. Impute the missing \(X\) and calculate the covariance.
The observed \(X\) mean is \((1+3)/2=2\), and the mean of the three observed \(Y\) values is \((1+5+3)/3=3\). Imputing \(X=2\) gives the completed rows \((1,1)\), \((3,5)\), and \((2,3)\); the completed means are still 2 and 3.
The centered products are \((-1)(-2)=2\), \((1)(2)=2\), and \((0)(0)=0\). Hence
The row with imputed \(X\) contributes zero, even though its \(Y\) value is observed. The covariance among the two jointly observed pairs, calculated using their own means, is \(4/(2-1)=4\). The completed-data calculation instead centers \(Y\) at 3 using all three observed \(Y\) values and divides by \(3-1\).
Worked Example: Different Rows Missing Different Variables
Consider four hypothetical rows: \((1,2)\), \((3,6)\), \((5,\text{missing})\), and \((\text{missing},10)\). Calculate the covariance after imputing each missing value with its variable’s observed mean.
The observed \(X\) mean is \((1+3+5)/3=3\), and the observed \(Y\) mean is \((2+6+10)/3=6\). The completed data are \((1,2)\), \((3,6)\), \((5,6)\), and \((3,10)\); their means remain 3 and 6.
The first two rows are jointly observed and contribute \((1-3)(2-6)=8\) and \((3-3)(6-6)=0\). The third row contributes zero because its imputed \(Y\) equals 6. The fourth contributes zero because its imputed \(X\) equals 3. Thus,
The covariance among the two jointly observed pairs is \(4/(2-1)=4\), since their own means are 2 and 4. The completed-data calculation instead centers using the marginal observed means 3 and 6 and uses the full-data denominator \(4-1\). The discrepancy reflects the pattern of observation as well as the choice of denominator.
What the Calculation Does—and Does Not—Say
The formula gives a precise account of the completed table, not a general correction for missing data. A useful comparison is with covariance based only on jointly observed rows. That calculation discards all rows outside \(S_X\cap S_Y\), centers both variables at means within that subset, and divides by \(|S_X\cap S_Y|-1\), if at least two pairs are available. Mean-imputed covariance uses the full \(n\)-row denominator and the marginal observed means. These quantities can differ even though both use the same jointly observed values in their cross-products.
| Calculation | Rows used for cross-products | Centering and denominator |
|---|---|---|
| Covariance after mean imputation | Only rows where both original values were observed can contribute nonzero products | Observed marginal means; denominator \(n-1\) |
| Covariance among jointly observed rows | Rows where both values were observed | Means within that subset; denominator \(m-1\), where \(m=|S_X\cap S_Y|\) |
The distinction matters in practice because a completed table can look complete without restoring the variation or joint information that was absent. The result depends on the missingness pattern, and a single covariance number does not display that dependence. The earlier material on Missing Data Mechanisms is relevant when considering whether an observed-data calculation can support a population interpretation; the algebra here does not establish such support.
No missingness mechanism is needed to verify the arithmetic identity. But interpreting the imputed covariance as a good estimate of the full-data covariance requires additional justification about the data-generating and missingness processes, and mean imputation generally does not supply that justification. Even under a simple missingness pattern, a row imputed at a mean has no centered cross-product. It therefore fails to represent the unobserved row’s actual contribution.
Diagnostics and Common Mistakes
A reliable audit starts with the missingness pattern, not just the completed table. Record how many rows have both values observed, only \(X\) observed, only \(Y\) observed, or neither observed. Then check each variable’s observed mean, verify that its completed mean is unchanged, and calculate the centered products row by row. The sum of those products should equal the sum over jointly observed rows in the identity above.
- Mistake: Treating every imputed row as if it contributes a typical covariance product. Correction: a mean-imputed value has zero deviation from its completed mean, so that row’s centered product is zero whenever either variable was imputed.
- Mistake: Centering only on jointly observed values without saying so. Correction: the mean-imputed covariance uses each variable’s marginal observed mean. Pairwise covariance uses means within the jointly observed subset.
- Mistake: Using the pairwise denominator for the completed table. Correction: for a completed table with \(n\) rows, the sample covariance uses \(n-1\); pairwise covariance uses \(m-1\) when it is calculated from \(m\) jointly observed pairs.
- Mistake: Assuming covariance must always move toward zero. Correction: the centered products, marginal means, overlap pattern, and denominator all matter. The formula does not guarantee a universal direction or size of change.
Covariance is expressed in the product of the variables’ units, such as points-squared if both variables are measured in points. Its magnitude depends on the measurement scales, so comparisons should be made with units and context stated. The calculation alone does not establish causation or the validity of a population-level conclusion.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- A four-row completed data set has observed marginal means \(\bar{x}_{\mathrm{obs}}=4\) and \(\bar{y}_{\mathrm{obs}}=3\). Its jointly observed pairs are \((2,1)\) and \((4,5)\); all other rows have at least one imputed value. What is its sample covariance after mean imputation?
- In a data set with \(n=3\), \(X\) is observed as 1 and 5 on two rows and missing on the third. \(Y\) is observed as 2, 6, and 4. Calculate the mean-imputed covariance. What is the covariance among the two jointly observed pairs?
- Why can covariance after mean imputation differ from covariance among jointly observed rows even when the same original pairs contribute nonzero cross-products?
- State one arithmetic check and one interpretive caution for a covariance calculated after mean imputation.
Solutions. (1) The centered products are \((2-4)(1-3)=4\) and \((4-4)(5-3)=0\). All other rows contribute zero, so the completed-data covariance is \((4+0)/(4-1)=4/3\approx1.333\). (2) The observed \(X\) mean is 3 and the \(Y\) mean is 4; the imputed row is \((3,4)\). The products are \((-2)(-2)=4\), \((2)(2)=4\), and 0, giving \(8/(3-1)=4\). For the two jointly observed pairs, their means are 3 and 4, so their covariance is \(8/(2-1)=8\). (3) Mean-imputed covariance uses the marginal observed means and denominator \(n-1\); pairwise covariance uses the jointly observed subset’s means and denominator \(m-1\). (4) An arithmetic check is to confirm that every row with at least one imputed value contributes zero and that the remaining products sum to the stated numerator. An interpretive caution is that this identity describes the completed data but does not, by itself, justify treating its covariance as an estimate of the full-data population covariance.