Topics / Chapter 8

The relationship between two measurements

To see whether two traits change together and to predict one from the other.

Two questions, two tools

A plant breeder looks at the link between plant height and yield; an agronomist at the link between nitrogen rate and yield. Two different questions can be asked:

  • Do they change together, and how strongly? This is the question of correlation. Both variables have equal status; nobody asks which affects which.
  • If I know one, how well can I predict the other? This is the question of regression. One variable is independent and controlled (nitrogen rate); the other is dependent and predicted from it (yield).

The correlation coefficient (r)

rr is a number between −1 and +1. Its sign shows the direction of the relationship and its size the strength:

rMeaningExample from the field
Close to +1Strong positive: as one rises, the other rises steadilySpike length and kernels per spike
Around 0No linear relationshipPlot number and yield
Close to −1Strong negative: as one rises, the other falls steadilyWeed density and yield

As a rough rule, ∣r∣<0.3|r| < 0.3 is weak, 0.30.3–0.70.7 moderate and above 0.70.7 strong. But even a large rr calculated from few points can arise by chance, so whether rr is significant is checked separately with a t test.

Correlation is not causation. You may find a strong correlation between the number of tractors in a district and wheat yield. But adding tractors won’t raise yield by itself; both have a common cause (larger, more modern farms). Only a controlled experiment can show cause and effect.

The regression line

Regression finds the line through the points that minimizes the sum of the squared vertical distances to the points (the least squares method):

y^=a+b x\hat{y} = a + b\,x

The most useful number is the slope (bb): it tells you how much Y changes on average when X increases by one unit. In the example below the slope is about 8.45, so each extra kg of nitrogen raises yield by 8.45 kg/da on average.

The coefficient of determination (R2R^2) shows how much of the variation in Y is explained by X. R2=0.94R^2 = 0.94 means 94% of the differences in yield are explained by differences in nitrogen rate, and the remaining 6% come from other factors (soil, measurement error).

Question: Do two measurements change together? Knowing one, how well can the other be predicted?
Example: Yield (kg/da) at different nitrogen rates (kg/da). Is there a relationship between nitrogen and yield, and how much does yield rise as the rate increases?

n = 7, mean 9

n = 7, mean 376

300350400051015(0; 285)(3; 320)(6; 362)(9; 390)(12; 415)(15; 428)(18; 432)Nitrogen rate (kg/da)Yield (kg/da)

Dots are the measurements, the line is the regression line. The green dot is the prediction for your X.

Regression equation

y^=299.93+8.452 x\hat{y} = 299.93 + 8.452\,x

Correlation (r)
0.969
Determination (R²)
93.9%
Prediction for x = 10
384.45

When X increases by one unit, Y increases by 8.452 units on average. 93.9% of the variation in Y is explained by X; the relationship is strong.

  1. Slope (b): how much Y changes on average when X increases by one unit.

    b=SxySxx=2130252=8.4524b = \dfrac{S_{xy}}{S_{xx}} = \dfrac{2130}{252} = 8.4524
  2. Intercept (a): makes the line pass through the mean point (x̄, ȳ).

    a=yˉ−b xˉ=376−8.4524⋅9=299.9286a = \bar{y} - b\,\bar{x} = 376 - 8.4524 \cdot 9 = 299.9286
  3. Regression equation:

    y^=299.929+8.4524 x\hat{y} = 299.929 + 8.4524\,x
  4. Coefficient of determination: the share of the variation in Y explained by X.

    R2=r2=0.9392  (93.9%)R^2 = r^2 = 0.9392 \;(93.9\%)

Is the relationship significant?

H0:ρ=0H_0: \rho = 0H1:ρ≠0H_1: \rho \neq 0
-6-4-20246-2.5712.571calculated 8.78 →t (df = 5)

The red area is the rejection region (α = 0.05). The green line is the value calculated from your data.

H₀ rejected: the difference is significant

There is a strong, positive (as one increases, so does the other) and statistically significant relationship between X and Y.

p-value = 0.0003 (significant at 1%, **)

Correlation is not causation: two variables changing together does not mean one causes the other.

How was it calculated?

tcalct_{calc} = 8.785

  1. Compute the corrected sums of squares and products.

    Sxx=∑x2−(∑x)2n=252S_{xx} = \sum x^2 - \dfrac{(\sum x)^2}{n} = 252
  2. Syy=∑y2−(∑y)2n=19170S_{yy} = \sum y^2 - \dfrac{(\sum y)^2}{n} = 19170
  3. Sxy=∑xy−∑x∑yn=2130S_{xy} = \sum xy - \dfrac{\sum x \sum y}{n} = 2130
  4. Correlation coefficient: the direction and strength of the relationship (between −1 and +1).

    r=SxySxx⋅Syy=2130252⋅19170=0.9691r = \dfrac{S_{xy}}{\sqrt{S_{xx} \cdot S_{yy}}} = \dfrac{2130}{\sqrt{252 \cdot 19170}} = 0.9691
  5. A t test checks whether r differs from zero.

    t=rn−21−r2=0.969151−0.9392=8.785t = \dfrac{r\sqrt{n-2}}{\sqrt{1-r^2}} = \dfrac{0.9691\sqrt{5}}{\sqrt{1-0.9392}} = 8.785
  6. Compare the calculated value with the table (critical) value.

    ∣tcalc∣=8.785>ttab=2.571|t_{calc}| = 8.785 > t_{tab} = 2.571
  7. The calculated value is in the rejection region: H₀ is rejected. The p-value (0.0003) is smaller than α = 0.05.

Don’t trust the line too much

Not every relationship is linear. Look closely at the points in the example: as the nitrogen rate rises, the yield gain slows down and almost stops between 15 and 18 kg. In reality yield reaches a plateau at some point and even falls at excessive rates. The line summarizes this curve roughly but overstates the gain at high rates. Don’t assume a relationship is really linear just because R2R^2 is high; always look at the scatter plot first.

Don’t go outside the range you measured. Predicting yield at 40 kg of nitrogen with a line measured between 0 and 18 kg means extending the line into a region it has never seen. The calculator warns you when you ask for such a prediction.