Statistics & probability

Simple linear regression calculator

Fit a straight line to paired data and inspect correlation, residuals and a prediction.

Your numbers

Up to 1,000 finite numbers separated by commas, spaces or semicolons. No missing-value markers. Values must be within ±1 trillion.
Up to 1,000 finite numbers separated by commas, spaces or semicolons. No missing-value markers. Values must be within ±1 trillion.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Try it, understand it

Explore the result

Inspect the fitted line, residuals and prediction scope together.

Worked example comparison
ExampleOutputWhat to notice
A perfect increasing lineLeast-squares slope2Points (1,3), (2,5), (3,7) fit y=2x+1.
A perfect decreasing lineLeast-squares slope-2The fitted slope is negative when y decreases with x.
Extrapolate deliberatelyLeast-squares slope2A prediction at x=5 is outside observations from one to three.

Check your understanding

Can the lists be sorted independently?

No. The observed x/y pairs must remain aligned.

Does a fitted association establish a cause?

No. Regression does not supply a causal experiment.

Behind the numbers

How this calculation works

Fit ordinary unweighted least squares with an intercept, preserving the entered pairing. The result includes fitted values and vertical residuals, Pearson correlation, R² and an input-specific prediction. A prediction outside the observed x range is labeled extrapolation. Enter aligned lists or one x,y pair per line. The normal-equation matrix and right-hand side are shown explicitly with coefficient order [intercept, slope], while the numerical fit uses centered/scaled observations rather than directly inverting that matrix.

THE FORMULAslope = Σ(x−x̄)(y−ȳ)/Σ(x−x̄)²; intercept = ȳ − slope × x̄

A worked example

For x = 1,2,3,4 and y = 2,4,5,4, the slope is 0.7, intercept 2 and prediction at x = 2.5 is 3.75. Residual sum of squares is 2.3.

Good to know

Unweighted descriptive calculations for up to 1,000 observations within ±1 trillion. Floating-point arithmetic and rounded display are used. No missing values are silently removed, no population distribution is inferred, and no confidence intervals are supplied.

Keep each x paired with its measured y

The Spearman rank correlation calculator compares ranks rather than fitting a straight line to raw values. The forecast error calculator compares actual observations with supplied predictions instead of estimating a regression line.

Least-squares regression with an intercept chooses a line that minimizes the sum of squared vertical residuals. Each x must stay paired with its corresponding y. Sorting the lists independently can destroy that relationship even though the two lists still contain the same numbers.

For points (1,3), (2,5) and (3,7), the fitted line is y=2x+1 and all residuals are zero. A nonzero residual is observed y minus fitted y. The table keeps those quantities separate rather than presenting only a line equation without its measurement-level fit.

When both coordinates have measurement error, the Deming regression with entered measurement error ratio calculator uses an entered error-variance ratio instead of assuming a fixed predictor. For an entered analytical standard set, the Absorbance standard curve inverse concentration calculator fits response against concentration and then performs an explicitly flagged inverse estimate.

A fitted relationship does not establish a cause

Pearson correlation and R² summarize particular aspects of this fitted relationship; they do not prove that changing x would cause a change in y. A constant x list cannot determine a unique slope, while a constant y list has an undefined correlation denominator even though a horizontal fitted line can exist.

A requested x outside the observed range is extrapolation and is labelled separately. The Spearman rank correlation calculator assesses monotonic rank association using a different calculation. Neither method removes outliers or supplies a causal experiment merely because a correlation coefficient is available.

A few questions, answered

Must the x and y lists have the same length?

Yes. Every observation needs one matched value in each list.

Why reject a constant x list?

There is no variation in x from which to determine a unique slope.

Does a perfect R² guarantee future predictions?

No. It describes the observed fit under this model, not a guarantee about new data.

Find your calculator

Start typing to explore the library.