Linear Regression Calculator
This linear regression calculator fits a simple least-squares line to paired x and y values. It reports the slope, intercept, Pearson correlation r, r², residual standard error, and a two-sided p-value for the slope, and it draws a scatter plot with the fitted line.
Linear regression calculator
Paste paired x and y values to get the slope, intercept, r, and r², with a scatter plot and the fitted line.
Working
Calculator loading… If the form does not return a result, wait a moment and try again.
Simple linear regression formulas
b₁ = Sxy / Sxx, where Sxy = Σ(x − x̄)(y − ȳ) and Sxx = Σ(x − x̄)².
b₀ = ȳ − b₁ x̄, so the fitted line is ŷ = b₀ + b₁ x.
r = Sxy / √(Sxx Syy), and r² is the fraction of the variation in y explained by the line.
The residual standard error is s = √(SSE / (n−2)), and the standard error of the slope is s / √Sxx. Then t = b₁ / SE(b₁) with df = n − 2.
Worked example
For the points (1, 2.1), (2, 3.9), (3, 6.2), (4, 7.8), (5, 10.1), (6, 11.7), (7, 14.2), (8, 15.8), the fitted line is approximately ŷ = 0.082 + 1.985 x. Pearson r is about 0.999, so r² is about 0.997, and the slope is clearly different from zero.
Related calculators and guides
Frequently asked questions
r² is the proportion of the variation in y that is accounted for by the linear relationship with x. A value of 1 means the points fall exactly on the line; a value near 0 means the line explains little of the variation.
No. This tool fits one explanatory variable. Multiple regression with two or more predictors is a different model.
The t-test for the slope assumes that the residuals are approximately normal with constant variance, that the pairs are independent, and that the relationship is linear. The fitted line itself is still the least-squares line even if those assumptions fail, but the p-value may not be reliable.
Correlation measures the strength of a linear association and does not single out a response variable. Regression also gives an equation for predicting y from x. The Pearson r from this calculator is the same r you would get from the correlation coefficient calculator.
Paste x in one box and y in the other, in the same order, with at least three pairs. Use periods for decimals and separate values with commas, spaces, or new lines.