UNIHIVE

Study Hub UNIPORT MTH 264

MTH 264 · Statistics for Biological and Agricultural Sciences

Simple regression and correlation

Scatter plots, r, fitting a line by least squares, testing the slope, and caution about cause.

Our notes

2 min read

Regression or correlation?

  • Correlation: how strongly two variables move together.
  • Regression: a line to predict y from x, as when yield depends on the fertiliser rate.

Useful sums

Sxx = Σx² − (Σx)²/n

Syy = Σy² − (Σy)²/n

Sxy = Σxy − (Σx)(Σy)/n

Correlation coefficient

r = Sxy ÷ √(Sxx × Syy), with −1 ≤ r ≤ 1.

  • Close to +1: strong positive straight-line pattern
  • Close to −1: strong negative
  • Close to 0: no straight-line pattern (a curved one may still exist)

Regression line

y = a + bx, where b = Sxy/Sxx and a = ȳ − bx̄.

Worked example

Nitrogen rate x (bags/ha) and maize yield y (t/ha):

x12345
y23546

n = 5; Σx = 15; Σy = 20; Σx² = 55; Σy² = 90; Σxy = 2 + 6 + 15 + 16 + 30 = 69.

  • Sxx = 55 − 45 = 10
  • Syy = 90 − 80 = 10
  • Sxy = 69 − 60 = 9
  • r = 9/√100 = 0.90
  • b = 9/10 = 0.9
  • a = 4 − 0.9(3) = 1.3

Line: y = 1.3 + 0.9x. Each extra bag adds 0.9 t/ha, in this range.

Check: the line must pass through (x̄, ȳ) = (3, 4): 1.3 + 2.7 = 4. Correct.

Coefficient of determination

r² = 0.81: 81% of the variation in yield goes with x in this data set.

Testing the slope

Residual SS = Syy − b Sxy = 10 − 8.1 = 1.9.

s² = 1.9/(n − 2) = 1.9/3 = 0.633.

SE(b) = √(s²/Sxx) = √0.0633 = 0.252.

t = 0.9/0.252 = 3.58. The critical value with df 3 is 3.182, so the slope is significant at 5%.

Check using r: t = r√(n − 2)/√(1 − r²) = 0.9 × 1.732/0.436 = 3.58. Correct.

Predicting

At x = 3.5: y = 1.3 + 3.15 = 4.45 t/ha.

Interpolation (within the data) is safer than extrapolation. At x = 20 the line gives 19.3 t/ha, which is absurd: yield flattens out, then falls. Biological responses often level off, so don't trust a straight line outside the range.

Residuals

Residual = observed − predicted. Plot them. A pattern shows the straight line doesn't fit.

Curves made straight

Some relationships become lines after a transformation.

  • Growth: ln y on x
  • Dose-response: often using log dose
  • Length-weight in fish: W = aLᵇ becomes log W = log a + b log L

Correlation is not causation

Lurking variables can explain a pattern. Rainfall could raise both weed cover and crop yield, so weeds and yield would be correlated without weeds helping yield. To show cause, run a designed, randomised experiment.

Spearman's rank correlation

For ranks or data that aren't normal: r_s = 1 − 6Σd²/[n(n² − 1)], where d is the difference in ranks.

Exams usually ask: compute r and the regression line; predict y; test the slope; interpret r²; explain why correlation doesn't prove cause.

Common mistake: swapping x and y. The regression of y on x is not the same line as x on y, unless r = ±1.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All MTH 264 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.