Linear Regression Calculator
This linear regression calculator fits the line y = m · x + b to your data pairs and reports R², standard errors, a prediction with intervals, residuals and a scatter plot.
Source: NIST/SEMATECH e-Handbook of Statistical Methods – Linear Least Squares Regression. Updated: .
How it is calculated
For the sample data the line is y = 1.012 · x + 1.321 with R² = 0.92. The regression line is the line that minimises the sum of squared vertical distances to all points (ordinary least squares).
How it is calculated
The slope is m = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)² and the intercept b = ȳ − m · x̄. R² is the share of the variation in y explained by x. The standard error of the estimate is s = √(Σ residual² / (n − 2)); from it come the standard errors of slope and intercept, the 95% interval for the slope (t distribution with n − 2 degrees of freedom) and the p-value for whether the slope differs from 0.
Good to know
- A prediction is most precise near the mean of x; far outside the data (extrapolation) it becomes uncertain, which the wider interval shows.
- The interval for the mean describes where the true line lies at x; the prediction interval applies to a single new observation and is wider.
- A high R² does not prove causation: it only measures the linear relationship. Check the scatter plot and residuals for outliers and curvature.
- For the relationship without prediction (Pearson and Spearman correlation), use the correlation calculator.
Frequently asked questions
How do you calculate linear regression?
Slope m = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)² and intercept b = ȳ − m · x̄. The calculator does this for any number of data pairs and lists the key figures in a table.
What does R² tell you in regression?
R², the coefficient of determination, is the share of the variation in y that the line explains. R² = 0.85 means 85% of the spread comes from the linear relationship.
How do you predict with a regression line?
Insert the x value into y = m · x + b. The calculator does this in the “Predict for x” field and also gives the 95% interval for the mean and for a single value.
How many data pairs do you need?
At least three for standard errors and intervals; with two points the line merely passes through both. More pairs make the estimate more reliable.
Sources and legal basis
- NIST/SEMATECH e-Handbook of Statistical Methods – Linear Least Squares Regression
- Wikipedia – Einfache lineare Regression (formulas, standard errors, confidence and prediction intervals)
- Wikipedia – Simple linear regression (confidence and prediction intervals)
As of: · Editorial policy
Related tools
- Correlation Coefficient CalculatorCorrelation coefficient calculator for paired data: Pearson r and Spearman ρ with p-value, confidence interval, R² and regression line. Paste a table.
- Standard deviation calculatorStandard deviation calculator for a list or frequency table: switch between sample (s) and population (σ), see every step in a table, plus a box plot.
- Linear Interpolation CalculatorLinear interpolation calculator: find the y value at an x between two known points, with the line equation, the inverse for x and the steps. Extrapolation too.
- Online chart makerMake a chart online: type your data or paste it from Excel, pick a bar, line or pie chart and save as PNG or SVG. Free, no sign-up, data stays local.
- Confidence Interval CalculatorConfidence interval calculator for a mean (t or z) and a proportion (Wilson): with margin of error, critical value, steps and a 90, 95 or 99 percent level.
- P-Value CalculatorP-value calculator from a z-score, t-score or chi-square, or straight from a t-test with means, SDs and n – plus critical value and confidence interval.
- Online CalculatorCalculator online, free and instant: type or tap and see the answer as you go – order of operations, brackets, percent, square root, steps and a history list.
- Quadratic Regression CalculatorQuadratic regression calculator: the parabola y = ax² + bx + c through your data points, with R², vertex, prediction and residuals and the working shown.
- Point Slope Form CalculatorPoint slope form calculator: get the line equation y − y₁ = m(x − x₁) from two points or from a point and slope, with slope-intercept form and every step.