How this calculator works
Ordinary least squares minimises squared vertical residuals. The fitted line passes through the means of x and y. Correlation and R squared measure linear association when both variables vary; they are omitted for constant y. The residual table preserves input order and helps identify mismatched data or large deviations. This engine supplies numeric summaries, not a scatter chart; use a plotting tool to inspect curvature and outliers before trusting a linear model.
Formula
m = sum((x-xMean)(y-yMean))/sum((x-xMean)^2); b = yMean - m xMean; r = Sxy/sqrt(Sxx Syy); SSE = sum((y - fitted y)^2).
Worked example
For (1, 2), (2, 4) and (3, 5), m = 1.5 and b = 2/3. The residuals are -1/6, 1/3 and -1/6, giving SSE = 1/6 and R squared = 27/28.
Advertisement
Frequently asked questions
Can I fit a vertical line?
No. Ordinary y-on-x regression requires variation in x and minimises vertical errors, not perpendicular distances.
Does high correlation prove causation?
No. Association can arise from confounding or coincidence. The fit alone does not establish a causal relationship.
Are repeated observations allowed?
Yes. Repeated pairs receive additional weight because each is treated as an observation.
Should I extrapolate?
A prediction outside the observed x range assumes the same linear relationship continues. That assumption may fail.