I'm completely confused about how to calculate R-squared for given lists of predicted and actual values.
As an example, assume that my predicted values are: [3, 8, 10, 17, 24, 27] and my actual values are [2, 8, 10, 13, 18, 20].
According to wikipedia, I do the following:
- get the mean of the actual values (y-bar) = 14.8333
- compute the residual sum of squares (RSS). For each pair of values, I'm getting the difference, squaring it, and summing the results. i.e. (3-2)^2 + (8-8)^2 + (10-10)^2 and so on. For my data this is 102.
- Compute the total sum of squares (TSS). For each actual value, subtract it from the mean of the actual values, square the result, and sum all of these. i.e. (2-14.833)^2 + (8-14.833)^2 and so on. So TSS = 220.83333.
- R^2 = 1 - RSS/TSS = .53811
Contrast this method with one described here, which says I also need to be using the average of the predicted values, as well as what Excel gives using the RSQ formula (.9729).
Am I doing something wrong above? Which is the correct formula/method to use?