Adjusted R-squared
As we add more independent variables to our regression, we might be encouraged by the fact that our R2 value always increases. Adding a new independent variable isn't going to make it harder to predict the dependent variable—if the new variable has no explanatory power, then its coefficient will simply be zero and the R2 will remain the same as it was without the independent variable.
However, this doesn't tell us whether a model has been improved by the addition of a new variable. If we want to know whether our new variable is really helping it to generate a better fit, we can use the adjusted R2, often written as and pronounced as "R-bar squared." Unlike R2, will only increase if the new independent variable increases R2 more than would be expected due to chance:
(defn matrix-adj-r-squared [coefs x y] (let [r-squared (matrix-r-squared coefs x y) n (count y) p (count coefs)] (- 1 (* (- 1 r-squared) (/ (dec n) (dec (...