Grades 9-12Free, no account needed
Linear regression calculator
Fit an exact least-squares line to typed point pairs and inspect correlation, r-squared, predictions, residuals and independent normal-equation checks.
Try your problem
Supported inputs and limits
Enter 2-20 x,y pairs separated by semicolons, at most 1100 characters: 0,1;1,2;2,2. Each coordinate is a signed integer, decimal with 1-6 places or integer fraction with positive denominator; at most 24 characters and 12 digits per numerator/denominator part, magnitude at most 1000000 and reduced denominator at most 1000000. No expressions, mixed numbers, repeated decimals or exponents. x must vary. Constant y is allowed but r and centered r-squared are undefined. Exact rational means, slope, intercept, residuals, SSE and r-squared; signed radical r is exact, with 10-significant-digit approximation when irrational. Unweighted OLS with intercept only; no nonlinear fit, significance test or prediction interval. Paste regress(0,1;1,2;2,2), case-sensitive and at most 200 characters. Plot coordinates are approximate and tiny residuals are not enlarged.
Step by step
Understand the method
Ordinary least squares with an intercept chooses y-hat = a + bx to minimize the sum of vertical squared residuals. A residual is observed y minus predicted y; it is not the perpendicular distance to the line.
Center coordinates about their means. Sum centered x squares for Sxx and centered cross-products for Sxy. The slope is Sxy/Sxx, and the intercept is mean y minus slope times mean x. The fitted line passes through the coordinate means.
Pearson r is Sxy divided by the square root of Sxx times Syy. Its sign follows the slope, while r-squared loses the sign. With varying y, r-squared = 1 - SSE/SST. Constant x cannot determine a unique slope; constant y gives a horizontal fit but undefined correlation and centered r-squared. Association alone does not establish causation.
Worked examples
Read the reasoning, or load an example into the calculator.
A fit with nonzero residuals
For (0,1),(1,2),(2,2), Sxx=2 and Sxy=1. Slope=1/2, intercept=7/6, SSE=1/6 and r-squared=3/4. Correlation is sqrt(3/4), approximately 0.8660254038.
Perfect negative association
Points (0,4),(1,2),(2,0) lie on y=4-2x. Residuals vanish, r=-1 and r-squared=1; squaring removes the negative sign.
Constant response
For (0,5),(1,5),(2,5), the exact fit is y=5 with SSE=0. Syy=0, so correlation and centered r-squared are undefined, not 1.
Try it without the calculator
Three questions for practice, not a graded school assessment. Your answers stay on this page and are not saved.
Original Testinar learning content. This local preview is awaiting final review before publication.

