> For the complete documentation index, see [llms.txt](https://kmis.gitbook.io/statistics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kmis.gitbook.io/statistics/chapter-10.-correlation-and-regression/10-2.-the-linear-correlation-coefficient.md).

# 10-2. The Linear Correlation Coefficient

Figure 10.3 "Linear Relationships of Varying Strengths" illustrates linear relationships between two variables $$x$$ and $$y$$ of varying strengths. It is visually apparent that in the situation in panel (a), $$x$$ could serve as a useful predictor of $$y$$ , it would be less useful in the situation illustrated in panel (b), and in the situation of panel (c) the linear relationship is so weak as to be practically nonexistent. The ***linear correlation coefficient*** is a number computed directly from the data that measures the strength of the linear relationship between the two variables $$x$$ and  $$y$$. &#x20;

Figure 10.3 Linear Relationships of Varying Strengths

![](https://saylordotorg.github.io/text_introductory-statistics/section_14/1a22032a1f4d609c4190985036b7f704.jpg)

####

> *The* **linear correlation coefficient** *for a collection of* $$n$$ *pairs* $$(x,y)$$ *of numbers in a sample is the number* $$r$$ *given by the formula*&#x20;
>
> &#x20;                                                                $$r= \frac{SS\_{xy}} {\sqrt{SS\_{xx}⋅SS\_{yy}}}$$ &#x20;
>
> *where*   $$SS\_{xx}=Σx^2− \frac{1}{n}(Σx)^2$$ ,  \
> &#x20;             $$SS\_{xy}=Σxy− \frac{1}{n}(Σx)(Σy)$$ ,\
> &#x20;          $$SS\_{yy}=Σy^2− \frac{1}{n}(Σy)^2$$&#x20;

The linear correlation coefficient has the following properties, illustrated in Figure 10.4 "Linear Correlation Coefficient ":

1. The value of $$r$$ lies between −1 and 1, inclusive.
2. The sign of $$r$$ indicates the direction of the linear relationship between $$x$$ and $$y$$:
   1. If $$r<0$$ then $$y$$ tends to decrease as $$x$$ is increased.
   2. If $$r>0$$ then $$y$$tends to increase as $$x$$ is increased.
3. The size of $$|r|$$ indicates the strength of the linear relationship between $$x$$ and $$y$$:
   1. If $$|r|$$ is near 1 (that is, if $$r$$ is near either 1 or −1) then the linear relationship between $$x$$ and $$y$$ is strong.
   2. If $$|r|$$ is near 0 (that is, if $$r$$ is near 0 and of either sign) then the linear relationship between $$x$$ and $$y$$ is weak.

Figure 10.4 Linear Correlation Coefficient *R*

![](https://saylordotorg.github.io/text_introductory-statistics/section_14/07aa5db140b70615a15e8631c2d7a2c4.jpg)

Pay particular attention to panel (f) in Figure 10.4 "Linear Correlation Coefficient ". It shows a perfectly deterministic relationship between $$x$$ and $$y$$, but $$r=0$$ because the relationship is not linear. (In this particular case the points lie on the top half of a circle.)

**EXAMPLE 1.** Compute the linear correlation coefficient for the height and weight pairs plotted in Figure 10.2 "Plot of Height and Weight Pairs".

**\[ Solution ]**

&#x20;Even for small data sets like this one computations are too long to do completely by hand. In actual practice the data are entered into a calculator or computer and a statistics program is used. In order to clarify the meaning of the formulas we will display the data and related quantities in tabular form. For each $$(x,y)$$ pair we compute three numbers: $$x^2$$ , $$xy$$ , and $$y^2$$ , as shown in the table provided. In the last line of the table we have the sum of the numbers in each column. Using them we compute:

{% file src="/files/-LrZ\_PRBg0OL1aY1sbeG" %}

![](https://2234305379-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lqmt1Wp54aKlZ5eVcaS%2F-LrZX2_mWb3FyKNyfX8D%2F-LrZXM3uCBc-og5zWvhL%2Fimage.png?alt=media\&token=e98bca81-ecbe-40b2-bf89-2df74535585e)

$$SS\_{xx}=Σx^2− \frac{1}{n}(Σx)^2 = 61537 - \frac{859^2}{12}  = 46.916$$

$$SS\_{xy}=Σxy− \frac{1}{n}(Σx)(Σy) = 143626− \frac{(859)(2003)}{12}=244.583$$

$$SS\_{yy}=Σy^2− \frac{1}{n}(Σy)^2 = 336025− \frac{(2003)^2}{12}=1690.916$$

so that

&#x20;                    $$r= \frac{SS\_{xy}} {\sqrt{SS\_{xx}⋅SS\_{yy}}} = \frac{244.583 } {\sqrt {(46.916)(1690.916)}} = 0.868$$

The number $$r=0.868$$ quantifies what is visually apparent from Figure 10.2 "Plot of Height and Weight Pairs": weights tends to increase linearly with height ( $$r$$ is positive) and although the relationship is not perfect, it is reasonably strong ($$r$$ is near 1).

{% tabs %}
{% tab title="R Source" %}

```
x <- c(68, 69, 70, 70, 71, 72, 72, 72, 73, 73, 74, 75)
y <- c(151, 146, 157, 164, 171, 160, 163, 180, 170, 175, 178, 188)

cor(x, y, method="pearson")
```

{% endtab %}

{% tab title="r" %}

```
> cor(x, y, method="pearson")
## [1] 0.8683647
```

{% endtab %}
{% endtabs %}
