Copperplate
Statistics guide

The Regression Equation: Linear Regression Formula, Example and Interpretation

The linear regression equation ŷ = b0 + b1x describes the straight line that best predicts an outcome from a predictor. This guide shows how to find it by least squares, interpret it and report it.

Statistics8 min readUpdated Copperplate editorial team

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

  1. Compute the means x̄ and ȳ.
  2. For each case, compute the deviations (x - x̄) and (y - ȳ).
  3. Multiply the deviations and sum them to get Sxy.
  4. Square the x deviations and sum them to get Sxx.
  5. Divide: b1 = Sxy / Sxx.
  6. 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

Studentx (hours)y (score)x - x̄y - ȳ(x - x̄)(y - ȳ)(x - x̄)^2
1258-5-11.557.525
2462-3-7.522.59
3567-2-2.55.04
4664-1-5.55.51
587212.52.51
697525.511.04
7107434.513.59
81284514.572.525
Sum5655600190.078
  • 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.

See how it works

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.

Copy-ready APA results template
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

AssumptionWhat it meansHow to check
LinearityThe mean of y changes in a straight line with each xScatterplot; residuals vs fitted values show no curve
IndependenceResiduals are unrelated to each otherStudy design; Durbin-Watson for time-ordered data
Normality of residualsResiduals are roughly normally distributedHistogram or normal P-P/Q-Q plot of residuals
Equal variance (homoscedasticity)Residual spread is constant across fitted valuesResiduals vs fitted plot shows no funnel shape
No severe multicollinearity (multiple regression)Predictors are not near-duplicatesVIF above about 5 to 10 is a warning sign
No unduly influential casesNo single case drives the lineCook'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.

Sources and further reading

  1. NIST/SEMATECH e-Handbook of Statistical Methods: 4.1.4.1 Linear Least Squares Regression
  2. Penn State STAT 501: Least squares regression (Lesson 1.2)
  3. UCLA OARC: Regression Analysis, SPSS Annotated Output
  4. APA Style numbers and statistics guide (7th ed.)
FAQ

Frequently asked questions

What is a regression line?

A regression line is the straight line drawn through a scatterplot using the regression equation ŷ = b0 + b1x. It is the line of best fit under least squares, meaning it minimizes the sum of squared vertical distances between the observed points and the line. It always passes through the point of means (x̄, ȳ).

What is the difference between correlation and regression?

Correlation (r) measures the strength and direction of a linear relationship between two variables and treats them symmetrically. Regression produces an equation that predicts one variable from another, with a slope in the outcome's units. They are linked: in simple regression, b1 = r × (sy / sx) and R² = r².

How do you find the linear regression equation from a table of data?

Compute the means of x and y, then the slope b1 = Σ(x - x̄)(y - ȳ) / Σ(x - x̄)^2, then the intercept b0 = ȳ - b1x̄. Write the result as ŷ = b0 + b1x. Check your answer by confirming that the line passes through (x̄, ȳ), or run the data through SPSS, Excel or R.

What is a good R² value?

There is no universal threshold. In controlled physical science experiments, R² above .90 is common. In psychology, education and social science, R² values of .10 to .30 can be meaningful because human behavior has many causes. Judge R² against previous studies in your field and focus on the size and precision of the coefficients.

What is the difference between linear and nonlinear regression?

Linear regression is linear in its coefficients, even if it includes transformed predictors such as x squared or log x. Nonlinear regression has parameters inside a nonlinear function, such as y = a × e^(bx), and is fitted by iterative methods that need starting values.

Contact us

Want an expert to
read it with you?

If you are working on this right now, an editor can review your draft and explain every change. Start with a quote for statistics help & consulting.

Need a full quote with your file? Use the quote form
WhatsApp