September 2015
Beginner to intermediate
608 pages
13h 43m
English
While calculating R2 previously, we saw how it was the amount of variance explained by the model:

Since the variance is the mean squared error, we can multiply both the var(ε) and var(y) terms by the sample size and arrive at the following alternative equation for R2:

This is simply the sum of squared residuals over the sum of squared differences from the mean. Incanter contains the incanter.core/sum-of-squares function that makes this very simple to express:
(defn r-squared [coefs x y] (let [fitted (i/mmult x coefs) residuals (i/minus ...
Read now
Unlock full access