Linear Regression Calculator
Linear regression finds the straight line that best fits your data: the line that minimizes the squared distance to every point. That line gives you the trend (slope), the baseline (intercept), the strength of the relationship (correlation), and a way to predict new values.
Enter paired X and Y values below. The calculator returns the regression equation, the correlation coefficient, R-squared with a plain-English reading, and predictions for any X you enter.
Linear Regression Calculator
Reading the scatter plot and residuals
The chart above the results plots your data as red dots with the fitted regression line in blue. The dashed amber segments are the residuals: the vertical miss between each actual y and the line’s prediction at that x. The table lists every residual numerically.
- RMSE (root mean square error) is the typical size of those misses in y units. Smaller means a tighter fit.
- Residuals that fan out or curve (instead of scattering randomly around zero) warn that a straight line may be the wrong model, even when R-squared looks high.
- Least-squares fitting guarantees the residuals sum to zero, which you can verify in the table.
Worked example (verified against the tool)
Study hours X = 1, 2, 3, 4, 5 and test scores Y = 52, 60, 68, 73, 82. The tool returns y = 7.3000x + 45.1000, r = 0.9971, R-squared = 0.9942, RMSE = 0.7874. Predicting x = 6 gives y = 88.9000. The first residual is 52 – 52.4 = -0.4: the line over-predicts the first point by four tenths of a point.
