Skip to content

Regularised discriminant analysis

Stabilise Gaussian class covariance estimates with pooled and spherical shrinkage, follow a checked example, and distinguish parameter conventions and probability calibration.

Regularised discriminant analysis (RDA) is a Gaussian classification method that stabilises class covariance estimates by shrinking them toward a pooled covariance and toward a spherical matrix. It gives a quant researcher a way to retain some class-specific feature geometry without trusting every covariance estimated from a small class sample.

For example, a classifier for liquidity conditions might use spread, depth and volatility features. Separate covariance matrices can capture different relationships in calm and stressed observations, but the stressed class may contain relatively few examples. RDA trades some of that flexibility for a more stable estimate. It does not establish that those labels are economically useful or that the Gaussian model fits market tails.

Two controls, with an explicit convention

Let there be KK classes, pp features and n=∑k=1Knkn=\sum_{k=1}^{K}n_k training observations. For class kk, estimate its mean μ^k\widehat\mu_k and sample covariance using the divisor nk−1n_k-1:
Sk=1nk−1∑i:yi=k(xi−μ^k)(xi−μ^k)⊤,nk>1.S_k=\frac{1}{n_k-1}\sum_{i:y_i=k} (\mathbf{x}_i-\widehat\mu_k)(\mathbf{x}_i-\widehat\mu_k)^\top, \qquad n_k>1.
The pooled within-class covariance is
Spool=∑k=1K(nk−1)Skn−K.S_{\mathrm{pool}}=\frac{\sum_{k=1}^{K}(n_k-1)S_k}{n-K}.

It centres each observation around its own class mean. Taking the covariance around the overall mean would also incorporate differences between class means and would be a different matrix.

This article uses direct covariance mixing, followed by scaled-identity shrinkage:
Ak(λ)=(1−λ)Sk+λSpool,Σ^k(λ,γ)=(1−γ)Ak(λ)+γtr⁡(Ak(λ))pI,0≤λ,γ≤1.\begin{aligned} A_k(\lambda)&=(1-\lambda)S_k+\lambda S_{\mathrm{pool}},\\ \widehat\Sigma_k(\lambda,\gamma) &=(1-\gamma)A_k(\lambda) +\gamma\frac{\operatorname{tr}(A_k(\lambda))}{p}I, \qquad 0\leq\lambda,\gamma\leq1. \end{aligned}
Increasing λ\lambda makes the classes share more of their covariance structure. Increasing γ\gamma makes each resulting matrix more spherical: off-diagonal covariances move toward zero and variances move toward their average. This is covariance shrinkage used inside a classifier. The direct-mixing form is documented in the R klaR reference, More details.
Check the parameterisation before copying settings. Friedman's original formulation first mixes class and pooled scatter matrices and their sample weights, then divides. Its λ\lambda therefore need not equal the direct covariance weight above. With two equally sized classes and consistent divisors, original scatter-mixing λ=1/3\lambda=1/3 corresponds to direct covariance weight 1/21/2. The methods share endpoints, but an identical parameter label is insufficient to reproduce an intermediate fit. Friedman (1989), equations (16)–(18).

A checked two-feature example

Consider fictional training covariance summaries for two equally sized classes. Features have already been expressed in comparable units:

S1=(1009),S2=(9001),Spool=5I.S_1=\begin{pmatrix}1&0\\0&9\end{pmatrix},\qquad S_2=\begin{pmatrix}9&0\\0&1\end{pmatrix},\qquad S_{\mathrm{pool}}=5I.

At direct covariance weight λ=0.5\lambda=0.5,

A1=0.5S1+0.5(5I)=(3007).A_1=0.5S_1+0.5(5I) =\begin{pmatrix}3&0\\0&7\end{pmatrix}.

Its average variance is still (3+7)/2=5(3+7)/2=5. Taking γ=0.2\gamma=0.2 gives

Σ^1=0.8(3007)+0.2(5I)=(3.4006.6).\widehat\Sigma_1 =0.8\begin{pmatrix}3&0\\0&7\end{pmatrix}+0.2(5I) =\begin{pmatrix}3.4&0\\0&6.6\end{pmatrix}.
For class 2 the diagonal entries are reversed: 6.66.6 and 3.43.4. The class 1 spectral condition number falls from 99 to 6.6/3.4≈1.946.6/3.4\approx1.94, while its trace stays at 1010. These are consequences of the stipulated blend, not evidence that these hyperparameters minimise classification error.
Three unit Mahalanobis contours for fictional class 1: diagonal variances 1 and 9, then 3 and 7 at lambda 0.5, then 3.4 and 6.6 at gamma 0.2. A dashed circle shows pooled variances 5 and 5; class 2 swaps the feature axes.
Three unit Mahalanobis contours for fictional class 1: diagonal variances 1 and 9, then 3 and 7 at lambda 0.5, then 3.4 and 6.6 at gamma 0.2. A dashed circle shows pooled variances 5 and 5; class 2 swaps the feature axes.
Original fictional calculation. Solid contours show the two shrinkage stages; the dashed circle is the pooled reference. Contours have squared Mahalanobis distance one and are not labelled probability coverage regions.

What the endpoints mean

The table holds class means and priors fixed and assumes the matrices needed for scoring are invertible.

Settings under this article's conventionCovariance usedResult
λ=0,γ=0\lambda=0,\gamma=0Separate SkS_kQuadratic discriminant analysis, or QDA
λ=1,γ=0\lambda=1,\gamma=0Common SpoolS_{\mathrm{pool}}Linear discriminant analysis, or LDA
γ=1\gamma=1, any λ\lambdatr⁡(Ak)I/p\operatorname{tr}(A_k)I/pSpherical covariance for each class; scales can still differ between classes
λ=1,γ=1\lambda=1,\gamma=1Common tr⁡(Spool)I/p\operatorname{tr}(S_{\mathrm{pool}})I/pNearest Euclidean class mean when priors are equal

A spherical matrix has equal variances across features within that class. A merely diagonal matrix can retain different feature variances. Neither phrase should be substituted for the other. When the spherical scale differs across classes, the boundary can remain quadratic.

Software may use another shrinkage target. For example, scikit-learn's QDA reg_param is documented as shrinking its class scaling toward an unscaled identity, without this separate pooling control. It is not a drop-in name for γ\gamma in the formula above. Official QDA parameter reference.

The covariance is only part of the classification rule

For positive prior probabilities πk\pi_k summing to one, RDA chooses the class with the largest Gaussian log score:
δk(x)=log⁡πk−12log⁡det⁡Σ^k−12(x−μ^k)⊤Σ^k−1(x−μ^k).\delta_k(\mathbf{x})= \log\pi_k -\frac12\log\det\widehat\Sigma_k -\frac12(\mathbf{x}-\widehat\mu_k)^\top \widehat\Sigma_k^{-1}(\mathbf{x}-\widehat\mu_k).
The final term measures distance relative to class geometry. The log determinant accounts for density being spread over a larger volume; the prior accounts for baseline class prevalence. Omitting either can change the predicted class. This score is equivalent to minimising Friedman's equation (19), after multiplying by −2-2. Original classification rule.

Under the fitted Gaussian model, class probabilities follow by normalising exp⁡(δk)\exp(\delta_k). Compute this with a stable log-sum-exp calculation. Training class proportions are a possible prior estimate, but deliberately oversampling stress observations does not make their training frequency the deployment prevalence. Record the prior choice separately from the covariance settings.

Stability needs an honest evaluation

A class covariance has p(p+1)/2p(p+1)/2 distinct entries. After estimating the class mean, its rank is at most nk−1n_k-1, so it is necessarily singular when nk≤pn_k\leq p. Even when invertible, small estimated eigenvalues can make inverse-covariance distances unstable. Pooling helps only if the pooled estimate contains the missing directions; its rank is at most n−Kn-K.

For a positive-semidefinite AkA_k with positive trace, any γ>0\gamma>0 makes the stated spherical-shrinkage estimate positive definite: every eigenvalue receives a positive contribution γtr⁡(Ak)/p\gamma\operatorname{tr}(A_k)/p. If the trace is zero, this target provides no repair. Numerical invertibility also does not guarantee useful class separation or protection from outliers.

Select λ\lambda, γ\gamma and any feature processing using cross-validation within the development data, keeping the final test untouched. For nested cross-validation, repeat tuning separately within each outer training split and assess only on its held-out outer fold. Within each training fold, refit scaling, imputation, class means, covariances and data-estimated priors. Spherical shrinkage depends on feature units: changing one feature from decimals to basis points changes the target geometry unless the preprocessing convention compensates. Apply each fitted transformation unchanged to its held-out fold. The official preprocessing guidance explains this leakage control.
For market time series, use splits that respect information availability and overlapping labels. A random split can let future observations influence a historical forecast. The SelfMadeQuant lesson Time-Ordered Train, Validation and Test Design develops this workflow; its preview is public and the full teaching requires membership.
Finally, classification accuracy and probability calibration are different checks. Gaussian model probabilities can be overconfident under misspecified distributions or changing regimes. Assess reliability on held-out predictions; if recalibration is needed, fit it on predictions from observations excluded from the underlying classifier's fit, and reserve a further evaluation set. The official calibration guide explains the separation and reliability diagrams.
For the generative-model foundation, Generative Classifiers: Gaussian Discriminant Analysis and Naive Bayes derives the shared-covariance model and Bayes classification. Its preview is public; the full lesson requires membership.

Practice: why distance alone fails

Two classes have the same zero mean and equal priors in two dimensions. Their fitted covariances are II and 4I4I. For x=(1,0)⊤\mathbf{x}=(1,0)^\top, which class has the higher Gaussian score? Both covariances are already spherical.

Answer. Class 1. After dropping the common log prior, its score is −1/2-1/2. Class 2 has squared Mahalanobis distance 1/41/4, but determinant 1616, so its score is −12log⁡16−18≈−1.5113-\tfrac12\log16-\tfrac18\approx-1.5113. Choosing the smaller Mahalanobis distance alone would incorrectly select class 2. Spherical shrinkage does not remove the determinant term when class scales differ.

Sources

Last updated
  • classification
  • discriminant analysis
  • covariance shrinkage
  • regularisation
  • model validation
← Back to the glossaryBack to top ↑