Do not trust a table you have not tested
A regression summary always looks authoritative, and statsmodels hands you the tools to check it. The variance inflation factor, variance_inflation_factor(matrix, i), measures how well one regressor is explained by the others: it equals 1/(1-Rⱼ²), values above 5 to 10 mean the coefficients are unstable, and the matrix must include the constant column (so the first regressor sits at position 1). durbin_watson(resid) is near 2 when errors are uncorrelated and near 0 when they trail each other. het_breuschpagan(resid, exog) returns four numbers whose second is the p-value of the test that the error variance is constant. jarque_bera(resid) returns the statistic, the p-value, the skewness and the kurtosis, and acorr_ljungbox(resid, lags=[12]) returns a DataFrame with the column lb_pvalue. For all of them a small p-value is a warning.
Two more checks complete the set. Cook's distance, res.get_influence().cooks_distance[0], scores each observation by how much the fit would move if it were removed, so the months with the largest values are the ones that drive the result. And the spurious regression is the classic trap: regress the log price of Home Depot on the log price of Lowe's and you get R²=0.93 with a Durbin–Watson statistic of 0.002, because two trending series always look related. A high R² with a Durbin–Watson near zero is the sign that you regressed one random walk on another. For Apple's three-factor regression (258 months) the factor VIFs are 1.13, 1.13 and 1.02, Durbin–Watson is 1.94, the Breusch–Pagan p-value is 0.21 and the Jarque–Bera p-value 0.015; adding SPY beside the market factor gives VIFs of 186 and 177; the most influential months are September 2008, January 2022 and October 2008.
- One number per worry: VIF for copies, Durbin–Watson and Ljung–Box for memory, Breusch–Pagan for spread, Jarque–Bera for shape, Cook's distance for single months.
- Mind the constant: VIF needs the design matrix with its constant column, and the regressors then start at position 1.
- A high R-squared proves nothing alone: two trending prices regress beautifully and the Durbin–Watson statistic gives it away.
Lab · what's graded
- OLS with the array API10 pts
- Variance inflation factors20 pts
- Four residual tests20 pts
- Influential months15 pts
- A spurious regression15 pts
- The whole diagnosis20 pts