Tutorials › Multivariate Statistics (Graduate) › Worked Comparison of Shrinkage and Thresholding

High-Dimensional Covariance Estimation · Tutorial 801 of 975

Worked Comparison of Shrinkage and Thresholding

Work through three covariance estimators on the same Gaussian dataset and compare how their errors depend on the loss being used.

Advanced 11 min read

What You'll Learn

  • Define identity shrinkage, nonlinear eigenvalue shrinkage, and entrywise thresholding precisely.
  • Calculate covariance estimates from a common sample covariance matrix.
  • Derive the optimal identity-shrinkage weight along a fixed shrinkage path.
  • Prove the Frobenius-loss oracle rule for eigenvalues in a fixed sample eigenbasis.
  • Compare squared Frobenius and operator-norm errors in a worked example.
  • Explain why thresholding off-diagonal entries does not guarantee positive definiteness.

Why Compare These Estimators?

When the dimension is large relative to the sample size, a sample covariance matrix can be unstable even when the observations are Gaussian. Different regularization methods impose different structures: identity shrinkage pulls eigenvalues toward a common value, nonlinear eigenvalue shrinkage adjusts them separately, and entrywise thresholding removes selected off-diagonal entries. Their errors need not agree, because a loss function determines which features of the error matter most.

We compare these methods using two losses. The squared Frobenius loss adds squared errors across all entries, so it reflects aggregate matrix error. The operator-norm loss measures the largest absolute eigenvalue of the error for symmetric matrices, so it reflects the error in the most affected direction. Neither loss is universally preferable; the relevant choice depends on the purpose of the covariance estimate.

Definition: For a true covariance matrix \(\Sigma\) and an estimate \(\widehat{\Sigma}\), the squared Frobenius loss is \(L_F(\widehat{\Sigma},\Sigma)=\|\widehat{\Sigma}-\Sigma\|_F^2 =\sum_{i,j}(\widehat{\Sigma}_{ij}-\Sigma_{ij})^2\). The operator-norm loss is \(L_{\mathrm{op}}(\widehat{\Sigma},\Sigma)=\|\widehat{\Sigma}-\Sigma\|_{\mathrm{op}}\), where \(\|A\|_{\mathrm{op}}=\sup_{\|x\|_2=1}\|Ax\|_2\). For a symmetric error matrix, this is the largest absolute eigenvalue.

Three Estimators

Suppose \(X_1,\ldots,X_n\) are independent Gaussian vectors in \(\mathbb{R}^p\) with mean zero and covariance \(\Sigma\). With the mean known to be zero, take the sample covariance to be \(S=n^{-1}\sum_{k=1}^n X_kX_k^\top\). If the mean is estimated instead, the usual centered sample covariance can be used; the comparison below concerns the estimators applied to the resulting \(S\).

Identity shrinkage combines \(S\) with a scalar multiple of the identity matrix. For a chosen target scale \(\mu\) and weight \(\alpha\in[0,1]\), it is \(\widehat{\Sigma}_{\mathrm{Id}}(\alpha)=\alpha S+(1-\alpha)\mu I_p\). A common scale is \(\mu=\operatorname{tr}(S)/p\), which preserves the average sample eigenvalue. The single weight shrinks every eigenvalue toward the same value.

For nonlinear eigenvalue shrinkage, write the spectral decomposition \(S=Q\operatorname{diag}(\lambda_1,\ldots,\lambda_p)Q^\top\), with orthonormal eigenvectors in \(Q\). Replace each sample eigenvalue by a nonnegative adjusted value \(d_i\), giving \(\widehat{\Sigma}_{\mathrm{NL}}=Q\operatorname{diag}(d_1,\ldots,d_p)Q^\top\). The adjustment can depend nonlinearly on the sample eigenvalues and on the sampling regime. This definition describes the estimator's form; it does not prescribe one particular eigenvalue-adjustment rule.

Entrywise thresholding acts on covariance entries rather than on eigenvalues. With threshold \(\tau\geq0\) and the diagonal retained, define the hard-threshold estimator by \(\widehat{\Sigma}_{\mathrm{TH},ij}=S_{ij}\) if \(i=j\), and \(\widehat{\Sigma}_{\mathrm{TH},ij}=S_{ij}\mathbf{1}\{|S_{ij}|\geq\tau\}\) if \(i\ne j\). The separate diagonal rule matters: the threshold is applied only to off-diagonal entries.

Worked Example: Applying Identity Shrinkage

Suppose \(p=3\) and \(S=\begin{pmatrix}2.1&0.3&0\\0.3&2.1&0\\0&0&0.8\end{pmatrix}\). Use \(\mu=\operatorname{tr}(S)/3\) and \(\alpha=1/2\).

First, \(\operatorname{tr}(S)=2.1+2.1+0.8=5\), so \(\mu=5/3\). Then \(\widehat{\Sigma}_{\mathrm{Id}}=(1/2)S+(1/2)(5/3)I_3\). Each diagonal entry is reduced halfway toward \(5/3\), while each off-diagonal entry is halved. Thus \(\widehat{\Sigma}_{\mathrm{Id}}=\begin{pmatrix}113/60&0.15&0\\0.15&113/60&0\\0&0&37/30\end{pmatrix}\). For example, the first diagonal entry is \(2.1/2+5/6=1.05+0.8333\ldots=113/60\approx1.8833\), and the third is \(0.8/2+5/6=37/30\).

Worked Example: Replacing Eigenvalues Separately

For the same \(S\), the first two coordinates form a \(2\times2\) block with eigenvectors proportional to \((1,1,0)^\top\) and \((1,-1,0)^\top\). Their eigenvalues are \(2.4\) and \(1.8\), respectively; the third eigenvalue is \(0.8\). Consider a nonlinear eigenvalue adjustment that replaces \((2.4,1.8,0.8)\) with \((2.2,1.4,1.0)\) in that eigenbasis.

The corresponding first two eigenvectors are \(q_1=(1,1,0)^\top/\sqrt{2}\) and \(q_2=(1,-1,0)^\top/\sqrt{2}\), and \(q_3=(0,0,1)^\top\). Therefore \(\widehat{\Sigma}_{\mathrm{NL}}=2.2q_1q_1^\top+1.4q_2q_2^\top+1.0q_3q_3^\top =\begin{pmatrix}1.8&0.4&0\\0.4&1.8&0\\0&0&1.0\end{pmatrix}\). The first diagonal entry is \(2.2/2+1.4/2=1.8\), and the off-diagonal entry is \(2.2/2-1.4/2=0.4\). The estimator remains positive definite because all three replacement eigenvalues are positive.

Worked Example: Thresholding and Comparing Two Losses

Continue with the same sample covariance and use \(\tau=0.31\). Since the off-diagonal entries equal \(0.3\), they are below the threshold and are set to zero. The diagonal is retained by definition, so \(\widehat{\Sigma}_{\mathrm{TH}}=\begin{pmatrix}2.1&0&0\\0&2.1&0\\0&0&0.8\end{pmatrix}\). For this comparison, take the true covariance to be \(\Sigma=\operatorname{diag}(2,1.5,1)\), which is positive definite.

For identity shrinkage, the error is \(\widehat{\Sigma}_{\mathrm{Id}}-\Sigma= \begin{pmatrix}-7/60&0.15&0\\0.15&23/60&0\\0&0&7/30\end{pmatrix}\). Its squared Frobenius loss is \((7/60)^2+(23/60)^2+2(0.15)^2+(7/30)^2 =49/3600+529/3600+0.045+49/900=0.26\). The first \(2\times2\) error block has eigenvalues \(2/15\pm\sqrt{34}/20\); the remaining eigenvalue is \(7/30\). Hence its operator-norm loss is \(2/15+\sqrt{34}/20\), approximately \(0.425\).

For nonlinear eigenvalue shrinkage, the error is \(\widehat{\Sigma}_{\mathrm{NL}}-\Sigma= \begin{pmatrix}-0.2&0.4&0\\0.4&0.3&0\\0&0&0\end{pmatrix}\). Its squared Frobenius loss is \(0.2^2+0.3^2+2(0.4)^2=0.45\). The eigenvalues of its upper-left block are \(0.05\pm\sqrt{0.2225}\), approximately \(0.522\) and \(-0.422\). Thus its operator-norm loss is approximately \(0.522\).

For thresholding, the error is diagonal with entries \(0.1,0.6,-0.2\). Its squared Frobenius loss is \(0.1^2+0.6^2+(-0.2)^2=0.41\), and its operator-norm loss is \(\max(0.1,0.6,0.2)=0.6\). In this example identity shrinkage has the smallest value under both losses. This is a comparison on one finite dataset and truth, not a general dominance claim.

Two Useful Loss Calculations

The first result identifies the best weight along a fixed identity-shrinkage path when the target and truth are treated as known. It explains precisely what “best weight” means under squared Frobenius loss; in practice, \(\Sigma\) is unknown, so the result is an oracle benchmark rather than a directly available tuning rule.

Theorem: Let \(S\), \(\Sigma\), and \(T\) be fixed symmetric \(p\times p\) matrices. Among estimators \(\widehat{\Sigma}(\alpha)=T+\alpha(S-T)\) with \(\alpha\in[0,1]\), the squared-Frobenius-loss minimizer is the projection onto \([0,1]\) of \(\alpha_0=\langle S-T,\Sigma-T\rangle_F/\|S-T\|_F^2\), provided \(S\ne T\). Here \(\langle A,B\rangle_F=\operatorname{tr}(A^\top B)\). If \(S=T\), every \(\alpha\) gives the same estimator.

To prove the result when \(S\ne T\), put \(D=S-T\) and \(R=T-\Sigma\). The error is \(R+\alpha D\). Expanding the squared norm gives \(\|R+\alpha D\|_F^2=\|R\|_F^2+2\alpha\langle D,R\rangle_F+\alpha^2\|D\|_F^2\). Because \(\|D\|_F^2>0\), this is a strictly convex quadratic in \(\alpha\). Its derivative is \(2\langle D,R\rangle_F+2\alpha\|D\|_F^2\), which vanishes at \(\alpha=-\langle D,R\rangle_F/\|D\|_F^2=\langle D,\Sigma-T\rangle_F/\|D\|_F^2\). The constrained minimum on \([0,1]\) is that unconstrained value if it lies in the interval, and otherwise the nearer endpoint. This is exactly projection onto \([0,1]\). \(\square\)

The next result clarifies what eigenvalue adjustment can achieve if the sample eigenvectors are held fixed. It is an oracle statement: the diagonal quantities involving \(\Sigma\) are unknown in applications, and choosing \(d_i\) from the data requires an estimation method.

Theorem: Let \(Q\) be an orthogonal \(p\times p\) matrix with columns \(q_1,\ldots,q_p\), and let \(\Sigma\) be symmetric. Among all real diagonal choices \(D=\operatorname{diag}(d_1,\ldots,d_p)\), the Frobenius loss \(\|QDQ^\top-\Sigma\|_F^2\) is minimized by \(d_i=q_i^\top\Sigma q_i\). If the choices are constrained to be nonnegative, the minimizer is \(d_i=\max(q_i^\top\Sigma q_i,0)\).

Orthogonal invariance of the Frobenius norm gives \(\|QDQ^\top-\Sigma\|_F^2=\|D-Q^\top\Sigma Q\|_F^2\). Write \(A=Q^\top\Sigma Q\). Expanding entry by entry, \(\|D-A\|_F^2=\sum_i(d_i-A_{ii})^2+\sum_{i\ne j}A_{ij}^2\). The second sum does not depend on \(D\), and each term in the first sum is minimized by \(d_i=A_{ii}=q_i^\top\Sigma q_i\). If \(d_i\geq0\) is required, the closest nonnegative number to \(A_{ii}\) is \(\max(A_{ii},0)\), which minimizes the corresponding squared term. \(\square\)

Reading the Comparison Carefully

The two losses weight error geometry differently. Frobenius loss accumulates discrepancies over all entries; operator norm is controlled by the largest error direction. Consequently, the ordering of two estimates can change with the loss, even when both estimates are positive definite. For example, take \(\Sigma=I_3\), \(A=\operatorname{diag}(1.4,1,1)\), and \(B=\operatorname{diag}(1.3,1.3,1)\). Both estimates are positive definite. Their squared Frobenius losses are \(0.4^2=0.16\) and \(0.3^2+0.3^2=0.18\), so \(A\) is better under that loss. Their operator-norm losses are \(0.4\) and \(0.3\), so \(B\) is better under operator norm.

Thresholding exploits approximate sparsity: if many true off-diagonal entries are zero or small, removing noisy sample entries can reduce aggregate error. Its risk reflects both the variance removed and the bias introduced by discarded nonzero entries. Shrinkage instead changes the spectrum or pulls entries toward a structured target, which can be preferable when the covariance is not sparse but sample eigenvalues are noisy. These are structural assumptions, not properties guaranteed by the Gaussian sampling model alone.

Common pitfall: Applying the off-diagonal threshold formula to every entry, including the diagonal, can incorrectly set a variance estimate to zero. The diagonal-retaining hard-threshold estimator is defined piecewise: keep \(S_{ii}\) unchanged and threshold only \(S_{ij}\) for \(i\ne j\). A second pitfall is assuming that a symmetric thresholded matrix must be positive definite. Symmetry follows when the same rule is applied to \(S_{ij}=S_{ji}\), but positive definiteness does not follow; the eigenvalues must be checked if positive definiteness is required.
Key takeaway: Identity shrinkage, nonlinear eigenvalue shrinkage, and entrywise thresholding regularize different features of a covariance estimate. Compare them using a loss aligned with the intended use, and keep the structural assumption behind each method in view.

Check Your Understanding

Use the definitions and calculations above to answer these questions.

  1. For \(S\) in the worked examples, what is the identity-shrinkage estimate when \(\alpha=0\), and what is it when \(\alpha=1\)?
  2. Why does replacing eigenvalues while retaining \(Q\) preserve positive semidefiniteness when every replacement \(d_i\) is nonnegative?
  3. With \(\tau=0.31\), what happens to the diagonal entry \(S_{11}=2.1\) and the off-diagonal entry \(S_{12}=0.3\) under the specified threshold rule?
  4. In the fixed-eigenvector theorem, why does the sum \(\sum_{i\ne j}A_{ij}^2\) not affect the minimizing diagonal values \(d_i\)?
  5. Give one reason the estimator with the smallest squared Frobenius loss in a dataset need not have the smallest operator-norm loss.
Clinical Biostats