In brief
- The simple linear regression equation is ŷ = b0 + b1x, where b0 is the intercept and b1 is the slope.
- Least squares chooses b0 and b1 to minimize the sum of squared residuals: b1 = Sxy / Sxx and b0 = ȳ - b1x̄.
- The slope is the predicted change in y for a one-unit increase in x; the intercept is the predicted y when x = 0.
- R² is the proportion of variance in y explained by the model; adjusted R² penalizes extra predictors.
- Report b, SE, t, p and a 95% CI for each predictor, plus R² and the overall F test.
What is the regression equation? ¶
A regression equation is a formula that predicts the value of an outcome variable (y) from one or more predictor variables (x). For simple linear regression it is ŷ = b0 + b1x, where ŷ is the predicted value, b0 is the intercept (the value of ŷ when x = 0) and b1 is the slope (the change in ŷ for each one-unit increase in x).
Plotted on a scatterplot, this equation is the regression line, also called the line of best fit or the least-squares regression line. Every point on the line is a prediction; the vertical distance from each observed point to the line is a residual.
Population model vs estimated equation
Textbooks write the population model as y = β0 + β1x + ε. The Greek letters are unknown population parameters and ε is random error. From your sample you estimate them as b0 and b1 (sometimes written β̂0 and β̂1). The fitted equation has no error term because it gives predicted values: ŷ = b0 + b1x. Each residual is e = y - ŷ.
Some school textbooks write the same line as y = a + bx or y = mx + c. The meaning is identical: a is the intercept and b (or m) is the slope.
How to find the regression equation with least squares ¶
Keep full precision until the last step. Rounding b1 early is the most common source of wrong intercepts in homework and theses.
Ordinary least squares (OLS) chooses the line that makes the sum of squared residuals, Σ(y - ŷ)^2, as small as possible. Solving that minimization gives two formulas:
- Slope:
b1 = Σ(x - x̄)(y - ȳ) / Σ(x - x̄)^2 = Sxy / Sxx - Intercept:
b0 = ȳ - b1x̄
An equivalent slope formula uses the correlation: b1 = r × (sy / sx), where sy and sx are the standard deviations of y and x. This shows that the slope has the same sign as r, and that the regression line always passes through the point (x̄, ȳ).
Steps to calculate linear regression by hand
- Compute the means x̄ and ȳ.
- For each case, compute the deviations (x - x̄) and (y - ȳ).
- Multiply the deviations and sum them to get Sxy.
- Square the x deviations and sum them to get Sxx.
- Divide: b1 = Sxy / Sxx.
- Compute b0 = ȳ - b1x̄ and write the equation.
Worked example: finding a linear regression equation ¶
A tutor records weekly study hours (x) and exam scores (y) for eight students.
Worked example
| Student | x (hours) | y (score) | x - x̄ | y - ȳ | (x - x̄)(y - ȳ) | (x - x̄)^2 |
|---|---|---|---|---|---|---|
| 1 | 2 | 58 | -5 | -11.5 | 57.5 | 25 |
| 2 | 4 | 62 | -3 | -7.5 | 22.5 | 9 |
| 3 | 5 | 67 | -2 | -2.5 | 5.0 | 4 |
| 4 | 6 | 64 | -1 | -5.5 | 5.5 | 1 |
| 5 | 8 | 72 | 1 | 2.5 | 2.5 | 1 |
| 6 | 9 | 75 | 2 | 5.5 | 11.0 | 4 |
| 7 | 10 | 74 | 3 | 4.5 | 13.5 | 9 |
| 8 | 12 | 84 | 5 | 14.5 | 72.5 | 25 |
| Sum | 56 | 556 | 0 | 0 | 190.0 | 78 |
- Means: x̄ = 56 / 8 = 7.0; ȳ = 556 / 8 = 69.5
- Slope: b1 = 190 / 78 = 2.436
- Intercept: b0 = 69.5 - (2.436 × 7.0) = 52.449
- Regression equation: ŷ = 52.45 + 2.44x
Prediction for a student who studies 10 hours: ŷ = 52.449 + 2.436 × 10 = 76.81. Student 7 actually scored 74, so the residual is 74 - 76.81 = -2.81.
Software gives the same answer. In SPSS, use Analyze > Regression > Linear, put the score in Dependent and hours in Independent(s). The Coefficients table lists 52.449 under (Constant) and 2.436 for hours. If your own output looks different from what you expect, our statistics help service can go through it with you line by line.
Statistics Help & Consulting
Fitting a regression model for your thesis or paper? Check the equation, assumptions and APA reporting with a statistician.
Interpreting the slope and intercept ¶
The slope (b1)
The slope is the expected change in y for a one-unit increase in x. In the example, each additional weekly study hour is associated with an exam score about 2.44 points higher. Keep the units: points per hour. A negative slope means y tends to fall as x rises.
In observational data, describe the slope as an association. Saying that studying one more hour causes a 2.44-point gain needs an experimental design.
The intercept (b0)
The intercept is the predicted y when x = 0. Here, a student who studies zero hours is predicted to score 52.45. The intercept is only meaningful if x = 0 is possible and inside the range of your data. Our data run from 2 to 12 hours, so 52.45 is an extrapolation. When zero is outside the data or impossible (such as height), treat the intercept as a technical anchor for the line, or center x on its mean so the intercept becomes the predicted y at the average x.
Avoid predicting outside the observed range of x. The relationship may not stay linear beyond the data you collected.
R² and adjusted R² ¶
R² (the coefficient of determination) is the proportion of the variance in y that the model explains:
R² = SS_regression / SS_total = 1 - SS_residual / SS_total
In the example, SS_total = Σ(y - ȳ)^2 = 492.00 and SS_residual = 29.18, so R² = 1 - 29.18 / 492.00 = .941. Study hours explain about 94% of the variation in scores in this small sample. In simple regression, R² equals r squared (r = .97).
Adjusted R² corrects for the number of predictors (k) relative to the sample size (n):
Adjusted R² = 1 - (1 - R²)(n - 1) / (n - k - 1)
Here, 1 - (1 - .9407)(7 / 6) = .931. Adding a useless predictor always nudges R² up, but adjusted R² can fall. Use adjusted R² to compare models with different numbers of predictors.
The overall F test asks whether the model explains more variance than chance: F(1, 6) = 95.17, p < .001. The standard error of the estimate (the typical size of a residual) is the square root of 29.18 / 6, which is 2.21 points.
A [simple/multiple] linear regression was conducted to examine whether [predictor(s)] predicted [outcome]. The model was [significant/not significant], F([df1], [df2]) = [F], p = [p], R² = [value], adjusted R² = [value]. [Predictor] [significantly/did not significantly] predict[ed] [outcome], b = [b], SE = [SE], t([df]) = [t], p = [p], 95% CI [[lower], [upper]]. Each one-unit increase in [predictor, with units] was associated with a [b]-unit [increase/decrease] in [outcome, with units][, holding other predictors constant]. The regression equation was ŷ = [b0] + [b1]([predictor 1]) + [b2]([predictor 2]). Assumptions: Residual plots indicated [linearity and constant variance]; residuals were approximately normal; VIF values ranged from [x] to [y]; no case had a Cook's distance above [value].
The multiple regression equation ¶
With two or more predictors, the equation extends to:
ŷ = b0 + b1x1 + b2x2 + ... + bkxk
Each coefficient is a partial slope: the predicted change in y for a one-unit increase in that predictor, holding the other predictors constant.
Illustration
Suppose a larger study estimates ŷ = 40.5 + 2.2(study hours) + 1.5(sleep hours). A student with 6 study hours and 7 sleep hours has a predicted score of 40.5 + 2.2 × 6 + 1.5 × 7 = 40.5 + 13.2 + 10.5 = 64.2. Among students who sleep the same amount, one extra study hour is associated with a 2.2-point higher score.
Raw coefficients depend on units, so you cannot compare them directly. Standardized coefficients (β, reported by SPSS as Beta) express every variable in standard deviations and allow a rough comparison of predictors within one model.
Linear, nonlinear and generalized linear regression
"Linear" means linear in the coefficients, so a model with x squared is still a linear regression. A nonlinear regression has parameters inside a nonlinear function, such as an exponential growth curve. A generalized linear model links a linear equation to outcomes that are not normal, such as logistic regression for binary outcomes and Poisson regression for counts.
Assumptions of linear regression ¶
| Assumption | What it means | How to check |
|---|---|---|
| Linearity | The mean of y changes in a straight line with each x | Scatterplot; residuals vs fitted values show no curve |
| Independence | Residuals are unrelated to each other | Study design; Durbin-Watson for time-ordered data |
| Normality of residuals | Residuals are roughly normally distributed | Histogram or normal P-P/Q-Q plot of residuals |
| Equal variance (homoscedasticity) | Residual spread is constant across fitted values | Residuals vs fitted plot shows no funnel shape |
| No severe multicollinearity (multiple regression) | Predictors are not near-duplicates | VIF above about 5 to 10 is a warning sign |
| No unduly influential cases | No single case drives the line | Cook's distance; standardized residuals beyond ±3 |
Note that normality applies to the residuals, not to x or y themselves. A memory aid is LINE: Linearity, Independence, Normality, Equal variance.
How to report a regression in APA style ¶
APA 7 asks you to italicize statistical symbols (b, SE, t, p, R²), give statistics to two decimals, omit the leading zero for values that cannot exceed 1 (such as R² and p), and report exact p values unless p < .001. Greek letters such as β are not italicized.
APA 7 results paragraph
A simple linear regression was conducted to examine whether weekly study hours predicted exam scores. Study hours significantly predicted exam scores, F(1, 6) = 95.17, p < .001, and explained 94% of the variance, R² = .94, adjusted R² = .93. Each additional hour of study was associated with a 2.44-point increase in exam score, b = 2.44, SE = 0.25, t(6) = 9.76, p < .001, 95% CI [1.82, 3.05]. The regression equation was ŷ = 52.45 + 2.44(hours).
With several predictors, put the coefficients in a table with columns for b, SE, β, t, p and the 95% CI. Our APA table format guide shows the layout. For group comparisons rather than continuous predictors, see one-way vs two-way ANOVA. If you want to learn to run and interpret models yourself, statistics tutoring works through examples at your pace, and SPSS help covers the menus and output.