From Paired Data to a Correlation
Pearson’s correlation summarizes the direction and strength of a linear pattern between two quantitative variables. A scatterplot shows that pattern visually; calculating \(r\) gives a single numerical summary. The calculation uses both variables together: each \(x\)-value must stay paired with the \(y\)-value recorded for the same individual.
The key idea is to express each observation as a number of sample standard deviations above or below its variable’s mean. These standardized values are called z-scores. Multiply the two z-scores for each individual, then combine those paired products using the sample adjustment described below. If an individual is above the mean on both variables, the product is positive; if one value is above its mean and the other is below, the product is negative.
This formula assumes that the data consist of correctly matched pairs and that both variables are quantitative and vary across the observations. It calculates a descriptive statistic for the data at hand; it does not require a probability model or a normality assumption. The value of \(r\) has no units, even if the original measurements have units, because each value is standardized by its own standard deviation.
Worked Calculation
In the first example, each row represents one hypothetical participant. The measurements might be minutes of activity (\(x\)) and a score (\(y\)). First calculate the means and sample standard deviations. Then standardize and multiply within rows. Keeping the rows intact is essential: multiplying values from different individuals would not calculate their correlation.
Worked Example: Four Paired Measurements
Suppose four hypothetical participants have the following paired measurements. Calculate Pearson’s \(r\).
| Participant | \(x\) | \(y\) |
|---|---|---|
| A | 115 | 52.5 |
| B | 85 | 47.5 |
| C | 105 | 49.5 |
| D | 95 | 50.5 |
1. Find the means. The \(x\)-values sum to \(400\), and the \(y\)-values sum to \(200\), so
2. Find the sample standard deviations. The deviations from the means are \(15,-15,5,-5\) for \(x\), and \(2.5,-2.5,-0.5,0.5\) for \(y\). Therefore,
Both standard deviations are positive, so standardization is possible.
3. Standardize each value and multiply within each pair. For participant C, for example, \(z_{x,C}=5/\sqrt{500/3}\approx0.3873\) and \(z_{y,C}=-0.5/\sqrt{13/3}\approx-0.2402\). The product is negative because C’s \(x\)-value is above its mean while the \(y\)-value is below its mean. The table shows the corresponding calculations for all four participants.
| Participant | \(x_i-\bar{x}\) | \(z_{x,i}\) | \(y_i-\bar{y}\) | \(z_{y,i}\) | \(z_{x,i}z_{y,i}\) |
|---|---|---|---|---|---|
| A | 15 | 1.1619 | 2.5 | 1.2010 | 1.3954 |
| B | -15 | -1.1619 | -2.5 | -1.2010 | 1.3954 |
| C | 5 | 0.3873 | -0.5 | -0.2402 | -0.0930 |
| D | -5 | -0.3873 | 0.5 | 0.2402 | -0.0930 |
The z-scores are rounded for display. In particular, \(-0.5/\sqrt{13/3}\approx-0.240192\), which rounds to \(-0.2402\); the corresponding positive value rounds to \(0.2402\). Use unrounded values for the final calculation:
Thus, these four hypothetical participants have a strong positive linear association between the recorded \(x\)- and \(y\)-measurements. The coefficient is dimensionless; it does not mean that one variable increases by a particular number of units when the other increases.
Why Divide by \(n-1\)?
The standard deviation in each z-score is the sample standard deviation, which uses \(n-1\) in its denominator. As a result, the sum of the paired z-score products must also be divided by \(n-1\) to obtain Pearson’s sample correlation. The following derivation makes the adjustment explicit.
A common informal description calls correlation an “average product of z-scores.” With sample standard deviations, the precise calculation is the sum of the \(n\) products divided by \(n-1\), not their ordinary arithmetic mean (which would divide by \(n\)). Equivalently, \(r\) is \(n/(n-1)\) times that ordinary mean. Applying the stated formula avoids a small but systematic error.
Two More Arithmetic Checks
Worked Example: A Perfect Negative Linear Pattern
Consider three hypothetical paired measurements \(x=(2,4,6)\) and \(y=(6,4,2)\). Each variable has mean \(4\), and both sample standard deviations are
The paired z-scores are \((-1,0,1)\) for \(x\) and \((1,0,-1)\) for \(y\). Their paired products are \(-1,0,-1\), so
The calculation matches the data: as \(x\) increases, \(y\) decreases in an exactly straight-line pattern. Both variables vary, so the correlation is defined.
Worked Example: A Positive but Imperfect Pattern
For four hypothetical paired measurements \(x=(2,4,5,7)\) and \(y=(4,3,6,5)\), both means are \(4.5\). The deviations are \((-2.5,-0.5,0.5,2.5)\) for \(x\) and \((-0.5,-1.5,1.5,0.5)\) for \(y\). The standard deviations are
The products of the paired deviations are \(1.25, 0.75, 0.75,\) and \(1.25\), with sum \(4\). Since \(z_{x,i}z_{y,i}\) equals the paired deviation product divided by \(s_xs_y\), their sum is
Thus,
The positive value indicates a positive linear association in these data, but the value is below \(1\), so the pairs do not lie exactly on an increasing straight line.
Common Mistakes and Practical Checks
The most frequent computational error is dividing the sum of products by \(n\) after using sample standard deviations. That produces the ordinary average of the products, not Pearson’s sample correlation. In the first example, that incorrect step would give approximately \(2.6047/4=0.6512\), rather than the correct \(2.6047/3=0.8682\).
A second mistake is to standardize the two columns correctly but then pair their z-scores in a different order. Each product must come from the same observational unit. A third is to round each z-score too early: small rounding errors accumulate, especially with a small dataset. Keep extra digits during the calculation and round the reported correlation at the end.
Before reporting a result, check that each row is a genuine pair, both variables have variation, and the sample-size adjustment is \(n-1\). Also compare the sign of the result with the scatterplot: a positive \(r\) should reflect an overall upward linear pattern, and a negative \(r\) an overall downward linear pattern. A numerical calculation does not replace looking at the plotted data.
Confirm that each \(x_i\) and \(y_i\) belong to the same individual or observational unit.
Use all \(n\) observations for each mean and divide the sum of squared deviations by \(n-1\) when finding each sample variance.
Find \(z_{x,i}\) and \(z_{y,i}\), then calculate \(z_{x,i}z_{y,i}\) for every pair.
Add the paired products and divide by \(n-1\). Keep unrounded values until the final result.
Check Your Understanding
Try these questions before moving on.
- For five paired observations, what divisor is used when the sum of the paired z-score products is converted to Pearson’s \(r\)?
- Suppose one observation has an \(x\)-value above \(\bar{x}\) and a \(y\)-value below \(\bar{y}\). What is the sign of its paired z-score product?
- Why should the \(x\)- and \(y\)-values from different individuals never be mixed when making the products?
- A calculation gives a sum of paired z-score products of \(1.8\) for \(n=4\). Find \(r\).
- What happens to the calculation of \(r\) if all the observed \(x\)-values are identical? Explain.