# Could data be described by a straight line when Pearson Correlation Coefficient has the highest absolute values?

Suppose that there is a dataset of 2D points $$(x_i, y_i)$$, consider the following statement:

"When the Pearson Correlation Coefficient(PCC) between $$x$$ and $$y$$ is equal to -1 or 1 (highest absolute values), data could be described by a straight line". That is, there are constants $$a$$ and $$b$$ such that:

$$y_i = ax_i+b \;\;\: \forall i$$

Now, I have two questions:

1) Is the above statement true?

2) More importantly, if the statement is true, please give a mathematical proof.

I have visually seen that a line can be fitted perfectly on such a dataset, but I am not sure this is always true, so I need a mathematical proof.

• To answer 1): yes, a value of 1 implies that a linear equation describes the relationship between X and Y perfectly, with all data points lying on a line. Sep 5 '19 at 10:00
• Part of the Cauchy-Schwarz Inequality asserts "Moreover, the two sides are equal if and only if $\mathbf {u}$ and $\mathbf {v}$ are linearly dependent," QED.
– whuber
Sep 5 '19 at 15:02
• Just to be clear. Nothing guarantees that a newly chosen point will fall on the line. The function may only be linear in the region where the points were taken. It is also possible that a new point taken between two data points could fall off the line. Now if you have a strange error term distribution that has a probability less than 1 of being 0 & consequently a positive probability of being different from 0 a new point could fall off the line and the linear equation previously determined could still hold. Sep 14 '19 at 22:25

For the answer 1), I just invite you to read the comment by @user2974951 which in a couple of words says exactly what is worth. I cite it "a value of 1 implies that a linear equation describes the relationship between X and Y perfectly, with all data points lying on a line". I stress the importance of linear, as the correlation is a measure for the linear interaction between variables.

Now for the point 2), I apologize if I only sketch a proof due to serious time constraints and very busy days on my side. But it will be enough. Consider that in a univariate regression with a single independent variable like $$y_{i}=a+\beta x_{i}+ \epsilon_{i}$$ with $$i=1,...,n$$, the $$R^{2}$$ of the regression can be retrieved as the square of the correlation coefficient between the two variable. Therefore setting the corr equal to 1 implies $$R^{2}=1$$. Take the formula for $$R^{2}$$ (here we take the one assuming there is an intercept as you hinted) given by:

$$R^2=1-\frac{\sum_{i=1}^{n}e_i^2}{\sum_{i=1}^{n}(y_i-\bar{y})^2}$$

Then set it to 1 and solve for the sum of squared errors at the numerator, then evaluate the implications for each observation residual. You get:

$$R^2=1 \rightarrow 1-\frac{\sum_{i=1}^{n}e_i^2}{\sum_{i=1}^{n}(y_i-\bar{y})^2} = 1 \rightarrow \frac{\sum_{i=1}^{n}e_i^2}{\sum_{i=1}^{n}(y_i-\bar{y})^2} = 0 \rightarrow \sum_{i=1}^{n}e_i^{2} = 0 \rightarrow e_i^{2}=0 \text{ for each i} \rightarrow e_i=0 \text{ for each i} \rightarrow y_{i}=a+\beta x_{i} \text{ for each i}$$

• For a much shorter demonstration, please see my comment to the question.
– whuber
Sep 5 '19 at 15:02
• @whuber very nice! Thanks
– Fr1
Sep 5 '19 at 15:40