Correlation coefficient

相关系数

How is the correlation coefficient computed?

Average the products of the standardised values; the result runs from minus one to one and measures direction and strength.

SkillKP000940

Sign in to read the whole lesson, with 2 more worked examples, 13 exercises

Sign in / Sign up

Mastery goals

  • Can compute the sample correlation coefficient r = Σ(xᵢ − x̄)(yᵢ − ȳ)/√[Σ(xᵢ − x̄)²·Σ(yᵢ − ȳ)²] by formula or with technology
  • Can state properties of r (unit-free, between −1 and 1, measures only linear association), use its sign for the direction and |r| for the strength of a linear association

8.1.2 Sample Correlation Coefficient

From the pattern of paired sample data in a scatter plot, we can roughly infer whether two variables are correlated, whether the correlation is positive or negative, whether it is linear or nonlinear, and so on. A scatter plot is direct, but it cannot show exactly how strongly the paired sample data are correlated, so it cannot put a number on the strength of the correlation between two variables. Just as we introduced numerical characteristics such as the mean and variance to analyze data of a single variable, can we introduce a suitable "numerical characteristic" to measure how strongly paired sample data are correlated?

For variables and , let the paired sample data obtained by random sampling be , , …, , where the means of and of are and . To show how the observations of each variable rise or fall relative to its mean, subtract the mean from each observation of each variable to get the paired data

and draw their scatter plot.

Treating the data in Table 8.1-1 this way gives Figure 8.1-3. Most of the points now lie in the first and third quadrants: for most points the two coordinates have the same sign. Clearly this pattern comes from the positive correlation between body-fat percentage and age.

xyO−30−25−20−15−10−551015−20−15−10−5510
Figure 8.1-3: scatter plot after subtracting the mean age from each age in Table 8.1-1 and the mean body-fat percentage from each body-fat value.

In general, if the variables and are positively correlated, then after shifting by the means most of the points lie in the first and third quadrants, and most of the corresponding pairs have the same sign, as in Figure 8.1-4 (1); if and are negatively correlated, then after shifting by the means most of the points lie in the second and fourth quadrants, and most of the corresponding pairs have opposite signs, as in Figure 8.1-4 (2).

xyO−4−3−2−11234−4−3−2−11234
Figure 8.1-4 (1): positive correlation
xyO−4−3−2−11234−4−3−2−11234
Figure 8.1-4 (2): negative correlation

Inspired by the discussion above, we use whether the two coordinates of each point () have the same sign to build the quantity

In general, shows that the paired sample data are positively correlated, and that they are negatively correlated.

The size of depends on the units the data are measured in, so it is not suitable for measuring the strength of the correlation directly. For example, when studying how strongly weight and height are correlated, if the unit of weight stays the same and the unit of height changes from metres to centimetres, becomes times as large, yet changing the unit does not change how strongly weight and height are correlated.

To remove the effect of the units, the data need to be "standardized". We divide and () by

respectively, getting

For simplicity, write these "standardized" paired data as

Following the construction of , we get

We call the sample correlation coefficient of the variables and .

So we have built the sample correlation coefficient from paired sample data. It is a numerical characteristic that describes paired sample data, and its sign reflects how the paired sample data vary:

When , the paired sample data are said to be positively correlated. Then, when the value of one of the data gets smaller, the value of the other usually gets smaller too; when the value of one gets larger, the value of the other usually gets larger too.

When , the paired sample data are said to be negatively correlated. Then, when the value of one of the data gets smaller, the value of the other usually gets larger; when the value of one gets larger, the value of the other usually gets smaller.

How, then, is the size of related to how strongly the paired sample data are correlated? To answer this, we first look at the range of values of .

The structure of recalls the coordinate form of the dot product of two-dimensional (plane) and three-dimensional (space) vectors. We extend vectors to dimensions. The dot product of -dimensional vectors , is still defined as

where is the angle between and . As with the coordinates of plane and space vectors, for vectors and we have

Let the first components of the "standardized" paired data , , …, form the -dimensional vector

and the second components form the -dimensional vector

Then

Since , the sample correlation coefficient is

where is the angle between the vectors and .

From we know that

When , the angle in is or , so the vectors and are collinear. From what we know about vectors, there is a real number with , that is,

This shows that all the paired sample data lie on the line

In this case the two components of the paired sample data satisfy a linear relationship.

So the range of the sample correlation coefficient is .

The absolute value of reflects how strongly the paired sample data are linearly correlated:

The closer is to , the stronger the linear correlation of the paired sample data;

the closer is to , the weaker the linear correlation of the paired sample data.

The sample correlation coefficient is sometimes also called the sample linear correlation coefficient, and describes how closely the sample points gather around some straight line. When , this only shows that the paired sample data have no linear correlation; it does not rule out some other kind of correlation between them.

Figure 8.1-5 shows scatter plots of several sets of paired sample data with their sample correlation coefficients. In plot (1) the points clearly tend to run along a straight line from bottom left to top right, so the paired sample data show a linear correlation; the sample correlation coefficient shows a very strong positive linear correlation. In plot (2) the points clearly tend to run along a straight line from top left to bottom right, so these paired sample data also show a linear correlation; shows a fairly strong negative linear correlation. Judging by the sample correlation coefficients, the linear correlation in plot (1) is somewhat stronger than in plot (2); the linear correlations in plots (3) and (4) are very weak, and the one in plot (4) is extremely weak.

xyO−4−3−2−11234−3−2−1123
Figure 8.1-5 (1):
xyO−4−3−2−11234−3−2−1123
Figure 8.1-5 (2):
xyO−4−3−2−11234−3−2−1123
Figure 8.1-5 (3):
xyO−4−3−2−11234−3−2−1123
Figure 8.1-5 (4):

To sum up, the correlation of two random variables can be analyzed from paired sample data, and the sample correlation coefficient reflects how strongly the two random variables are linearly correlated: the sign of shows whether the correlation is positive or negative, and the size of shows how strongly the two variables are linearly correlated, that is, how closely the points gather around a straight line.

In a finite population, to know exactly whether two variables are positively or negatively correlated and how strongly they are linearly correlated, we can use all the paired data of the two variables and compute their correlation coefficient by formula (1). For example, to know exactly how strongly body-fat percentage and age are linearly correlated, we would need to survey the age and body-fat percentage of everyone and substitute all the paired data into formula (1). That correlation coefficient would reflect exactly how strongly the variables are correlated.

In practice, though, getting all the paired data of a population is usually not easy. So we again use the idea of estimating the population from a sample: first take a sample to obtain some paired sample data of the two variables, then compute the sample correlation coefficient and use it to estimate the population correlation coefficient, and so learn how strongly the two variables are correlated. For a simple random sample, the sample is random, so the sample correlation coefficient is random too. In general, the larger the sample, the better the sample correlation coefficient estimates the correlation coefficient of the two variables.

Example 1

Using the sample data on body-fat percentage and age in Table 8.1-1, decide whether the two variables are linearly correlated, compute the sample correlation coefficient, and judge how strongly they are correlated.

Solution: First draw the scatter plot, as in Figure 8.1-1. The plot shows that the sample points gather near a straight line, so we infer that body-fat percentage and age are linearly correlated.

By the definition of the sample correlation coefficient,

A calculator gives

Statistical software can also compute the sample correlation coefficient: some spreadsheet programs use the function CORREL, and R uses the function cor.

Substituting into ① gives

From we infer that body-fat percentage and age are positively linearly correlated, and the correlation is very strong.

Related points

All points in this topic

Cite this page: Correlation coefficient · KnowledgeTree (知识树), https://www.knowledgetree.world/en/kp/KP000940