Skip to content
Scintria
ToolsGrant writerFunding
HomeLiteratureClinical trialsEvidence LabProtocol packData analysisLearnProjectsLibraryReferencesApplications
Start free
ScintriaStart free

Learn / Biostatistics / Correlation and linear regression

Simple linear regression

15 minute read · 6-question quiz

Download this lesson as a colour Word or PDF study guide with the figures and answers. Included in paid plans; reading and quizzes stay free.Sign in

What you will learn

  • Fit and interpret a straight-line regression: slope, intercept, R² and residual SD

  • Use the model to predict, and avoid extrapolation

  • Check the main assumptions with residual plots

Correlation says how closely two variables move together. Regression goes further: it describes how much an outcome Y changes, on average, per unit change in a predictor X, and lets us predict.

The model

Y = β_0 + β_1 X + ε

  • β_0, the intercept, is the expected Y when X = 0 (often not meaningful on its own).
  • β_1, the slope, is the expected change in Y for a one-unit increase in X.
  • ε is the error: the part of Y the line does not explain, assumed to have mean 0 and constant SD.

The line is chosen by least squares: it minimises the sum of the squared vertical distances (residuals) from the points to the line.

Worked example: age and blood pressure

For the 16 adults of the previous lesson, least squares gives

SBP = 88.2 + 0.955 × age

  • Slope 0.955 (SE 0.056; 95% CI 0.84 to 1.07; t = 17.1, p < 0.0001): on average, each additional year of age is associated with a 0.96 mmHg higher SBP.
  • Intercept 88.2: the fitted SBP at age 0. Not meaningful, as nobody in the study is near age 0.
  • R² = 0.955: the model explains 95.5% of the variation in SBP. (In real population data R² is usually far lower.)
  • Residual SD = 3.1 mmHg: a typical person's SBP lies about 3 mmHg off the line.

Prediction. For a 50-year-old: 88.2 + 0.955 × 50 = 136.0 mmHg. A 95% prediction interval for one individual is wider than the CI for the average of 50-year-olds.

1201401603040506070Age (years)SBP (mmHg)y = 88.24 + 0.96xr = 0.98, R² = 0.95SBP = 88.2 + 0.955 × age
The fitted line passes through the cloud; the slope is the change in SBP per year of age.

Confidence interval vs prediction interval

  • The CI for the mean at a given X describes uncertainty in the average Y for people with that X.
  • The prediction interval describes where a new individual's Y is likely to fall. It is much wider, as it includes the person-to-person scatter.

Assumptions (remember LINE)

  1. Linearity: the relationship is a straight line. Check the scatter plot and residual plot.
  2. Independence: observations are unrelated (violated by repeated measures or families).
  3. Normality of the residuals (matters little with large n; matters for prediction intervals in small samples).
  4. Equal variance (homoscedasticity): the scatter around the line is the same at all X.
Good residual plotCurve in residualsFunnel shapeRandom scatter around 0Even band widthNo patternAssumptions fineU or arch shapeRelationship is notstraightAdd a squared term ortransformSpread grows with fittedvalueUnequal varianceLog-transform Y or userobust SEs
Plot the residuals against the fitted values. Patterns reveal violations.

Never extrapolate beyond the data

The data covers ages 25 to 71. Plugging in age 80 gives 164.6 mmHg, but blood pressure at 80 is not guaranteed to follow the same line (and a survival effect among the very old may flatten it). Predictions are valid only inside the range of observed X. Extrapolating to age 5 using the intercept would give nonsense.

Other practical points

  • Centre X to make the intercept meaningful. If age is centred at 50, the intercept becomes the expected SBP at age 50 (136.0).
  • A binary X (0 = placebo, 1 = treatment) turns regression into the t-test: the slope is the mean difference between groups, with the same p-value as the pooled t-test.
  • Regression to the mean: extreme values tend to be less extreme when measured again. Patients enrolled because of very high BP will show a fall without any treatment. A control group is the cure.
  • Transformations: modelling ln Y turns slope coefficients into percentage changes (after exponentiating, ratios of geometric means).

Report regression results like this

Estimate, 95% CI and p, with units: 'Each additional year of age was associated with a 0.96 mmHg higher SBP (95% CI 0.84 to 1.07; p < 0.001); R² = 0.96.' Do not leave readers with p-values alone.

Summary

  • Regression gives the average change in Y per unit of X (the slope) and lets you predict.

  • Least squares minimises squared residuals; R² is the share of variation explained.

  • Check linearity, independence, normal residuals and constant variance (LINE).

  • Do not extrapolate beyond the observed range of X.

  • A binary predictor in regression reproduces the two-sample t-test.

Check your understanding

Question 1
1

In SBP = 88.2 + 0.955 × age, the number 0.955 is the:

Question 2
2

Predicted SBP at age 60 is about:

Question 3
3

A residual plot with a funnel shape suggests:

Question 4
4

R² = 0.25 means:

Question 5
5

Patients are enrolled because their cholesterol is extremely high; at follow-up, without treatment, it is lower. This is:

Question 6
6

A prediction interval is wider than the CI for the mean response because it:

Draft study guide. Spotted an error or something unclear? Tell us at hello@scintria.com. This is educational material, not clinical or regulatory advice.

Correlation: strength of a straight-line relationshipMultiple regression: adjusting for several variables