In-depth learning guide

Simple Linear Regression and Prediction Guide

Simple linear regression estimates y = a + bx from paired data. The fitted equation can produce a point prediction, but predictions outside the observed X range should be identified as extrapolation.

3 min readStep-by-step methodReviewed 19 Oct 2026Published by LynaraOpen Simple Linear Regression & Prediction Calculator →

Method

  1. Enter paired X and Y values.
  2. Calculate slope and intercept from the observed pairs.
  3. Inspect r and r² as association and fit summaries.
  4. Optionally enter an X value, substitute it into the fitted line and check whether that X is inside the observed range.

Worked example

X = 1, 2, 3 and Y = 2, 4, 6 produces y = 2x.

Entering X = 4 predicts Y = 8, but 4 is beyond the observed X range and is therefore extrapolation.

Notes

Open Simple Linear Regression & Prediction Calculator

Reproduce a small least-squares regression by hand

Take four illustrative paired measurements, X = [1, 2, 3, 4] and Y = [2, 4, 3, 5]. The means are X̄ = 2.5 and Ȳ = 3.5. The sum of products of centered deviations is 4 and the sum of squared X deviations is 5. With an intercept in the model, the ordinary least-squares slope is 4 ÷ 5 = 0.80, and the intercept is 3.5 − (0.80 × 2.5) = 1.50. The fitted equation is predicted Y = 1.50 + 0.80 × X.

The fitted values for the four observed X values are 2.30, 3.10, 3.90 and 4.70. Their errors, actual minus fitted, are −0.30, 0.90, −0.90 and 0.30. Squaring and summing produces residual sum of squares 1.80. The total sum of squares around the observed Y mean is 5.00, so the sample R-squared is 1 − (1.80 ÷ 5.00) = 0.64. This is consistent with the paired-data Pearson correlation of 0.80, whose square is also 0.64 in a simple linear regression with an intercept.

A hypothetical prediction at X = 5 would be 5.50, but this lies beyond the observed X range of 1 to 4. It is extrapolation, not an observed result or a reliable forecast. Four observations also cannot establish that a linear model is suitable for a wider population; examine a scatterplot, residuals, unusual observations and the domain process before drawing conclusions.

Interpret the line in the units of the variables

A simple least-squares regression estimates an intercept and slope for predicting Y from X. The slope describes the expected change in predicted Y for a one-unit increase in X under the fitted linear model. The intercept is the predicted Y when X equals zero, which may or may not be meaningful in the observed range.

R-squared describes the fraction of variation in Y accounted for by the fitted linear relationship in this dataset. It does not measure causation or guarantee accurate individual predictions.

Check residual patterns and avoid careless extrapolation

A straight-line fit can be misleading when residuals show curvature, changing spread or influential points. Inspect the data and residual behavior rather than relying only on the fitted equation.

Predictions far outside the observed X range are extrapolations. The linear relationship may not continue there, so label those predictions as more uncertain instead of presenting them with the same confidence as interpolation.

Editorial review and limitations

Review status: reviewed under Lynara's editorial policy on 19 Oct 2026. Institution-specific grading rules, assignment instructions and publisher requirements can override a general example.
Verification: see the methodology and sources & verification pages. To report a reproducible error, use the contact page with the page URL, inputs and expected result.

Continue with the related tools

Use the linked tools for your own inputs and scenarios.

Browse all statistics calculators →

Keep learning

Related guides