Regression analysis: a beginner's guide
Regression is the most versatile tool in applied statistics. A t-test, an ANOVA and a correlation can all be written as regression models. Regression goes further: it handles several predictors at once, mixes categorical and continuous predictors, adjusts for confounders, tests interactions, and predicts outcomes for new cases.
What regression does
A regression model describes the outcome (dependent variable, y) as a function of one or more predictors (independent variables, x). The simplest version is a straight line:
y = b₀ + b₁x + error
b₀ is the intercept, the predicted y when x = 0. b₁ is the slope: how much y changes, on average, for each one-unit increase in x. The “error” is the part of y the model doesn’t explain.
Example: for 32 cars in the mtcars dataset, regressing fuel economy on weight gives mpg = 37.29 − 5.34 × weight (in 1,000 lb). Each extra 1,000 lb is associated with 5.34 fewer miles per gallon, and weight explains 75% of the variation in fuel economy (R² = .75). The full walkthrough is in simple linear regression.
Three things regression is used for
- Explaining: which predictors are associated with the outcome, and how strongly?
- Adjusting: is a predictor still associated with the outcome after you account for other variables? This is the main reason to use multiple regression.
- Predicting: what outcome would you expect for a new case with given predictor values?
Choosing the right model for your outcome
The outcome variable’s type decides the model family. The predictors can be any mix of types.
| Outcome | Example | Model | Coefficients mean |
|---|---|---|---|
| Continuous | Exam score, blood pressure | Linear regression (OLS) | Change in the outcome per unit |
| Binary (yes/no) | Passed, recovered, purchased | Logistic regression | Odds ratios |
| Ordered categories | Satisfaction (low/medium/high) | Ordinal logistic regression | Odds of being in a higher category |
| Unordered categories | Chosen transport mode | Multinomial logistic regression | Odds of each category vs a reference |
| Counts | Number of absences, accidents | Poisson or negative binomial regression | Rate ratios |
| Repeated or clustered measurements | Pupils within schools, visits within patients | Mixed-effects model (or clustered standard errors) | As above, accounting for clustering |
Using linear regression on a yes/no outcome, or on counts that are mostly zeros, produces predictions outside the possible range and unreliable p-values. Match the model to the outcome.
Reading regression output
- Coefficients (b): the expected change in the outcome for a one-unit change in the predictor, with the other predictors held constant. Each has a standard error, a t (or z) statistic, a p-value and a confidence interval.
- Standardised coefficients (β): the coefficients in SD units, which helps compare predictors measured on different scales.
- R² and adjusted R² (linear regression): the proportion of variance in the outcome explained by the model. Adjusted R² penalises adding predictors that don’t help.
- The overall F test: whether the model as a whole explains more than nothing.
Assumptions and diagnostics (linear regression)
- Linearity: the relationship between each predictor and the outcome is straight.
- Independent errors: no clustering or time dependence that the model ignores.
- Homoscedasticity: the spread of residuals is constant across fitted values.
- Normal residuals: mainly matters for small samples.
- No severe multicollinearity: predictors not too highly correlated with each other (checked with VIF).
- No dominating influential points (checked with Cook’s distance).
Analytika computes these diagnostics with every linear model and lists any problems as caveats next to the results. It picks the model family from your outcome’s type, and it supports linear, logistic, ordinal, multinomial, Poisson, negative binomial and mixed-effects models, with interactions and clustered standard errors.
Regression and causation
“Controlling for” variables in a regression adjusts only for what you measured. Unmeasured confounders can still produce an association. Coefficients from observational data describe how the outcome differs between cases with different predictor values, not what would happen if you changed a predictor. Phrase results as “associated with”, unless the predictor was randomly assigned.
Where to go next
- Simple linear regression: one predictor, step by step.
- Multiple linear regression: several predictors, dummy variables and multicollinearity.
- Logistic regression: binary outcomes.
More in Regression
Try it with the free tools
Run this on your own data
Upload a dataset and ask your question in plain English. Analytika checks the assumptions, picks the test, runs it, and writes the results up in APA format.