When is X^T X singular (non-invertible), and how does that affect fitting a linear regression?

Quick Overview

Asks when the matrix X^T X in linear regression becomes singular and what that does to fitting the model. It tests rank and linear dependence, the common causes in real feature sets, which quantities stay identified, and how each remedy trades off.

When is X^T X singular (non-invertible), and how does that affect fitting a linear regression?

Role: Data Scientist

Category: Machine Learning

Difficulty: medium

Interview Round: Other

In ordinary least squares with design matrix $X$ (n rows, p columns), under what conditions would the matrix $X^T X$ be non-invertible (singular), and how does that affect your ability to fit a model? ```hint Look at the null space Ask what it means for a nonzero vector $v$ to satisfy $X^T X v = 0$, and what that says about $Xv$. ``` ```hint Think about real feature sets List the ways a design matrix ends up with dependent columns in practice, including how categorical variables are encoded. ``` ### What a Strong Answer Covers - The exact condition for singularity in terms of the columns or rank of $X$ - Concrete ways it happens in real data - What happens to the OLS fit and which quantities are still identified - Remedies and the trade-off each one makes - The nearly singular case and what it does to coefficient variance ### Follow-up Questions - If $X^T X$ is invertible but nearly singular, what happens to the coefficient estimates and their standard errors? - Which solution does the pseudo-inverse pick, and when is that a reasonable default? - Why does ridge regression make the matrix invertible for any positive penalty? - How do common libraries behave when you fit OLS on a rank-deficient design?

Overview: Asks when the matrix X^T X in linear regression becomes singular and what that does to fitting the model. It tests rank and linear dependence, the common causes in real feature sets, which quantities stay identified, and how each remedy trades off.

PracHub logo
General
Nov 24, 2026
mediumData ScientistOtherMachine Learning
0
0

In ordinary least squares with design matrix XX (n rows, p columns), under what conditions would the matrix XTXX^T X be non-invertible (singular), and how does that affect your ability to fit a model?

What a Strong Answer Covers Guidance

  • The exact condition for singularity in terms of the columns or rank of XX
  • Concrete ways it happens in real data
  • What happens to the OLS fit and which quantities are still identified
  • Remedies and the trade-off each one makes
  • The nearly singular case and what it does to coefficient variance

Follow-up Questions Guidance

  • If XTXX^T X is invertible but nearly singular, what happens to the coefficient estimates and their standard errors?
  • Which solution does the pseudo-inverse pick, and when is that a reasonable default?
  • Why does ridge regression make the matrix invertible for any positive penalty?
  • How do common libraries behave when you fit OLS on a rank-deficient design?