2
$\begingroup$

I am a bit confused about the relationship between Pearson's $r$ and the Coefficient of Determination $R^2$.

$$ r = \frac{\sum\limits_{i = 1}^n (x_i - \overline x)(y_i - \overline y)}{\sqrt{\sum\limits_{i = 1}^n (x_i - \overline x)^2(y_i - \overline y)^2}} $$

$$ R^2 = 1 - \frac{\sum\limits_{i = 1}^n (x_i - y_i)^2}{\sum\limits_{i = 1}^n (x_i - \overline x)^2} $$

Let $y$ be the prediction and $x$ be the actual values, and $\overline y$ and $\overline x$ their means.

Most explanations I have read says that $R^2$ can be derived by squaring the Pearson's $r$, and hence the name. However, using the formulas given above, then a squaring of $r$ does not equal $R^2$; at least for the data I have tried with.

Are the formulas wrong, or what is happening?

Wikipedia have a vague statement here: When an intercept is included, then $r^2$ is simply the square of the sample correlation coefficient (i.e., r).

$\endgroup$
1
  • 3
    $\begingroup$ Your notation is quite confusing. $x$ is normally used for a regressor rather than for the actual values. Actual values are normally denoted $y$ which you use for fitted values. Fitted values are normally denoted $\hat y$. In addition, the first denominator is wrong. You should have a product of two roots, one of variance of $x$ and another of variance of $y$ (using your notation). $\endgroup$ Commented Feb 7, 2018 at 16:37

2 Answers 2

4
$\begingroup$

Your confusion lies in the fact that this only works if $x_i = \hat{y_i}$, where $\hat{y_i}$ are the OLS predicted values for $y$ based on $x$ (i.e. linear regression of $y$ on $x$). Try running this regression and using $\hat{y}$ instead of $x$ and it'll work.

The short version is that for this to work, $x$ needs to satisfy several criteria (e.g. $\sum x_i(y_i - x_i) = 0$, etc), which are satisfied when $x_i = \hat{y_i}$.

$\endgroup$
1
  • $\begingroup$ Sorry, you're right. I fixed it :) $\endgroup$ Commented Feb 7, 2018 at 17:21
0
$\begingroup$

Even if your post is already some days old - for my own research I came across this post and about a very nice side that explains. So, maybe for others out there, have a look here: https://towardsdatascience.com/r%C2%B2-or-r%C2%B2-when-to-use-what-4968eee68ed3

BG Trieniti

$\endgroup$
2
  • $\begingroup$ While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review $\endgroup$ Commented May 24, 2022 at 0:39
  • $\begingroup$ Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. $\endgroup$
    – Community Bot
    Commented May 24, 2022 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.