It comes as no surprise that (“coefficient of determination”) equals in simple regression (predictor X, criterion Y), where is Pearson’s correlation coefficient. equals the fraction of explained variance in a simple regression. However, the statistical (mathematical) background is often less clear or buried in less-intuitive formula.
The goal of this post is to offer a gentle explanantion why
where is and are the predicted values.
Some more notation: are the individual values of the criterion, and is the mean of the criterion.
As an example, suppose we wanted to predict the grades () of some students based on their studying time (). Of course, our prediction won’t be perfect most of the time, so there will be gaps (errors or residuals) between what we predict and what the actual grade in some particular case will be. So
, or, similarly .
Let’s start with the idea that the variance is additive, see here or here for details. The additivity of variance implies that the whole variation in the students’ grades is the sum of the variance of our prediction errors and the improvement of our prediction/ regression model:
Total = Error^2 + Improvement^2.
Total variance in simple regression equals error variance plus variance explained by model.
This expression can be rearranged to
1 = Error^2 / Total + Improvement^2 / Total.
Puh, quite some stuff. Now we apply a property of least square regression stating that there is no correlation between the residuals (e) and the predicted value (we don’t discuss that property here further). More formally:
A bit more readable:
Now we write the (sample) correlation between actual (observed) and predicted (fitted) values as follows:
In other words,
Note that cancel out, leaving
The variance can be seen as the average of the squared sums (SS) of some delta (d): . If we on our way “lose” the part (as it happened in the line above), we are left with the sum of squares (SS), as they are called. Now, as we are concerned with the variance of the error, variance of the model improvement and the total variance, we can in the same way speak of the according SS-terms. We will come back to the SS-terms later on.
Now a little trick. We add the term , which is zero, so no harm caused. We get:
Now stay close. Observe that we have three terms in the numerator, let’s call them , , and . We can multiplicate that out resulting in . So:
As the denominator did not change, we just abbreviated it in the obvious way. Note that the numerator now is of the form (as b = c). Thus we can further simplify to
Referring back to our notion of the two parts of the total variance in regression we can think of the numerator above as , where e indicates the error or residual term, and m the model improvement. However, as the correlation between m and e (which is zero, see above) is nothing but average product of m and e, their sum also is zero. Thus we are left with
Think of the numerator as a and then , thus
After canceling out the obvious we are left with
This term is nothing but
Model variance / Total variance.
And we are there! To summarise
OK, quite some ride. At least we arrived where we headed to. Some algebra kungfu turned out to be handy. It took me some time to decypher the algebra without any explanation. So I hope me comments make the voyage a bit shorter for you.
Without some expertise in algebra (multiplicating out, adding zero-terms, …) and some knowledge of regression properties we would not have arrived at the end. The good news are that each of the steps is not really difficult to understand (I am not saying it is easy to discover these steps).