Why Check the Whole Matrix?
A shared-control analysis may involve several treatment-versus-control contrasts. Each contrast has a variance, and each pair has a covariance. These quantities can be assembled into a matrix, but a matrix whose entries look reasonable one at a time may still be impossible as a joint covariance matrix. A numerical audit therefore checks both individual entries and the matrix as a whole.
The checks in this tutorial apply after a contrast covariance matrix has been calculated, whether from group variances and allocation sizes or from a general contrast representation. They do not replace that calculation. Instead, they help catch errors such as a misplaced entry, an incorrect sign, a variance entered as a standard error, or an impossible combination of pairwise covariances.
For example, if the vector of independent group means has covariance matrix \(\Sigma\), and the contrasts are formed as \(D=L\bar{Y}\), then their covariance matrix is \(V=L\Sigma L^T\). Under independent group means, \(\Sigma\) is diagonal, with group-mean variances such as \(\sigma_j^2/n_j\). This construction gives a useful reference for checking a numerical result. The random variables must have finite variances, the contrast definitions and their order must be clear, and the group-mean covariance assumptions used in \(\Sigma\) must be appropriate for the calculation.
A Practical Sequence of Checks
Check the matrix in a fixed order. First confirm that its rows and columns refer to the same contrasts in the same order. Then inspect symmetry, diagonal variances, implied correlations, and joint positive semidefiniteness. The sequence matters: a correlation cannot be interpreted correctly if its row or column has been mislabelled, and a positive-semidefinite result cannot rescue a diagonal variance that was calculated from the wrong model.
Each off-diagonal covariance must appear in both mirrored positions: \(V_{ij}=V_{ji}\). With rounded entries, compare the two values using a tolerance appropriate to the scale and precision of the calculation.
Compare each \(V_{ii}\) with the variance derived for that contrast. Variances are nonnegative and have squared outcome units; they are not standard errors, which have outcome units.
For positive diagonal entries, compute \(\rho_{ij}=V_{ij}/\sqrt{V_{ii}V_{jj}}\). Each must lie between \(-1\) and \(1\). A zero variance requires separate care: a variable with zero variance has zero covariance with every variable, and its correlation is undefined.
Test whether the symmetric matrix is positive semidefinite. For a three-by-three matrix, all principal minors must be nonnegative. For larger matrices, eigenvalues or a suitable semidefinite-factorization check are practical numerical tools.
The reason for the final check follows directly from the definition of covariance. For any fixed vector \(a\), the scalar \(a^T D\) is a linear combination of the contrasts, so
Thus, if some \(a\) gives \(a^T V a<0\), the proposed matrix cannot be the covariance matrix of any random vector. For a symmetric three-by-three matrix, the principal-minor test checks the three diagonal entries, the three two-by-two principal determinants, and the full determinant. It is a joint check: passing separate checks on each pair does not by itself establish that the whole matrix is valid.
Worked Numerical Audits
Worked Example: Auditing a Matrix From Three Shared-Control Contrasts
Suppose, hypothetically, that three independent group means have variances \(4\), \(9\), and \(16\) outcome-units squared for control, treatment 1, and treatment 2, respectively. Define \(D_1=\bar{Y}_1-\bar{Y}_0\) and \(D_2=\bar{Y}_2-\bar{Y}_0\). The shared control contributes covariance \(4\) between the two contrasts. The proposed matrix is
Symmetry and diagonal checks. The off-diagonal entries match. The contrast variances are \(9+4=13\) and \(16+4=20\), matching the diagonal. The entries are in squared outcome units.
Implied correlation. The correlation is
This is within \([-1,1]\). The one-by-one principal minors are \(13\) and \(20\), and the determinant is
All principal minors are positive, so \(V\) is positive definite and therefore positive semidefinite. The checks agree with the construction from independent group-mean variances.
Worked Example: Pairwise Checks Pass but the Joint Check Fails
Consider the following hypothetical proposed correlation matrix for three contrasts:
It is symmetric, and all three diagonal entries are \(1\). Each implied pairwise correlation is within \([-1,1]\), so those checks alone do not identify a problem. But the determinant is
A principal minor is negative, so the matrix is not positive semidefinite. The problem can also be seen from the contrast combination \(a=(1,-1,-1)^T\):
This would assign negative variance to a linear combination of the contrasts, which is impossible. The example shows why checking every pairwise correlation is not enough: all the proposed pairs cannot coexist in one valid joint covariance structure.
Worked Example: A Valid Singular Matrix From Dependent Contrasts
Suppose, hypothetically, that independent control, treatment 1, and treatment 2 group means have variances \(4\), \(9\), and \(16\). Define \(D_1=\bar{Y}_1-\bar{Y}_0\), \(D_2=\bar{Y}_2-\bar{Y}_0\), and \(D_3=\bar{Y}_1-\bar{Y}_2\). These definitions imply \(D_3=D_1-D_2\). The corresponding covariance matrix is
The diagonal variances are \(9+4=13\), \(16+4=20\), and \(9+16=25\). The covariances are \(\operatorname{Cov}(D_1,D_2)=4\), \(\operatorname{Cov}(D_1,D_3)=13-4=9\), and \(\operatorname{Cov}(D_2,D_3)=4-20=-16\). The matrix is symmetric. Its implied correlations are
Each pairwise value is in range. The two-by-two principal minors are \(13\cdot20-4^2=244\), \(13\cdot25-9^2=244\), and \(20\cdot25-(-16)^2=244\). The full determinant is
The matrix is positive semidefinite but singular. This is expected: \(D_3=D_1-D_2\), so the three contrasts are linearly dependent and do not have three independent directions of variation. A zero determinant is not automatically an error; it can reflect an exact dependence among contrasts.
Interpreting Diagnostics and Limits
A failed check points to a calculation or specification that needs investigation, but it does not necessarily identify the source. If a matrix is asymmetric, first check contrast ordering, transcription, and rounding. If a diagonal entry disagrees with its independently calculated variance, check whether a standard error was entered instead of a variance, or whether the wrong sample size or variance was used. If an implied correlation is outside \([-1,1]\), the covariance and at least one of the two variances cannot all be correct.
A negative eigenvalue or principal minor indicates a joint inconsistency. Recheck signs in the contrasts, shared-group contributions, and the alignment of rows and columns. In a three-by-three matrix, a negative two-by-two principal minor already disproves positive semidefiniteness; a negative full determinant also disproves it. Conversely, a zero eigenvalue or determinant may be entirely legitimate when contrasts are redundant.
Rounding can complicate numerical checks. A matrix printed to a few decimal places may be slightly asymmetric or have a very small negative computed eigenvalue even when its unrounded form is valid. Compare discrepancies with the scale of the entries and the precision retained in the calculation. Do not treat a substantial negative eigenvalue as harmless rounding, and do not silently alter entries merely to force the check to pass. Recompute from the underlying variances and contrast definitions when possible.
The alternatives to a full matrix check are useful but incomplete. Checking only symmetry and diagonal variances can miss impossible off-diagonal combinations. Checking each correlation separately can miss a joint inconsistency, as the second example showed. Checking only the determinant can also miss a negative smaller principal minor. For three contrasts, the complete principal-minor check is direct; for larger matrices, checking eigenvalues or a factorization designed for semidefinite matrices is usually more practical than listing every principal minor.
Check Your Understanding
Try each question, then compare your reasoning with the solutions below.
- A proposed covariance matrix has \(V_{12}=3.2\) and \(V_{21}=3.1\). What should you check before treating it as asymmetric?
- For a two-contrast matrix with diagonal entries \(9\) and \(16\), what range must the covariance entry satisfy?
- Why is a zero determinant not, by itself, proof that a contrast covariance matrix is invalid?
- A symmetric three-by-three matrix has positive diagonal entries and all pairwise correlations within \([-1,1]\), but one two-by-two principal minor is negative. Can it be a covariance matrix?
Solutions. (1) Check that rows and columns use the same contrast order and that the entries were not rounded differently. If the discrepancy remains beyond reasonable rounding tolerance, the matrix is not symmetric and cannot be a covariance matrix. (2) Positive semidefiniteness requires \(9\cdot16-c^2\geq0\), so \(|c|\leq\sqrt{144}=12\); the covariance must be between \(-12\) and \(12\), in the corresponding squared outcome units. (3) A zero determinant can arise from linearly dependent contrasts, as in the third worked example. A singular covariance matrix can still be positive semidefinite. (4) No. A negative principal minor contradicts positive semidefiniteness, even when every entry and pairwise correlation looks individually plausible.