When to Use Linear Regression
Linear regression predicts a continuous outcome and estimates the slope of the relationship between two variables. Learn when it's the right choice and what to check before you use it.
Key takeaway
Linear regression answers "what happens to y when x changes?" It requires a continuous outcome, roughly linear relationship, independent observations, and roughly normally distributed residuals for inference on the slope.
What regression answers that correlation doesn't
You've learned that a correlation coefficient measures association strength—how tightly two variables stick together. But correlation alone does not tell you how much one variable changes when the other changes, nor does it give you a way to predict values.
Linear regression answers two questions correlation cannot:
- Prediction: If I know x, what do I expect y to be? Regression gives you a fitted line: y = a + b·x, where you can plug in any x to forecast y.
- Slope (rate of change): When x increases by one unit, how much does y increase? The slope b is that answer. You can even test whether the slope is significantly different from zero—meaning x and y truly co-vary, not just happen to be correlated in your sample.
So if you want to know just how close two variables are related (and nothing more), use correlation. If you want to predict, model causality, or estimate how fast one variable responds to another, use linear regression.
Decision checklist
Before you run a linear regression, check all four conditions. If any fail badly, regression gives you meaningless numbers.
Conditions for linear regression
- Outcome is continuous: Your dependent variable (what you are predicting) is measured on a scale—age, income, test score, blood pressure. It is not a category (yes/no, pass/fail, disease present/absent).
- Roughly linear relationship: Plot a scatterplot of x vs. y. The points should cluster roughly around a straight line, not a curve or a cloud with no pattern. If you see a U-shape or an exponential curve, linear regression will not work well.
- Independence of residuals: Each observation is independent. If you have repeated measures on the same person (time-series, longitudinal data), or measurements clustered by school/hospital, you violate this. Regression assumes every y is a fresh draw.
- Homoscedasticity (constant variance): The scatter around the regression line should be roughly even across the range of x. If the residuals fan out (wider scatter at one end of x than the other), or bunch up, this assumption fails.
- Roughly normal residuals: For inference on the slope (confidence intervals, p-values), the residuals—the vertical distances from points to the line—should be roughly bell-shaped. With large samples (n > 30), this is less critical because the Central Limit Theorem rescues you.
How to check: After you fit the regression, plot the fitted values on the x-axis and residuals on the y-axis. You should see a random scatter with no pattern, no trend, and no funnel shape. If you see a pattern (residuals increase with fitted values, or residuals curve), at least one assumption is violated.
When to reach for something else
| Situation | Use instead | Note |
|---|---|---|
| Outcome is categorical (yes/no, disease/healthy, pass/fail) | Logistic regression | Linear regression produces nonsense predictions (e.g., probabilities > 1). Logistic regression models the probability directly. No calculator exists here yet. |
| You have multiple predictors (x₁, x₂, x₃, …) | Multiple regression | Linear regression calculator on this site handles only simple (bivariate) regression. Multiple regression is a natural extension but requires different software. |
| Relationship is curved, not linear (U-shape, exponential, etc.) | Transform variables or use rank-based methods | Try log-transforming x or y, or polynomial regression (add x² as a predictor). Alternatively, use Spearman correlation, which captures monotone (one-direction) relationships without assuming linearity. |
| Residuals are wildly non-normal or heteroscedastic | Robust regression or transformation | Transforming y (e.g., log or square root) often stabilizes variance. Robust regression down-weights outliers. |
| Observations are not independent (repeated measures, hierarchical data) | Mixed-effects model or GEE | Standard linear regression will underestimate uncertainty. Consult a statistician or advanced software. |
Worked example
A researcher collected data from 30 college students: hours spent studying for an exam and the exam score (out of 100). The research question is: "Does study time predict exam performance?"
First, she plotted a scatterplot. The points cluster roughly in a line from lower-left (few hours, low score) to upper-right (many hours, high score). No curve, no fan shape—the scatter is even. She reasoned that each student is independent, they studied different amounts, and the outcome (test score) is continuous. All four conditions are plausible.
She fit a regression and got: Score = 58.2 + 4.1 × Hours. The intercept 58.2 means a student who studies 0 hours is predicted to score 58.2. The slope 4.1 means each additional hour of study is associated with a 4.1-point increase in exam score.
The p-value for the slope was 0.0023, much less than α = 0.05. She can reject the null hypothesis that study time has no effect. Study hours do predict exam score.
A 95% confidence interval for the slope was [1.8, 6.4]. This means: if she could repeat this experiment many times, about 95 out of 100 times, the true slope would fall between 1.8 and 6.4 additional points per study hour.
Frequently asked questions
Linear regression vs. correlation—what's the difference?
Correlation measures the strength of association between two variables: it always ranges from −1 to +1, and a correlation of 0 means no linear relationship. Correlation is symmetric—the correlation of x with y equals the correlation of y with x.
Linear regression models the relationship as y = a + b·x. It is directional: you must choose which variable is the outcome (the one to predict) and which is the predictor. Regression gives you a slope (the rate of change), a prediction line, and the ability to estimate y for any value of x.
What is R² and how does it differ from the correlation coefficient?
The correlation coefficient r ranges from −1 to +1. R² (R-squared, the coefficient of determination) is the square of the correlation. If r = 0.7, then R² = 0.49, meaning the regression explains about 49% of the variance in y.
In simple (two-variable) regression, R² tells you what fraction of the variation in the outcome is accounted for by the predictor. An R² of 0.8 means the model explains 80% of the variation; an R² of 0.2 means only 20%. Higher R² is usually better, but a low R² does not mean the regression is wrong—it just means other variables (not in the model) also matter.
What are the assumptions of linear regression?
There are five core assumptions: (1) the outcome is continuous; (2) the relationship between predictor and outcome is roughly linear; (3) observations are independent; (4) variance is constant (homoscedasticity) across the range of the predictor; (5) residuals are roughly normally distributed. Violations matter most when you want to compute a p-value or confidence interval for the slope. If you only care about prediction and you have lots of data, minor violations may not matter.
What if my relationship isn't linear?
First, check a scatterplot. If the points follow a clear curve (exponential, power-law, U-shape), linear regression will fit poorly and the slope will be misleading. You have three options: (1) transform your variables (e.g., take the log of y or x) and fit a linear regression on the transformed scale; (2) add a polynomial term (e.g., fit y = a + b₁·x + b₂·x²); (3) use a rank-based method like Spearman correlation, which measures monotone association without assuming linearity.
Can I use linear regression with a categorical outcome?
No. Linear regression assumes the outcome is continuous. If your outcome is categorical—for example, disease present/absent, pass/fail, or yes/no—then linear regression produces meaningless predictions (values outside the range [0, 1] for binary outcomes, for instance). You must use logistic regression instead, which models the probability of the outcome belonging to a category. CampusBreeze does not yet offer a logistic regression calculator.
How do I know if my residuals are normally distributed?
After fitting the regression, plot the residuals (the vertical distance from each point to the fitted line) and check a histogram or Q–Q plot. Residuals should be roughly bell-shaped and symmetric around zero. With large samples (n > 30), modest deviations from normality often do not matter much for inference because of the Central Limit Theorem. If residuals are very skewed or multimodal, consider transforming the outcome or checking for outliers.
Sources
- Howell, D. C. (2013). Effect sizes. Accessed August 2026.
- StataCorp. Assumptions of linear regression. Accessed August 2026.
- CrossValidated / Stack Exchange. Statistical advice and peer review. Accessed August 2026.
- Field, A. (2013). Discovering Statistics Using IBM SPSS Statistics (4th ed.). SAGE.
Related tools & pages
Linear Regression Calculator
Paste your data and get the regression equation, slope confidence interval, and p-value.
Open calculator →Correlation Coefficient Calculator
Compute Pearson r and test whether the correlation is significant.
Open calculator →Spearman Correlation Calculator
Rank-based correlation for non-linear or ordinal data.
Open calculator →