Skip to content

Linear Regression Calculator

Fit a least-squares line to paired observations with residuals, correlation, parameter standard errors and labelled prediction uncertainty.

One x | y pair per row, 2–2,000 rows. Unweighted observations; an intercept is fitted.

Leave blank to omit predictions. Extrapolation is labelled.

Preparing calculator controls…

Results

Enter your inputs and calculate to see the result.

Runs in your browser — nothing you enter is sent to a server.

How the Linear Regression Calculator works

Fit an unweighted straight line with an intercept using centered, compensated sums. Inspect every fitted value and residual, R² and Pearson correlation. For an optional x, report predicted y, standard error of the mean response s√(1/n+(x−x̄)²/Sxx), and standard error of a new observation s√(1+1/n+(x−x̄)²/Sxx).

Fit a least-squares line to paired observations with residuals, correlation, parameter standard errors and labelled prediction uncertainty.

Formula

b = Σ(x−x̄)(y−ȳ)/Σ(x−x̄)²; a = ȳ−bx̄; ŷ = a+bx. s² = Σ(y−ŷ)²/(n−2). SE(b)=s/√Sxx; SE(a)=s√(1/n+x̄²/Sxx).

Inputs must be finite numbers within ±1 billion; nonzero observations smaller than 1e-100 must be rescaled. x must vary. Two pairs define a line but cannot estimate residual uncertainty. Constant y makes correlation and R² undefined. Standard errors assume independent, constant-variance errors and a suitable straight-line model; they are not confidence intervals. No causal claim, weighted fit, missing-value imputation or automatic outlier deletion. Predictions outside the observed x range are labelled extrapolation. Display uses six decimals; very small nonzero results use scientific notation.

Examples

A non-perfect fit

Pairs (1,2), (2,3), (3,5) give slope 1.5, intercept 0.333333, R² 0.964286 and residual standard error 0.408248. At x=4, predicted y is 6.333333 and the tool labels extrapolation.

Two observations

(1,2) and (2,4) give slope 2 and intercept 0. The line is defined, but residual degrees of freedom are zero, so parameter and prediction standard errors are undefined.

Frequently asked questions

What does this calculation assume?

Fit an unweighted straight line with an intercept using centered, compensated sums. Inspect every fitted value and residual, R² and Pearson correlation. For an optional x, report predicted y, standard error of the mean response s√(1/n+(x−x̄)²/Sxx), and standard error of a new observation s√(1+1/n+(x−x̄)²/Sxx).

Which limitations matter for this tool?

Inputs must be finite numbers within ±1 billion; nonzero observations smaller than 1e-100 must be rescaled. x must vary. Two pairs define a line but cannot estimate residual uncertainty. Constant y makes correlation and R² undefined. Standard errors assume independent, constant-variance errors and a suitable straight-line model; they are not confidence intervals. No causal claim, weighted fit, missing-value imputation or automatic outlier deletion. Predictions outside the observed x range are labelled extrapolation. Display uses six decimals; very small nonzero results use scientific notation.

How can I check the result?

Pairs (1,2), (2,3), (3,5) give slope 1.5, intercept 0.333333, R² 0.964286 and residual standard error 0.408248. At x=4, predicted y is 6.333333 and the tool labels extrapolation. Compare this worked case before using your own inputs.

Information:

Good to know

Inputs must be finite numbers within ±1 billion; nonzero observations smaller than 1e-100 must be rescaled. x must vary. Two pairs define a line but cannot estimate residual uncertainty. Constant y makes correlation and R² undefined. Standard errors assume independent, constant-variance errors and a suitable straight-line model; they are not confidence intervals. No causal claim, weighted fit, missing-value imputation or automatic outlier deletion. Predictions outside the observed x range are labelled extrapolation. Display uses six decimals; very small nonzero results use scientific notation.

Prediction standard errors: Penn State STAT 501, estimation and prediction. Reference: NIST: least-squares estimates and residual standard deviation. The implementation scope and conventions above are authoritative for this worksheet.

Quartiles and Box Plot Calculator

Compare quartile conventions, calculate IQR and outlier fences, and draw a responsive box plot with observed-value whiskers and numeric results.

Calculators