Skip to main content
v2026.11,858 entries · CC-BY 4.0

Perfect Multicollinearity: Definition, Example and How to Fix It

Perfect multicollinearity (perfect collinearity) means a predictor is an exact linear combination of others. See why OLS fails, a worked example and fixes.

Written and maintained by CASRAI Editorial Board

Last updated

What perfect multicollinearity (perfect collinearity) means

Perfect multicollinearity, also called perfect collinearity, occurs when one regressor in a regression model can be written as an exact linear combination of the other regressors, including the constant. When that happens, ordinary least squares (OLS) cannot assign a unique coefficient to each predictor, because infinitely many coefficient sets fit the data equally well. It is a property of the design matrix, not of the sample size or the outcome variable, and it is the extreme case of the problem covered in multicollinearity and VIF in regression.

Formula: why OLS cannot be computed

For a model y = Xβ + ε, X is the n × k design matrix (n observations, k columns including the column of ones), y is the outcome vector, β is the vector of k coefficients and ε is the error vector. The OLS solution is

β̂ = (X′X)−1 X′y

where X′ is the transpose of X and (X′X)−1 is the matrix inverse. The inverse exists only if X has full column rank, meaning rank(X) = k. Under perfect multicollinearity at least one column of X is a linear combination of the others, so rank(X) < k, X′X is singular (its determinant is 0) and the formula has no solution.

Worked example with real numbers

Take four observations with a constant, a predictor x₁ and a second predictor x₂ that is defined as x₂ = 1 + 2x₁. The outcome is y.

Obs. Constant x₁ x₂ = 1 + 2x₁ y
1 1 1 3 5
2 1 2 5 9
3 1 3 7 12
4 1 4 9 18

Compute X′X from the sums: n = 4, Σx₁ = 10, Σx₂ = 3 + 5 + 7 + 9 = 24, Σx₁² = 1 + 4 + 9 + 16 = 30, Σx₁x₂ = 3 + 10 + 21 + 36 = 70 and Σx₂² = 9 + 25 + 49 + 81 = 164. So

X′X = [  4  10  24 ]
      [ 10  30  70 ]
      [ 24  70 164 ]

The third column equals the first column plus twice the second: 4 + 2(10) = 24, 10 + 2(30) = 70 and 24 + 2(70) = 164. Because one column is a combination of the others, the determinant is 0 and the matrix has rank 2, not 3. No inverse exists.

The consequence is that the data cannot tell the effect of x₂ from the effect of x₁. Any coefficients (b₀ − t, b₁ − 2t, b₂ + t) produce the same fitted values for every value of t. A minimum-norm solver returns the set b₀ = −0.9833, b₁ = 1.2333, b₂ = 1.4833, and each fitted value matches the t = 0 version (for observation 1: −0.9833 + 1.2333 + 1.4833 × 3 = 4.7). That is only one of infinitely many equally good answers, so the individual coefficients carry no information.

Dropping x₂ restores a unique fit. With only the constant and x₁: x̄ = 2.5, ȳ = 11, Σ(x₁ − x̄)(y − ȳ) = 9 + 1 + 0.5 + 10.5 = 21, Σ(x₁ − x̄)² = 5, so slope = 21 / 5 = 4.2 and intercept = 11 − 4.2 × 2.5 = 0.5. The fitted values are 4.7, 8.9, 13.1 and 17.3, which gives a residual sum of squares of 0.09 + 0.01 + 1.21 + 0.49 = 1.80. The same fitted values from the singular model show that x₂ added nothing.

The dummy variable trap

The most common real-world source is the dummy variable trap: a categorical variable with m categories is coded as m dummy columns and the model also keeps a constant. The dummies sum to 1 in every row, which equals the constant column, so the columns are exactly dependent. Hanck, Arnold, Gerber and Schmelzer describe the trap as not paying attention and falsely including exhaustive dummies. With three groups (a, b, c) and two observations each, the design matrix has 4 columns (constant plus three dummies) but rank 3. The fix is to drop one category, the reference category, or to drop the constant. See creating dummy variables in Stata for coding patterns.

Interpretation: how perfect collinearity shows up

There is no statistic to interpret, because the model is not identified. What you can read is what your software does and what it means.

What you see What it means Typical action
R lm() prints NA for a coefficient and notes “1 not defined because of singularities” R found an exactly dependent column and marked that coefficient as aliased Identify the dependency, remove or recode one variable, refit
numpy linalg.inv(X.T @ X) raises “Singular matrix” X′X has no inverse in this example Check rank with numpy.linalg.matrix_rank
Correlation between two predictors is exactly 1 or −1 Two columns are perfectly linearly related (the pairwise case only) Remove one of the pair

R behaves differently from some packages: in the lm documentation, the argument singular.ok is described as “If FALSE (the default in S but not in R) a singular fit is an error.” By default R therefore fits the model and omits aliased terms, which the summary.lm documentation says are “omitted in the returned object but restored by the print method.” A silent NA is easy to miss, so check for it. Perfect collinearity is distinct from the near-perfect case; for variance inflation factors, thresholds and centring, use the VIF guide.

Assumptions and common mistakes

  • The assumption. Multiple regression assumes no perfect multicollinearity, that is, no regressor is an exact linear combination of the others (Hanck et al., section 6.4).
  • Dummy trap. Including a constant and a dummy for every category.
  • Redundant units. Entering the same measurement twice, such as a length in centimetres and the same length in metres.
  • Totals alongside parts. Including a total score and all the sub-scores that sum to it.
  • Too few observations. Having more columns than rows (k > n) forces rank(X) < k even if no two variables look related.
  • Checking pairs only. A pairwise correlation matrix catches a perfect link between two variables but not an exact dependency spread across three or more, like the dummy trap.
  • Reading aliased output as zero effect. An NA does not mean the predictor has no effect; it means the data cannot separate it from the others.

How to report it

You normally do not report perfect collinearity as a result; you report the corrected model. If a predictor was removed because of it, say so in the analysis plan or the methods section. An APA-style sentence could read: “The categorical variable was entered as two dummy variables with the third category as the reference, because including all three dummies alongside the intercept would have produced perfect multicollinearity.” A second option: “The total score was excluded because it was an exact linear combination of the three subscale scores already in the model.” Report the final model’s coefficients and standard errors as usual; for other regression reporting conventions see regression analysis.

How to calculate it in Excel, R or Python

Excel

Put the constant in A2:A5, x₁ in B2:B5 and x₂ in C2:C5, then enter the determinant of X′X (array-enter with Ctrl+Shift+Enter in older versions):

=MDETERM(MMULT(TRANSPOSE(A2:C5), A2:C5))

A result of 0, or a value on the order of rounding error, signals a singular X′X. =CORREL(B2:B5, C2:C5) returns 1 here but only detects a pairwise relationship.

R

For a table of how R shows this in practice, see logistic regression in R.

x1 <- c(1, 2, 3, 4)
x2 <- 1 + 2 * x1
y  <- c(5, 9, 12, 18)
fit <- lm(y ~ x1 + x2)
summary(fit)          # an aliased coefficient is shown as NA
summary(fit)$aliased  # TRUE marks aliased coefficients
fit$rank              # 2, fewer than the 3 coefficients

Python

import numpy as np
x1 = np.array([1, 2, 3, 4.0])
x2 = 1 + 2 * x1
X = np.column_stack([np.ones(4), x1, x2])
print(np.linalg.matrix_rank(X))   # 2, not 3
print(np.linalg.det(X.T @ X))     # 0.0
np.linalg.inv(X.T @ X)            # LinAlgError: Singular matrix

FAQ

What is the difference between perfect collinearity and perfect multicollinearity?

In practice the terms are used interchangeably. Collinearity is often used for two variables and multicollinearity for several, but both describe an exact linear dependency among predictors that makes OLS unsolvable.

How do I fix perfect multicollinearity?

Remove or recode the redundant variable: drop one dummy (the reference category), drop the duplicated or derived variable, or collect more observations than parameters. Then refit and confirm that no coefficient is NA.

Does perfect multicollinearity raise an error?

It depends on the software. R fits the model by default and reports aliased coefficients as NA; some tools warn or raise an error when inverting X′X.

Is near-perfect collinearity the same problem?

No. With near-perfect collinearity the model can be estimated but the standard errors are inflated. See the VIF guide.

Sources

Sources checked on 2026-10-29.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Perfect Multicollinearity: Definition, Example and How to Fix It

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Ask CASRAI · Regulatory Radar

Research-admin question? Get an answer that links its sources.

An AI assistant specialized in research administration. Every answer links its sources to check before you act. 2 questions free, no account. $29/month after.

  • Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.
  • Every answer numbers its sources and links each one, so you can check the source yourself.