LAISHA Explains
Statistics and research methods

Correlation and regression

Correlation and regression: scatter diagrams, Pearson's r and its test, rank correlation, fitting a line, r², prediction, cautions and path analysis.

Exam essential5 min read
On this page
  1. The scatter diagram
  2. Karl Pearson's correlation coefficient
  3. Simple linear regression
  4. Beyond two variables
  5. Cautions
  6. Key points
  7. What the exams ask
  8. Questions people ask
  9. Sources
  10. Related on Laisha
  11. Discussion

Does yield rise with nitrogen dose, and by how much per kilogram? Are taller wheat plants also higher yielding? Does grain weight go down as grain number goes up? Questions about how two variables move together are answered by correlation and regression.

Correlation measures the strength and direction of a linear relationship between two variables, with neither treated as cause. Regression describes how one variable changes with another: it fits an equation that can predict Y from X. Both are among the most used tools in agricultural research, from dose–response trials to breeding.

Left: wheat yield plotted against nitrogen dose for six plots, with the fitted regression line Y = 2.25 + 0.0198 X; the correlation coefficient r is 0.994. Right: small scatter patterns showing strong positive, zero and strong negative correlation, and a curved relation where r is near zero even though the variables are clearly related 04080120160 2345 Nitrogen dose X (kg per ha) Yield Y (t per ha) Ŷ = 2.25 + 0.0198 Xr = 0.994; r² = 0.988r ≈ +0.9r ≈ 0r ≈ −0.9curved: r ≈ 0
A fitted regression line for yield against nitrogen dose (left), and scatter patterns for different correlations (right). A curved relation can have r near zero.Diagram: Laisha, original.

The scatter diagram

Always start by plotting Y against X. The scatter diagram shows whether the relation is linear or curved, whether there are outliers, and whether the spread changes with X. Numbers calculated without looking at the plot can be badly misleading.

Karl Pearson's correlation coefficient

Correlation coefficient
r = Sxy ⁄ √(Sxx Syy)
Sxy = Σxy − (Σx)(Σy) ⁄ n; Sxx = Σx2 − (Σx)2 ⁄ n; Syy = Σy2 − (Σy)2 ⁄ n

Its properties:

  • r lies between −1 and +1. +1 is a perfect positive linear relation, −1 a perfect negative one, and 0 means no linear relation.
  • r has no units, and it is unchanged by changes of origin or scale, such as converting kg to t.
  • r measures only linear association. A strong curved relation can give r ≈ 0.

Testing r

To test whether the population correlation is zero:

Significance of r
t = r √(n − 2) ⁄ √(1 − r2), with df = n − 2

Rank correlation

When data are ranks, such as judges scoring taste or farmers ranking varieties, or when the relation is monotonic but not linear, Spearman's rank correlation is used:

Spearman's rank correlation
ρ = 1 − 6Σd2 ⁄ [n(n2 − 1)], where d = difference in ranks

Simple linear regression

The regression of Y on X fits the line Ŷ = a + bX by least squares: it minimises the sum of squared vertical distances of the points from the line.

Regression of Y on X
b = Sxy ⁄ Sxx (regression coefficient, or slope)
a = ȳ − b x̄ (intercept)

The slope b is the change in Y per unit change in X, in the units of Y per unit of X. Unlike r, it depends on units and on which variable is treated as dependent.

There are two regression lines: Y on X (byx) and X on Y (bxy). They cross at (x̄, ȳ), and:

  • r2 = byx × bxy, so r is the geometric mean of the two regression coefficients;
  • r, byx and bxy always have the same sign.

Coefficient of determination

r2 is the proportion of the variation in Y explained by the regression on X. An r2 of 0.80 means 80% of the variation is accounted for, and 20% remains unexplained.

Worked example

Wheat yield and nitrogen dose

Six plots received 0, 30, 60, 90, 120 and 150 kg N per ha, and yielded 2.1, 2.9, 3.5, 4.2, 4.6 and 5.1 t per ha.

  • Σx = 450, Σy = 22.4, Σxy = 1,992, Σx2 = 49,500 and Σy2 = 89.88.
  • Sxy = 1,992 − 450 × 22.4 ⁄ 6 = 312; Sxx = 49,500 − 4502 ⁄ 6 = 15,750; Syy = 89.88 − 22.42 ⁄ 6 = 6.253.
  • r = 312 ⁄ √(15,750 × 6.253) = 0.994, so r2 = 0.988.
  • t = 0.994 × √4 ⁄ √(1 − 0.988) ≈ 18.4. The table value at df 4 (5%) is 2.776, so r is highly significant.
  • b = 312 ⁄ 15,750 = 0.0198 t per kg N, about 20 kg of grain per kg of N. a = 3.733 − 0.0198 × 75 = 2.25.
  • The predicted yield at 100 kg N is 2.25 + 0.0198 × 100 = 4.23 t per ha.

Over a wider range of doses, yields level off. A quadratic, Y = a + bX + cX2, then fits better and gives the economic optimum dose.

Testing and using the regression

  • The significance of b is tested with t = b ⁄ SE(b), where SE(b) = √(s2 ⁄ Sxx) and s2 is the residual mean square. In simple regression, this test gives the same result as testing r.
  • Prediction within the range of X is reasonably safe. Extrapolation beyond it is risky, because the relation may change shape.
  • Residual plots check whether a straight line is appropriate and whether the variance is constant.

Beyond two variables

  • Multiple regression (Y = a + b1X1 + b2X2 + …) predicts yield from several factors, such as rainfall, temperature and fertiliser. It is the basis of many crop-weather forecasting models.
  • Partial correlation measures the association between two variables while holding others constant.
  • Path analysis, introduced by Sewall Wright and applied to crops by Dewey and Lu (1959), splits the correlations of component traits with yield into direct and indirect effects. Breeders use it to decide which yield components to select for.

Cautions

  • Correlation is not causation. Two variables may both depend on a third. Yield and rainfall may both rise with irrigation availability across districts.
  • Spurious correlation can arise from ratios sharing a common term, from mixing groups, or from trends over time.
  • Outliers can create or hide a correlation. A single extreme point can change r dramatically.
  • A non-significant r does not prove there is no relation; it may be curved.
  • Restricted range reduces r. Correlations within a narrow set of elite varieties are often weaker than across all germplasm.

Key points

  • Correlation measures the strength of linear association; regression gives an equation to predict Y from X.
  • r = Sxy ⁄ √(Sxx Syy). It lies between −1 and +1, has no units, and is tested with t = r√(n − 2) ⁄ √(1 − r2) at df n − 2.
  • Spearman's ρ = 1 − 6Σd2 ⁄ [n(n2 − 1)] is used for ranks.
  • b = Sxy ⁄ Sxx and a = ȳ − b x̄; r2 = byx bxy and is the share of variation explained.
  • Multiple regression, partial correlation and path analysis extend the methods to many variables.
  • Correlation does not imply causation; avoid extrapolation and check for outliers.

What the exams ask

  • Calculate r and the regression equation from data, and test r.
  • State the properties of the correlation and regression coefficients.
  • Distinguish correlation and regression.
  • Calculate Spearman's rank correlation.
  • Explain path analysis and the meaning of r2.

Described in general terms: the kind of examination, not a past paper. Laisha never reproduces exam questions.

Questions people ask

What is a "good" r?

It depends on the field. In controlled dose–response trials, r above 0.9 is common. In farm surveys or breeding populations, r of 0.3 to 0.5 can be meaningful and significant with enough data. Always consider r2, the sample size and the practical size of the effect.

Why does r change if I add plots from another site?

Combining sites adds between-site differences. If one site has both higher X and higher Y, the pooled correlation can become strong even if there is none within either site. The reverse can also happen. Analyse within groups, or include site in a multiple regression.

Can regression prove that fertiliser increases yield?

A designed experiment with randomised doses supports a causal interpretation, because randomisation removes confounding. Regression on survey data, where farmers chose their own doses, shows only association: farmers who use more fertiliser may also have better land and management.

Sources

  1. Snedecor, G. W. and Cochran, W. G. Statistical Methods, 8th edition. Iowa State University Press, 1989.
  2. Gomez, K. A. and Gomez, A. A. Statistical Procedures for Agricultural Research, 2nd edition. Wiley, 1984.
  3. Dewey, D. R. and Lu, K. H. "A correlation and path-coefficient analysis of components of crested wheatgrass seed production." Agronomy Journal 51, 515–518 (1959).
  4. Draper, N. R. and Smith, H. Applied Regression Analysis, 3rd edition. Wiley, 1998.

More in statistics and research methods

Discussion

Questions, corrections and notes from readers on this article. Every comment is checked before it appears: keep it on the topic, and do not share phone numbers, links or contact details.

Last reviewed

Ask Laisha about this

Opens Laisha's chat with your question ready to send. Sign in or start free.