Statistics

Regression Calculator

The Regression Calculator fits a least-squares straight line to your paired X and Y value lists, then reports the line equation y = mx + b, the R-squared value, and a predicted Y at an X value you choose.

What this calculator does

The Regression Calculator estimates your result instantly from the values you enter, using standard statistics formulas. The Regression Calculator fits a least-squares straight line to your paired X and Y value lists, then reports the line equation y = mx + b, the R-squared value, and a predicted Y at an X value you choose. Calculations run in your browser, so nothing you type is sent to a server, and the output is an estimate rather than a certified or official figure.

Regression Calculator

Result

—
Equation
—
Predicted Y
—
R²

About Regression Calculator

Paste a list of X values and a matching list of Y values, and this tool fits the best straight line through them using ordinary least squares. It returns the slope-intercept equation, the R² goodness-of-fit value, and a prediction for any X you enter.

Both lists must have the same length and at least two points, and the X values need some variation for a line to be defined.

Formula & Mathematical Calculation

Calculation Method

  1. Compute } d=n × sx2-sx × sx
  2. Compute } m=(n × sxy-sx × sy) ÷ d, b=(sy-m × sx) ÷ n
  3. Compute den=Math.sqrt((n × sx2-sx × sx) × (n × sy2-sy × sy)), r=den===0?0:(n × sxy-sx × sy) ÷ den

Calculation Example

With X = 1, 2, 3, 4 and Y = 2, 4, 5, 8, the tool computes n = 4, Σx = 10, Σy = 19, Σxy = 57, Σx² = 30. The slope is m = (4×57 − 10×19) ÷ (4×30 − 10²) = 38 ÷ 20 = 1.9, and the intercept b = (19 − 1.9×10) ÷ 4 = 0.

The equation shown is y = 1.9x + 0. Predicting at X = 5 gives y = 1.9×5 + 0 = 9.5, and R² = 38² ÷ (20×75) = 0.9627.

Key Benefits

  • Fits a least-squares regression line to any paired X and Y data you enter
  • Shows the slope-intercept equation, R-squared, and a point prediction together
  • Lets you forecast Y at a specific X value without a spreadsheet
  • Reports R-squared so you can judge how well the line fits the data

How to Use this Calculator

  1. Enter X values
    Type your independent-variable values into the X values field, separated by commas.
  2. Enter Y values
    Type the matching dependent-variable values into the Y values field, using the same count as X.
  3. Set the prediction point
    Enter the X value at which you want a predicted Y in the Predict Y at X field.
  4. Calculate
    Press Calculate and read the Equation, Predicted Y, and R-squared result boxes.

Assumptions & Limitations

What the calculation assumes

  • Every value you enter is treated as an exact, known amount.
  • Any rate or interval you enter is assumed to hold for the whole period unless the form asks for it separately.
  • Results use standard published formulas and account only for the values entered above.
  • Rounding is applied for display; the underlying calculation uses your full precision.
  • Results are returned in the same units you enter, unless the tool states the output unit.

What it does not cover

  • Regression Calculator produces a calculated result for reference and learning, not a certified or official measurement.
  • Real-world outcomes differ when tolerances, rounding rules or local standards apply.
  • Definitions and standards vary by region and change over time; verify the convention that applies to your case.
  • Figures are only as accurate as the inputs you supply — check them before acting on the result.
  • For work where the result carries real consequences, confirm it against an authoritative source.

Frequently Asked Questions

It uses ordinary least-squares linear regression, computing the slope m and intercept b that minimize the squared vertical distances to the data points.

R-squared is the square of the Pearson correlation between X and Y; it ranges from 0 to 1 and indicates how much of the variation in Y the fitted line accounts for.

You need at least two X-Y pairs, both lists must be the same length, and the X values must not all be identical, otherwise the tool shows an input error.

It substitutes your chosen X into the fitted equation as m times X plus b, using the same slope and intercept shown in the Equation box.

Free to use, no account needed. Calculations run in your browser, so nothing you type is sent to a server. Results are estimates — how we build and check our calculators.