Tech Challenge
2026-08-22
🤖
Daily Tech Challenge
AI & ML
medium
Question 1 of 5
A linear model is fit on two features that are almost the same column. The fitted coefficients come out enormous and opposite in sign, yet R-squared is essentially identical to a fit on x1 alone. What is going on, and what does the Variance Inflation Factor measure?
Example
import numpy as np, statsmodels.api as sm rng = np.random.default_rng(0) x1 = rng.normal(size=500) x2 = x1 + rng.normal(scale=0.01, size=500) # almost a copy of x1 y = 3.0 * x1 + rng.normal(scale=0.5, size=500) X = sm.add_constant(np.column_stack([x1, x2])) fit = sm.OLS(y, X).fit() print(fit.params) # e.g. [0.01, 12.7, -9.7] -- true signal is (0, 3, 0) print(fit.bse) # standard errors are huge print(fit.rsquared) # ~0.97, basically unchanged vs x1 alone # VIF for feature j: 1 / (1 - R2 of regressing x_j on the OTHER features)
Saturday, August 22, 2026 · A new challenge drops every day