How should the number of predictors relate to sample size, and what happens with too many predictors?

Quick Overview

Asks how many observations a regression needs per predictor and what goes wrong as the predictor count approaches or passes the sample size. It tests overfitting, coefficient variance, degrees of freedom, why least squares stops having a unique solution, and the usual remedies.

How should the number of predictors relate to sample size, and what happens with too many predictors?

Role: Data Scientist

Category: Machine Learning

Difficulty: medium

Interview Round: Other

How should the number of predictors relate to your sample size, and what happens when you have too many predictors relative to observations? ```hint Count parameters Count everything the model estimates, including the intercept and every dummy level, and compare that with the number of rows. ``` ```hint Look at the normal equations What happens to $X^\top X$ when the design matrix has more columns than rows? ``` ### What a Strong Answer Covers - A rule of thumb for observations per estimated parameter, and what counts as a parameter - How overfitting, coefficient variance and error degrees of freedom change as the number of predictors approaches the sample size - Why ordinary least squares has no unique solution once the parameters outnumber the observations - Remedies such as more data, dimensionality reduction and regularization ### Follow-up Questions - Why does in-sample R-squared rise even when the added predictors are pure noise, and what would you look at instead? - How does ridge regression give a unique solution when there are more predictors than observations? - How would the rule of thumb change for a logistic regression on a rare outcome? - If you screen predictors by their correlation with the outcome before fitting, what goes wrong with the later validation?

Overview: Asks how many observations a regression needs per predictor and what goes wrong as the predictor count approaches or passes the sample size. It tests overfitting, coefficient variance, degrees of freedom, why least squares stops having a unique solution, and the usual remedies.

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

How should the number of predictors relate to your sample size, and what happens when you have too many predictors relative to observations?

What a Strong Answer Covers Guidance

  • A rule of thumb for observations per estimated parameter, and what counts as a parameter
  • How overfitting, coefficient variance and error degrees of freedom change as the number of predictors approaches the sample size
  • Why ordinary least squares has no unique solution once the parameters outnumber the observations
  • Remedies such as more data, dimensionality reduction and regularization

Follow-up Questions Guidance

  • Why does in-sample R-squared rise even when the added predictors are pure noise, and what would you look at instead?
  • How does ridge regression give a unique solution when there are more predictors than observations?
  • How would the rule of thumb change for a logistic regression on a rare outcome?
  • If you screen predictors by their correlation with the outcome before fitting, what goes wrong with the later validation?