Tutorials › Multivariate Statistics (Graduate) › Testing A Diagonal Covariance Matrix

Covariance Matrix Inference · Tutorial 245 of 975

Testing A Diagonal Covariance Matrix

Learn how the diagonal-covariance likelihood-ratio test is derived, calibrated, and interpreted under multivariate normality.

Intermediate 10 min read

What You'll Learn

  • Derive the unrestricted and diagonal covariance maximum-likelihood estimates
  • Calculate the likelihood-ratio statistic from a sample covariance matrix
  • Determine the chi-square degrees of freedom from the covariance parameter counts
  • Relate the test statistic to the determinant of the sample correlation matrix
  • Distinguish zero covariance from independence, and identify the Gaussian condition

What Does a Diagonal Covariance Matrix Assert?

For a multivariate measurement, a diagonal covariance matrix says that every pair of distinct components has covariance zero. This is a useful restriction when the scientific question is whether measurements vary independently, or when a simpler covariance model is needed. The likelihood-ratio test compares the fit of this restricted model with the fit of an unrestricted covariance matrix.

The test is specifically a Gaussian covariance test. For a multivariate normal distribution, zero covariances between components imply their independence. Outside the Gaussian model, zero covariance alone does not generally imply independence, so the interpretation must respect the distributional assumption.

Definition: A covariance matrix \(\boldsymbol\Sigma\) is diagonal if \(\sigma_{jk}=0\) for every pair \(j\ne k\). For \(p\) variables, the hypotheses are \(H_0:\boldsymbol\Sigma=\operatorname{diag}(\sigma_1^2,\ldots,\sigma_p^2)\), with every \(\sigma_j^2>0\), against the alternative that \(\boldsymbol\Sigma\) is any positive-definite covariance matrix.

Suppose \(\mathbf X_1,\ldots,\mathbf X_n\) are independent observations from \(N_p(\boldsymbol\mu,\boldsymbol\Sigma)\), where both the mean vector and covariance matrix are unknown. Write \(\bar{\mathbf X}=n^{-1}\sum_{i=1}^n\mathbf X_i\) and \(S=n^{-1}\sum_{i=1}^n(\mathbf X_i-\bar{\mathbf X})(\mathbf X_i-\bar{\mathbf X})'\). This definition uses divisor \(n\), as appropriate for the maximum-likelihood covariance estimate.

Deriving the Likelihood-Ratio Statistic

Assume \(n>p\) and that the observed residual vectors span \(p\) dimensions, so \(S\) is positive definite. These conditions ensure that the unrestricted covariance maximum-likelihood estimate exists as a positive-definite matrix. The Gaussian likelihood is

$$ L(\boldsymbol\mu,\boldsymbol\Sigma) =(2\pi)^{-np/2}|\boldsymbol\Sigma|^{-n/2} \exp\left\{-\frac12\sum_{i=1}^n (\mathbf X_i-\boldsymbol\mu)'\boldsymbol\Sigma^{-1} (\mathbf X_i-\boldsymbol\mu)\right\}. $$

For fixed positive-definite \(\boldsymbol\Sigma\), the likelihood is maximized at \(\hat{\boldsymbol\mu}=\bar{\mathbf X}\). Substituting this estimate gives the covariance likelihood. The unrestricted estimate is \(S\); under the diagonal restriction, the estimate of each variance is the corresponding diagonal entry \(s_{jj}\). The derivation below also shows why these estimates maximize their respective likelihoods.

Result: When \(S\) is positive definite, the Gaussian likelihood-ratio statistic for diagonality is \(\Lambda=\left(|S|/\prod_{j=1}^p s_{jj}\right)^{n/2}\). Its usual deviance form is \(T=-2\log\Lambda=n\log\left(\prod_{j=1}^p s_{jj}/|S|\right)\).

To verify the estimates and statistic, let \(A=\sum_i(\mathbf X_i-\bar{\mathbf X})(\mathbf X_i-\bar{\mathbf X})'=nS\). After maximizing over the mean, the covariance-dependent part of the log-likelihood is \(-\tfrac n2\log|\boldsymbol\Sigma|-\tfrac12\operatorname{tr}(\boldsymbol\Sigma^{-1}A)\). For unrestricted \(\boldsymbol\Sigma\), its maximum occurs at \(A/n=S\). Under the null, write \(\boldsymbol\Sigma=\operatorname{diag}(v_1,\ldots,v_p)\). The covariance-dependent terms separate into \(-\tfrac n2\sum_j\log v_j-\tfrac12\sum_j A_{jj}/v_j\). Differentiating with respect to \(v_j>0\) gives \(-n/(2v_j)+A_{jj}/(2v_j^2)=0\), hence \(v_j=A_{jj}/n=s_{jj}\). The second derivative at this point is \(-n/(2s_{jj}^2)<0\), and the log-likelihood tends downwards at either boundary \(v_j\to0\) or \(v_j\to\infty\), confirming a maximum.

At either fitted covariance, the trace term in the maximized log-likelihood is \(np\): unrestricted, \(\operatorname{tr}(S^{-1}nS)=np\); under the null, \(\sum_j A_{jj}/s_{jj}=np\). These terms cancel in the likelihood ratio. The determinant under the restricted fit is \(\prod_j s_{jj}\), while the unrestricted determinant is \(|S|\). Taking the ratio of maximized likelihoods and then \(-2\) times its logarithm gives the stated formulas.

Calibration and Degrees of Freedom

The unrestricted covariance matrix has \(p(p+1)/2\) distinct parameters: \(p\) variances and \(p(p-1)/2\) distinct off-diagonal covariances. A diagonal covariance matrix has \(p\) free variance parameters. The mean vector contributes \(p\) nuisance parameters to both models, so it does not change the difference in dimensions.

$$ \frac{p(p+1)}{2}-p=\frac{p(p-1)}{2}. $$

For fixed \(p\), under \(H_0\), and as \(n\to\infty\), Wilks' theorem therefore gives \(T\xrightarrow{d}\chi^2_{p(p-1)/2}\). The regularity conditions are satisfied when the true covariance has strictly positive diagonal entries: the unrestricted covariance parameter lies in the positive-definite cone, and the null is a smooth restriction within that parameter space. This is an asymptotic calibration, not an exact finite-sample chi-square distribution. Large values of \(T\) count against diagonality; an approximate upper-tail \(p\)-value is computed from the stated chi-square distribution.

Worked Calculations

Worked Example: A Two-Variable Test With a Large Statistic

Suppose \(n=40\), \(p=2\), and the observed maximum-likelihood sample covariance is \(S=\begin{pmatrix}64&16\sqrt7\\16\sqrt7&64\end{pmatrix}\). Calculate the statistic and its reference degrees of freedom.

The product of the diagonal entries is \(64(64)=4096\). The determinant is \(64(64)-(16\sqrt7)^2=4096-256(7)=4096-1792=2304\). Thus

$$ T=40\log(4096/2304)=40\log(16/9) \approx40(0.5753641)=23.0145658\approx23.015. $$

There is one degree of freedom, since \(p(p-1)/2=2(1)/2=1\). The statistic is large relative to a \(\chi^2_1\) reference distribution, providing evidence against a diagonal covariance matrix. This conclusion is conditional on the Gaussian model and the asymptotic calibration.

Worked Example: A Two-Variable Test With a Smaller Statistic

Let \(n=20\) and \(S=\begin{pmatrix}20&12\\12&50\end{pmatrix}\). The diagonal product is \(20(50)=1000\), and \(|S|=20(50)-12^2=1000-144=856\), which is positive. Therefore

$$ T=20\log(1000/856) =20\log(1.1682243\ldots) \approx20(0.1554849)=3.109698\approx3.110. $$

Again, the reference degrees of freedom are \(1\). This statistic is much smaller than in the preceding example; it does not provide comparably strong evidence against the null. The sample correlation is \(12/\sqrt{20(50)}=12/\sqrt{1000}\approx0.379\), illustrating that the test is sensitive to the observed off-diagonal association, but its decision is based on the likelihood statistic and its reference distribution rather than a separate correlation threshold.

Worked Example: Three Variables and Three Degrees of Freedom

Suppose \(n=30\) and \(S=\begin{pmatrix}4&1&0\\1&9&0\\0&0&16\end{pmatrix}\). The product of the diagonal entries is \(4(9)(16)=576\). Expanding the determinant along the last row gives \(|S|=16(4(9)-1^2)=16(35)=560\). Hence

$$ T=30\log(576/560) =30\log(36/35) \approx30(0.0281709)=0.8451\approx0.845. $$

Here \(p(p-1)/2=3\), corresponding to the three distinct off-diagonal covariance entries. The reference distribution is \(\chi^2_3\), not \(\chi^2_1\), even though this particular sample matrix has only one nonzero off-diagonal entry. The degrees of freedom come from the dimension of the full alternative relative to the null, not from counting nonzero sample entries.

Correlation Form and Nonnegativity

The statistic can also be expressed using the sample correlation matrix. Let \(D=\operatorname{diag}(s_{11},\ldots,s_{pp})\) and \(R=D^{-1/2}SD^{-1/2}\). Since \(S=D^{1/2}RD^{1/2}\), determinants give \(|S|=|D||R|=(\prod_j s_{jj})|R|\). Therefore \(T=-n\log|R|\). This form shows that the test is unchanged by rescaling any variable by a positive constant.

For positive-definite \(S\), the matrix \(R\) is positive definite and has diagonal entries all equal to one. Hadamard's determinant inequality states that the determinant of a positive-definite matrix is at most the product of its diagonal entries, with equality only when it is diagonal. Applied to \(R\), it gives \(0<|R|\le1\), so \(T\ge0\). Equality occurs exactly when \(R\), and therefore \(S\), is diagonal.

What the Test Can and Cannot Establish

Under multivariate normality, a diagonal covariance matrix has a stronger interpretation than merely uncorrelated components: the components are mutually independent. In fact, the Gaussian density with diagonal covariance factors into the product of its univariate normal densities. Conversely, independence of jointly Gaussian components implies zero pairwise covariances. Thus, within the multivariate normal model, testing diagonality is also a test of mutual independence.

That equivalence does not hold for arbitrary distributions. For example, let \(Z\sim N(0,1)\), and define \(X=Z\) and \(Y=Z^2\). Then \(\operatorname{Cov}(X,Y)=E[Z^3]-E[Z]E[Z^2]=0\), but \(Y\) is determined by \(X\), so \(X\) and \(Y\) are not independent. A rejection of the diagonal-covariance null indicates covariance structure inconsistent with the null; a failure to reject does not establish independence without the Gaussian assumption.

Common pitfall: Treating zero off-diagonal covariances as proof of independence for any distribution is incorrect. Zero covariance means lack of linear association as measured by covariance; independence is stronger. The implication from zero covariances to mutual independence applies here because the joint distribution is assumed multivariate normal.

A second practical caution is that the chi-square reference is asymptotic. It should not be presented as an exact finite-sample distribution, especially when the sample is small relative to the number of variables. Also, if \(S\) is singular, the determinant-based statistic and the usual unrestricted maximum-likelihood covariance estimate are not available in the stated form; the conditions for the standard test must be checked before calculating it.

Check Your Understanding

Use the definitions and derivation above to answer these questions.

  1. For \(p=5\), how many degrees of freedom does the asymptotic test use? Show the parameter-count difference.
  2. Why does estimating the mean vector not alter the difference in covariance-model dimensions?
  3. For a positive-definite sample covariance matrix, why can the statistic \(T\) not be negative?
  4. What additional distributional assumption lets a diagonal covariance matrix imply mutual independence?
  5. Why is the usual chi-square calibration described as asymptotic rather than exact?
Clinical Biostats