Calculators
Linear Regression Calculator
Fit a least-squares regression line to paired data locally in your browser. Get the slope, intercept, equation, Pearson r, R-squared, standard error of estimate, and an optional Y prediction.
Enter two paired datasets with the same number of values in the same order, separated by commas, spaces, or new lines. The calculator fits the least-squares line y = a + bx and reports the slope, intercept, equation, Pearson r, R-squared, and standard error of estimate. Optionally enter an X value to predict Y; predictions far outside the input range are extrapolations. The calculation runs locally in your browser; your values are not uploaded or stored.
Find the best-fit line through paired X and Y data.
Enter paired X and Y values with the same count in the same order. The calculator fits the ordinary least-squares line y = a + bx, where the slope is b = Σ((x − x̄)(y − ȳ)) ÷ Σ(x − x̄)² and the intercept is a = ȳ − b × x̄. For X 1, 2, 3, 4, 5 and Y 2, 4, 5, 4, 6 the line is y = 0.8x + 1.8 with r = 0.912, R-squared ≈ 0.832, and a standard error of estimate of about 0.566. An optional X value reports the fitted prediction; values far outside the input range are extrapolations. The standard error needs at least three pairs, and identical X values make the slope undefined, while identical Y values leave r undefined for a horizontal line. R-squared is the share of Y variance the line explains, not proof of causation, and the fit assumes a linear relationship with residuals that do not drift. All calculations run locally in your browser; your values are not uploaded or stored.
Frequently Asked Questions
Everything you need to know about this tool, how it works, and privacy.
What is linear regression?
Simple linear regression fits a straight line y = a + bx through paired X and Y data so the squared distance between the line and the observed points is as small as possible. The slope is b = Σ((x − x̄)(y − ȳ)) ÷ Σ(x − x̄)² and the intercept is a = ȳ − b × x̄.
What do the slope and intercept mean?
The slope b is the average change in Y for each additional unit of X: a slope of 2 means Y rises by about 2 when X rises by 1. The intercept a is the fitted Y value when X is 0, which may be outside the observed data and can be meaningless on its own.
What is R-squared?
R-squared is the share of the variance in Y that the fitted line explains, ranging from 0 to 1. It equals the square of Pearson r for a single predictor. A high value means the points sit close to the line; it does not prove the relationship is causal or that the fit is the right model.
What is the standard error of estimate?
The standard error of estimate is the typical distance of the observed Y values from the fitted line: SE = √(Σ(y − ŷ)² ÷ (n − 2)). It needs at least three pairs because two points define a line exactly and leave no residual degrees of freedom.
Can the calculator predict new Y values?
Yes. Enter an optional X value to get the fitted prediction from the line. Predictions far outside the range of your input X values are extrapolations, and the calculator does not report a prediction interval or confidence band.
What are the input limits?
Enter the same number of X and Y values, at least two and up to 10000, separated by commas, spaces, or new lines; values must be finite numbers from -1e9 to 1e9. Identical X values make the slope undefined, identical Y values leave r and R-squared undefined, and mismatched or non-numeric entries show a clear error.
Are my data values uploaded?
No. All calculations run locally in your browser. CodeASystem does not upload or store your input values.