Qm
Advanced

The p Greater Than n Regime

When you have more candidate features than observations, ordinary regression doesn't just get noisier, it stops having a unique answer at all, and that changes everything about how you have to estimate.

Prerequisites: The Curse of Dimensionality, High-Dimensional Mean Testing When p Exceeds n

Suppose someone asks you to draw the one true straight line through a single data point. You can't, a line has two degrees of freedom (a slope and an intercept), and one point isn't enough to pin both down; infinitely many different lines pass through it exactly. Give them a second point and, generically, exactly one line fits both. This isn't really about lines specifically, it's about having fewer independent facts than unknowns. When the number of candidate predictor variables pp exceeds the number of observations nn, you're in exactly this situation, just scaled up: you're trying to determine pp regression coefficients from only nn rows of data, and when p>np > n there are infinitely many combinations of coefficients that fit the data perfectly. This is the "p greater than n" regime, and it is a qualitatively different problem from ordinary small-sample noise, it's not that the answer is uncertain, it's that there is no unique answer to be uncertain about, without bringing in extra assumptions from outside the data.

1 point: infinitely many lines fit exactly 2 points: exactly one line fits
With fewer data points than a model's degrees of freedom, infinitely many parameter settings fit the data equally well, this is the geometric heart of why p greater than n leaves ordinary least squares without a unique answer.

Why it breaks, one symbol at a time

Ordinary least squares solves for coefficients β^\hat\beta by minimizing squared error, and the closed-form solution requires inverting the matrix XXX'X, where XX is the n×pn \times p matrix of predictor values:

β^=(XX)1Xy\hat\beta = (X'X)^{-1} X'y

In words: the fitted coefficients come from "undoing" the predictor-to-predictor relationships captured in XXX'X and applying that to how the predictors relate to the target yy. The matrix XXX'X is p×pp \times p, and its rank can never exceed min(n,p)\min(n, p), a basic fact about matrices built by multiplying an n×pn \times p matrix by its own transpose. When p>np > n, the rank of XXX'X is at most nn, strictly less than pp, which means XXX'X is singular, not invertible, and (XX)1(X'X)^{-1} simply does not exist. The regression doesn't have one right answer with some uncertainty around it; it has an entire subspace of solutions that all achieve exactly zero training error, and nothing in the data itself picks among them.

Worked example 1: an explicitly singular matrix

Take p=3p=3 candidate features but only n=2n=2 observations:

X=(123214)X = \begin{pmatrix} 1 & 2 & 3 \\ 2 & 1 & 4 \end{pmatrix}

Then XXX'X is 3×33\times3:

XX=(54114510111025)X'X = \begin{pmatrix} 5 & 4 & 11 \\ 4 & 5 & 10 \\ 11 & 10 & 25 \end{pmatrix}

Its determinant works out to exactly 00 (checkable by cofactor expansion, or by noting a 3×33\times3 matrix built from only 2 independent rows of underlying data cannot have full rank 3), confirming XXX'X is singular, so (XX)1(X'X)^{-1} doesn't exist and OLS has no unique solution. Now contrast with n=4>p=3n=4 > p=3, using an additional two observations (0,1,1)(0,1,1) and (3,0,2)(3,0,2) added to XX: the resulting 4×34\times3 matrix generically has rank 33 (full column rank), and the corresponding XXX'X has a nonzero determinant, so it's invertible and OLS returns exactly one answer.

Worked example 2: ridge regression restores a unique answer

Ridge regression adds a small positive constant λ\lambda times the identity matrix before inverting:

β^ridge=(XX+λI)1Xy\hat\beta_{\text{ridge}} = (X'X + \lambda I)^{-1} X'y

In words: nudge every diagonal entry of XXX'X up by λ\lambda before inverting, this guarantees invertibility regardless of rank, because adding λI\lambda I to a matrix shifts every eigenvalue up by λ\lambda, and a matrix with all-positive eigenvalues is always invertible. Using the same p=3p=3, n=2n=2 example, take λ=1\lambda = 1: XX+I=(64114610111026)X'X + I = \begin{pmatrix}6&4&11\\4&6&10\\11&10&26\end{pmatrix}. This matrix now has a nonzero determinant (unlike the un-regularized version), so it can be inverted and β^ridge\hat\beta_{\text{ridge}} is a single, well-defined vector even though p>np > n. The cost is that β^ridge\hat\beta_{\text{ridge}} is now biased toward zero relative to whatever the "true" coefficients might be, you've traded the complete non-identifiability of raw OLS for a unique but shrunk, and therefore biased, answer. The alternative path is reducing pp first, via feature selection, principal components, or an explicit sparsity assumption (most true coefficients are exactly zero), so that ordinary methods apply to a smaller, well-posed problem.

When p>np > n, OLS doesn't fail by becoming "more uncertain", it fails by having infinitely many equally-perfect-fitting solutions, because XXX'X is mathematically singular. Getting a unique, useful answer requires bringing in extra structure from outside the data: regularization, dimension reduction, or an explicit sparsity assumption.

X'X (p>n): det = 0 not invertible infinitely many solutions +λI X'X + λI: det ≠ 0 invertible unique, but biased, solution
Adding a small ridge penalty to the diagonal of a singular matrix restores invertibility and gives a unique answer, at the cost of introducing bias toward zero.

What this means in practice

  • This is the default regime for cross-sectional equity research with a large factor library. Hundreds of engineered signals or alternative-data features tested against a modest number of independent time periods routinely puts pp comfortably above nn (in the relevant, effectively-independent sense), so lasso-type sparsity assumptions or heavy dimension reduction aren't optional extras, they're required for the estimation problem to be well-posed at all.
  • High-dimensional risk models face the same wall when the number of securities or candidate factors exceeds the number of independent history days, this is precisely why factor covariance estimation leans on structure (a small number of common factors) rather than a raw high-dimensional covariance matrix.
  • Cross-validation still "runs" in software even when p>np > n without regularization, a pseudo-inverse will silently return some numbers, which is exactly why this failure mode is dangerous rather than merely inconvenient; nothing crashes, but the output has no statistical meaning as an estimate of anything.

The classic confusion: treating p>np > n as just a more severe version of ordinary small-sample noise, where the answer is still "the same estimate, but with wider confidence intervals." It's categorically different. Without added structure, the estimator isn't a noisy version of a unique truth, it's genuinely non-unique, with infinitely many equally-fitting solutions and no principled way, from the data alone, to prefer one over another. Statistical software that computes some answer via a pseudo-inverse can look exactly like a normal regression output, complete with coefficient values, while carrying zero statistical justification as an estimate of the true relationship, the numbers are real, but their meaning is not.

Discussion

Sign in to join the discussion · reading is open to everyone

💡 Discussion rules

  1. Ask and answer about this concept. Off-topic gets removed.
  2. No homework dumps. Show what you tried first.
  3. Corrections are welcome. Cite a source when you claim an error.

Loading discussion…

Related concepts

Practice in interviews

Further reading

  • Hastie, Tibshirani & Wainwright, Statistical Learning with Sparsity, ch. 1-2
  • Bühlmann & van de Geer, Statistics for High-Dimensional Data, ch. 2
ShareTwitterLinkedIn