Linear Regression and Prediction Calculator — Free Online | EverydayCalcSkip to main content
everydaycalc.

Find calculators and file viewers

Press Esc to close · / or Ctrl+K to open

Home›Math & Scientific›Linear Regression and Prediction Calculator
Math & Scientific

Linear Regression and Prediction Calculator

Fit an ordinary least-squares line to paired data and predict Y for a chosen X, showing slope, intercept, r and R².

✦ INSTANT CALCULATION

Linear Regression and Prediction Calculator

YOUR RESULT
—

ⓘ Calculated locally in your browser. Results depend on the values and units you enter.

Explore the calculation visually

The chart follows the current valid inputs and the original calculation engine. It is an illustration, not a separate estimate.

What changes if one input changes?

5: 4.6 · 6: 5.4 · 7: 6.2

How this calculator works

Ordinary least squares with an intercept minimizes the sum of squared vertical residuals. Slope = Sxy/Sxx and intercept = meanY − slope×meanX. Enter 3–1000 pairs in matching order; provide a target X for the point prediction. Pearson r and R² describe the linear fit, not causal effects or confidence intervals. X must vary; if Y is constant, the fitted line is horizontal and correlation and R² are undefined. Extrapolating outside observed X may be unreliable; predictions do not include uncertainty intervals.

Formula and reasoning

ŷ(x₀) = ȳ + [Σ(xᵢ−x̄)(yᵢ−ȳ) / Σ(xᵢ−x̄)²] × (x₀−x̄)

  1. 1. Start with the measurements
    Observed X values1, 2, 3, 4, 5Observed Y values2, 1, 4, 3, 5Predict Y when X is6
  2. 2. Substitute into the formula

    Observed X values = 1, 2, 3, 4, 5 ? Observed Y values = 2, 1, 4, 3, 5 ? Predict Y when X is = 6

  3. 3. Check the computed answer

    Result for the sample inputs5.4

Worked example

X = 1,2,3,4,5 and Y = 2,1,4,3,5 fit Y = 0.8X + 0.6, predicting Y = 5.4 at X = 6.

Frequently asked questions

What is R²?

R² is the proportion of sample Y variation explained by the fitted straight line with an intercept.

Is the predicted value guaranteed?

No. It is a model point estimate that does not incorporate prediction uncertainty.

Results are informational and assume the stated inputs and formulas. Double-check critical financial or engineering decisions with a qualified professional.

Add this calculator to your website

Share a working calculator on your blog or website. Choose a fixed size or let the height fit the content.

Fixed height

Works on websites that accept iframe HTML.

Responsive height

Automatically adjusts the height. Your website must allow scripts.

Open calculator preview ↗

Powered by EverydayCalc