Guides  /  regression analysis

Regression analysis: a complete guide

Regression estimates how an outcome changes as a predictor changes, while holding other variables constant — and that last clause is where most of its power and most of its misinterpretation live. This guide works a simple regression through by hand, explains what a coefficient means in a multiple model, and covers the diagnostic checks that decide whether the output can be trusted.

Hafiz Ahmad Tariq Written and reviewed by Hafiz Ahmad Tariq, Senior Biostatistician
Updated 17 August 202620 min read
What is regression analysis?

Regression analysis is a statistical method for modelling the relationship between an outcome variable and one or more predictors. It estimates how much the outcome changes for each unit change in a predictor, and in multiple regression it does so while holding the other predictors constant. The output is a set of coefficients, each with a standard error, significance test and confidence interval.

Definition

What regression does

Regression fits a line, or a plane, through your data so that the total squared distance from the observed points to the line is as small as possible. The result is an equation that predicts the outcome from the predictors.

For one predictor, the model is y = b₀ + b₁x + e. The intercept b₀ is the predicted outcome when the predictor is zero, the slope b₁ is how much the outcome changes per unit of the predictor, and e is the residual — the part of each observation the model does not explain.

intercept b₀ residual = observed − predicted run rise slope b₁ = rise / run The line is chosen to minimise the SUM OF SQUARED residuals — hence “least squares”. Residuals are measured vertically, not perpendicular to the line.
The fitted line minimises the sum of squared vertical distances from the points. Those distances are the residuals.
Why squared, and why vertical

Squaring makes all deviations positive and penalises large misses disproportionately, which is what produces a unique best-fit line. The distances are measured vertically because the model treats the predictor as known and the outcome as the thing being predicted — the asymmetry is deliberate, and it is why regressing y on x gives a different line from regressing x on y.

Choosing

Simple, multiple and the wider family

ModelOutcomePredictors
Simple linearContinuousOne continuous or binary
Multiple linearContinuousTwo or more
LogisticBinaryAny
OrdinalOrdered categoriesAny
Poisson / negative binomialCountsAny
Multilevel / mixedAny, with nestingAny, plus random effects

The family is larger than most courses cover, and choosing the wrong member is a common and consequential error. The decision is driven almost entirely by the nature of the outcome: continuous outcomes take linear regression, binary outcomes take logistic, counts take Poisson or negative binomial, and any outcome measured repeatedly on the same units needs a multilevel or mixed model regardless of its type.

Nesting overrides everything else

If your data are clustered — pupils within schools, patients within wards, repeated measures within people — ordinary regression treats correlated observations as independent, understates the standard errors, and produces p-values that are too small. No amount of adding covariates fixes this; it needs a multilevel model.

Not sure which model your data need?

Send your outcome, predictors and design. A named statistician confirms the model, fits it, checks the diagnostics and returns annotated output.

Get a fixed quote

Worked example

Worked example: simple regression by hand

Six students report weekly study hours (x) and achieve exam scores (y). We want the line predicting score from hours.

Studentxyx−x̄y−ȳ(x−x̄)(y−ȳ)(x−x̄)²
1252−3−12369
2355−2−9184
3461−1−331
46681441
5774210204
6874310309
Sum303840011128

Step 1 — the means

x̄ = 30 / 6 = 5 and ȳ = 384 / 6 = 64

Step 2 — the slope

b₁ = Σ(x−x̄)(y−ȳ) / Σ(x−x̄)² = 111 / 28 = 3.964

Step 3 — the intercept

b₀ = ȳ − b₁x̄ = 64 − (3.964 × 5) = 64 − 19.82 = 44.18

Step 4 — the equation

score = 44.18 + 3.964 × hours

So each additional weekly study hour is associated with about 3.96 more exam marks, and a student studying zero hours is predicted to score 44.18 — a figure that lies outside the observed range of the data and should be treated with caution.

Step 5 — how well does it fit?

Total sum of squares SSₜₒₜ = Σ(y−ȳ)² = 450. Regression sum of squares SSₕₑₔ = b₁ × Σ(x−x̄)(y−ȳ) = 3.964 × 111 = 440.04.

R² = 440.04 / 450 = 0.978 — the model accounts for about 98% of the variance in scores.

An R squared this high is a warning sign, not a triumph

Real educational data almost never behave like this; the numbers here were chosen so the arithmetic stays clean. In practice an R² above about 0.9 in behavioural research usually means a variable has been regressed on a version of itself, or that the sample is too small for the figure to mean much.

Interpretation

Interpreting coefficients

OutputWhat it means
b (unstandardised)Change in the outcome per one-unit change in the predictor, in original units
β (standardised)Change in SDs of the outcome per one SD of the predictor
SEHow precisely the coefficient is estimated
t and pWhether the coefficient differs from zero
95% CIThe range of plausible values for the coefficient

One further quantity is worth knowing about even though it rarely appears in student write-ups: the semi-partial correlation, sometimes called the part correlation. Squared, it gives the proportion of variance in the outcome uniquely attributable to that predictor — the amount R² would fall by if the predictor were removed. It is often more informative than the standardised coefficient for answering “how much does this variable actually add?”, because it is expressed on the same scale as R² and is not distorted by the predictor's own variability. Most software reports it alongside the coefficients; it is simply overlooked.

When to use which

Report the unstandardised coefficient when the units are meaningful — “each additional study hour is worth 3.96 marks” is directly interpretable and is what a reader can act on. Report standardised coefficients when comparing the relative importance of predictors measured on different scales, since the raw coefficients are not comparable across units.

Standardised coefficients are not importance rankings

β depends on the variability of the predictor in your particular sample. A predictor with restricted range in your data will have a small β even if it matters a great deal in the population. Comparing βs across studies with different sampling is not valid.

Note also that a coefficient's significance answers a narrower question than most readers assume. It tests whether that predictor adds anything once the others are in the model. A predictor strongly related to the outcome on its own can appear non-significant simply because another predictor already captures the same information.

Model fit

R squared and how much it really tells you

StatisticWhat it measuresCaution
Proportion of outcome variance explainedAlways rises when predictors are added, even useless ones
Adjusted R²R² penalised for the number of predictorsUse this one for multiple regression
F testWhether the model beats predicting the meanSignificant does not mean useful
Standard error of the estimateTypical size of a prediction errorIn outcome units — often the most practical figure

R² increases mechanically with every predictor added, including random noise, which is why adjusted R² exists and why it should be the one reported whenever there is more than one predictor. If adding a variable raises R² but lowers adjusted R², that variable is not earning its place.

A low R squared is not necessarily a bad model

In fields where outcomes are driven by many unmeasured factors — most of psychology, education and economics — an R² of .15 can represent a genuinely useful finding. What matters is whether the coefficients are precisely estimated and substantively meaningful, not whether the model explains most of the variance.

Multiple predictors

Multiple regression and the meaning of 'controlling for'

In a multiple regression, each coefficient describes the association between that predictor and the outcome with the other predictors held constant. This is the phrase that does most of the work in a discussion section, and it deserves precision.

“Holding constant” is a statistical operation, not an experimental one. The model estimates what the relationship would look like among cases that were identical on the other measured variables. It cannot hold constant anything you did not measure, and it cannot make an observational design causal.

ClaimJustified?
“Study hours predicted scores, controlling for prior attainment”Yes — describes the model
“Study hours affected scores independently of prior attainment”Only if prior attainment is the sole confounder
“Increasing study hours would raise scores by 3.96 marks”No — that is a causal claim from observational data

A related and more subtle problem is that adding a variable can change a coefficient's sign entirely. This is not a bug: it happens when the added variable was suppressing or confounding the original relationship, and the reversed sign may be the more accurate estimate. But it also means a coefficient reported from one model cannot be quoted as though it were a property of the predictor itself. It is a property of that predictor in that model, and changing the covariates changes it. Always state which variables were in the model alongside any coefficient you report.

Multicollinearity

When predictors are strongly correlated with each other, the model struggles to separate their contributions. Coefficients become unstable, swinging in size or even sign when another variable is added, and standard errors inflate. Check the variance inflation factor; values above about 5 warrant attention and above 10 are usually taken as serious.

Collinearity harms interpretation, not prediction

A model with badly collinear predictors can still predict the outcome perfectly well. What it cannot do is tell you which predictor is responsible. If your question is predictive, collinearity may not matter; if it is explanatory, it may invalidate the whole analysis.

Assumptions

Assumptions and diagnostics

AssumptionHow to checkIf violated
LinearityResiduals vs fitted plotTransform, or add a quadratic term
IndependenceStudy design; Durbin-Watson for time seriesMultilevel model or time-series methods
HomoscedasticityResiduals vs fitted — look for a funnelRobust standard errors, or transform the outcome
Normality of residualsQ-Q plot of residualsUsually robust with large n; else bootstrap
No influential outliersCook’s distance, leverageInvestigate; report with and without
No severe multicollinearityVIFDrop or combine predictors
healthy — random scatter funnel — heteroscedastic curve — non-linear Plot residuals against fitted values every time. It diagnoses three assumptions in one chart. A funnel means your standard errors are wrong. A curve means the model is the wrong shape.
One plot of residuals against fitted values diagnoses linearity, homoscedasticity and outliers simultaneously.

The residuals-versus-fitted plot is the single most informative diagnostic and takes seconds to produce. A healthy plot shows a formless band of points around zero. A funnel widening to the right means the variance grows with the prediction, so your standard errors and therefore your p-values are wrong. A curve means the relationship is not linear and the model is systematically wrong at both ends.

Normality applies to the residuals

Not to the outcome variable, and not to the predictors. A skewed outcome can produce perfectly normal residuals once the predictors are accounted for, and testing the raw variable will mislead you into transforming data that did not need it.

Sample size

How many participants do you need?

Rules of thumb are widely quoted and mostly too crude to rely on, but they are useful as a floor.

RuleRequirementComment
N ≥ 50 + 8kFor testing the overall modelk = number of predictors
N ≥ 104 + kFor testing individual predictorsStricter, and usually the relevant one
10–20 cases per predictorGeneral guidanceDepends heavily on effect size

With 4 predictors, the second rule gives a minimum of 108 participants for individual coefficients to be tested with reasonable power. A proper power analysis is better than any of these, because the requirement depends on the size of effect you want to detect, and a small expected effect can demand several times the rule-of-thumb figure.

Overfitting is the risk when N is small

With too few cases per predictor the model fits the noise in your particular sample. R² looks impressive, the coefficients look meaningful, and none of it replicates. If you have 30 cases and 8 predictors, the model is describing your sample, not the population.

Settle the sample size before collecting data

Our power analysis calculator gives the sample needed to detect the effect you care about at your chosen power and significance level.

Use the calculator

Pitfalls

Seven mistakes that cost marks

1. Claiming causation from observational data

Regression describes association. “Predicted” is a statistical term, not a causal one, and readers will take it literally if you are not careful.

2. Interpreting the intercept when zero is impossible

If no participant has a predictor value of zero, the intercept is an extrapolation. Centre the predictors to make it meaningful.

3. Reporting R² rather than adjusted R² in multiple regression

R² rises with every predictor added, including irrelevant ones.

4. Not plotting the residuals

One plot checks three assumptions. Omitting it is the most common reason a violated assumption goes undetected.

5. Ignoring clustering in the data

Pupils within schools or repeated measures within people need a multilevel model. Ordinary regression will give p-values that are too small.

6. Too many predictors for the sample

The model will fit noise and will not replicate. Check the sample size rules before fitting.

7. Extrapolating beyond the observed range

A model fitted on 2 to 8 study hours says nothing reliable about 20 hours.

reporting">

Reporting

Reporting regression in APA style

ElementHow to write it
Overall modelF(2, 107) = 18.44, p < .001, R² = .26, adjusted R² = .24
A predictorb = 3.96, SE = 0.42, β = .48, t(107) = 9.43, p < .001, 95% CI [3.13, 4.79]
Non-significant predictorb = 0.21, SE = 0.38, β = .04, t(107) = 0.55, p = .583
Report the overall model first, then individual predictors
Give b, SE and the confidence interval for every predictor
Use adjusted R² whenever there is more than one predictor
State the assumption checks you performed and their outcome
Present a table when there are more than about three predictors
Avoid causal verbs unless the design supports them
A sentence that earns marks

“The model significantly predicted exam performance, F(2, 107) = 18.44, p < .001, adjusted R² = .24. Weekly study hours was a significant predictor (b = 3.96, 95% CI [3.13, 4.79], β = .48, p < .001), indicating that each additional hour was associated with approximately four additional marks with prior attainment held constant. Residual plots showed no evidence of heteroscedasticity or non-linearity.”

Have your model built, checked and interpreted

Send your dataset and research question. A named statistician fits the model, runs the diagnostics, and returns APA tables with the coefficients interpreted in plain language.

See SPSS data analysis

Answers

Frequently asked questions

What is the difference between correlation and regression?

Correlation measures the strength and direction of association between two variables in a single symmetric number. Regression fits an equation predicting one variable from others, giving a slope in real units, allowing several predictors at once, and letting you hold other variables constant.

What does R squared mean in regression?

The proportion of variance in the outcome explained by the model. An R squared of .26 means the predictors account for 26% of the variation. It rises whenever predictors are added, even useless ones, so adjusted R squared should be reported whenever there is more than one predictor.

What does 'controlling for' actually mean?

That the coefficient describes the association between a predictor and the outcome among cases identical on the other measured variables. It is a statistical adjustment, not an experimental one: it cannot control for variables you did not measure, and it does not make an observational design causal.

How do I know if my regression assumptions are met?

Plot the residuals against the fitted values first — that single chart diagnoses linearity, homoscedasticity and outliers. Add a Q-Q plot of the residuals for normality, VIF for multicollinearity, and Cook's distance for influential cases.

How many participants do I need for regression?

A common rule is N greater than or equal to 104 plus the number of predictors for testing individual coefficients, so roughly 108 for four predictors. These are floors rather than targets; a proper power analysis based on the effect size you expect is considerably more reliable.

What is multicollinearity and does it matter?

It occurs when predictors are strongly correlated with each other, making it hard for the model to separate their contributions. Coefficients become unstable and standard errors inflate. Check VIF, where above 5 warrants attention. It damages interpretation of individual predictors but not overall prediction.

Can regression prove that one variable causes another?

No. Regression estimates association, however many covariates are included. Causal claims require design features such as randomisation or a credible identification strategy. Use wording such as 'was associated with' or 'predicted' rather than 'caused' or 'increased'.

Should I report standardised or unstandardised coefficients?

Unstandardised when the units are meaningful, since they can be interpreted directly. Standardised when comparing the relative contribution of predictors measured on different scales. Standardised coefficients depend on the variability in your sample, so they are not comparable across studies.

Send the data. Get a fixed quote.

Attach your dataset or just describe the project. A named statistician replies with a price and a deadline, usually within one working day.