[Durgical](https://durgical.com/en/) › [DurgiPedia](https://durgical.com/en/durgipedia/) › [Epidemiology](https://durgical.com/en/epidemiology/) › [Biostatistics](https://durgical.com/en/epidemiology/areas/stats/) › Linear regression

# Linear regression

- Statistical test

It fits a straight line that predicts one numerical variable from another. The slope says how much the outcome changes per unit of the other variable.

Updated Nov 5, 2026

## Key points

- y = a + b × x: a is the intercept (y when x = 0); b is the slope (change in y per unit of x).
- b > 0: positive relation; b

## What it is

Simple linear regression describes how a numerical outcome (y) changes on average when an explanatory variable (x) changes, through the line y = a + b × x that minimises the sum of squared errors (least squares). Multiple linear regression adds several explanatory variables at once, so each coefficient estimates the effect of one variable while holding the others constant: a way to control confounding.

## When to use it

- A continuous numerical outcome and one or more explanatory variables.
- Slope b = Σ[(x − mean x)(y − mean y)] / Σ(x − mean x)²; intercept a = mean y − b × mean x.
- For a binary outcome, logistic regression is used; for time to an event, the Cox model.

## Worked example

- Data: the same 5 adults as on the correlation page; exercise (x): 1 to 5 hours; systolic pressure (y): 138, 137, 135, 128, 127 mmHg.
- Sum of the products of deviations = −31; Σ squared deviations of x = 10.
- Slope b = −31 / 10 = −3.1 mmHg per weekly hour of exercise.
- Intercept a = 133 − (−3.1 × 3) = 133 + 9.3 = 142.3 mmHg.
- Line: pressure = 142.3 − 3.1 × hours. For 4 hours: 142.3 − 12.4 = 129.9 mmHg.
- R² = 0.91: the model explains 91% of the variation in these 5 data points.
- Reading: each hour of exercise goes with 3.1 mmHg less on average; a multiple model could adjust for age or weight.

## Markers

- a
- b
- R²
- least squares

## Assumptions and pitfalls

- Reading the slope as a causal effect in an observational study without adjusting for confounding.
- Extrapolating the line beyond the observed range (for example to 20 hours of exercise).
- Not checking the residuals: a curved relation fitted with a straight line gives false conclusions.
- Including too many variables for too few observations (overfitting).

## Memory aid

‘a anchors, b bends’: the intercept sets the starting point and the slope sets the tilt of the line.

## Test yourself

Think of the answer, then tap the question to see it.

## What does the slope represent in a linear regression?

The average change in the outcome for each one-unit increase in the explanatory variable.

## What does multiple linear regression add?

It estimates each variable’s effect while holding the others in the model constant, which helps control confounding.

## What are the assumptions of linear regression?

A linear relation, independent residuals, constant variance of the residuals and a roughly normal distribution of them.

## If the outcome is yes/no (fell ill or not), which regression is used?

Logistic regression, which models the log of the odds of the outcome.

[Add to my cards (4)](https://durgical.app/estudiar/?add=/en/epidemiology/linear-regression/)

## Connections

## Related 4

- [Correlation](https://durgical.com/en/epidemiology/correlation/)
- [Logistic regression](https://durgical.com/en/epidemiology/logistic-regression/)
- [Controlling confounding](https://durgical.com/en/epidemiology/controlling-confounding/)
- [Confounding](https://durgical.com/en/epidemiology/confounding/)

[← All of epidemiology](https://durgical.com/en/epidemiology/)

Educational content on epidemiological and statistical methods; the examples use made-up numbers to teach the calculation. Not a clinical or legal guide: current Colombian rules are in the official sources.

Sources: [Linear Least Squares Regression](https://www.itl.nist.gov/div898/handbook/pmd/section1/pmd141.htm) (NIST/SEMATECH e-Handbook of Statistical Methods, National Institute of Standards and Technology, 2012); [Scatter Plot](https://www.itl.nist.gov/div898/handbook/eda/section3/scatterp.htm) (NIST/SEMATECH e-Handbook of Statistical Methods, National Institute of Standards and Technology, 2012).

## **Spotted a mistake?** We are always improving for the community. Tell us what is wrong and our team will review it. Report a mistake

Representative model, for educational purposes only.

---
Source: https://durgical.com/en/epidemiology/linear-regression/
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite as: DurgiPedia (durgical.com), https://durgical.com/en/epidemiology/linear-regression/
