Skip to content
ToolUlkaa Tool
All tools

Statistics

Statistics CalculatorRandom Number GeneratorStandard Deviation CalculatorZ-Score CalculatorProbability CalculatorPermutation and Combination CalculatorP-Value CalculatorT-Test CalculatorConfidence Interval CalculatorSample Size CalculatorChi-Square CalculatorCorrelation Coefficient CalculatorLinear Regression CalculatorANOVA CalculatorProbability Distribution Calculator

Categories

AcademicTextMathematicsStatisticsMachine LearningAIData ScienceFile
All tools
Statistics

Least Squares Regression Line Calculator

Paste x, y data to get the line y = b + mx that minimises the squared errors.

Try:
One pair per line, separated by a comma, tab or space. Two columns copied from Excel work. A text first line is used as the axis names.
Model
Confidence level

Linear regression

y^=0.17143+1.9786x\hat{y}=0.17143 + 1.9786xy^​=0.17143+1.9786x

p < 0.0001 < α = 0.05, so reject H0: the slope is 0. There is evidence that x helps predict y. The line is y = 0.1714 + 1.979x and explains 99.5% of the variation in y (r² = 0.9946).

Slope (m)1.97857
Intercept (b)0.171429
Correlation r0.99729
R squared0.99458
Std. error of slope0.059619
Std. error of estimate0.38638
p for slope4.981e-8 (t = 33.19, df 6)
95% CI, slope1.8327 to 2.1245
95% CI, intercept-0.56524 to 0.9081
Points8

At ad spend = 9, the predicted sales is 17.979. The 95% prediction interval for a single new point is 16.78 to 19.177, and the 95% interval for the mean response is 17.242 to 18.715.

Compare models by R squared

ModelEquationR²Adjusted R²
Lineary^=0.17143+1.9786x\hat{y}=0.17143 + 1.9786xy^​=0.17143+1.9786x0.994580.99368
Polynomial (degree 2) (highest)y^=0.27857+1.9143x+0.0071429x2\hat{y}=0.27857 + 1.9143x + 0.0071429x^{2}y^​=0.27857+1.9143x+0.0071429x20.994630.99249
Exponentialy=2.3542 e0.26307xy=2.3542\,e^{0.26307x}y=2.3542e0.26307x0.892710.87483
Logarithmicy=0.35792+6.5761ln⁡xy=0.35792 + 6.5761\ln xy=0.35792+6.5761lnx0.905980.89031

A higher-degree polynomial always raises R², even when it only follows noise, so look at adjusted R² too. The exponential R² is measured on the original y values.

Residual plot

ad spendsalesFittedResidual
12.42.150.25
23.74.12857-0.42857
36.56.107140.39286
47.68.08571-0.48571
510.410.06430.33571
611.812.0429-0.24286
714.314.02140.27857
815.916-0.1

Least squares, step by step

  1. 1Means and sums
    xˉ=∑xn, yˉ=∑yn, Sxx=∑(x−xˉ)2, Sxy=∑(x−xˉ)(y−yˉ)\bar{x}=\frac{\sum x}{n},\ \bar{y}=\frac{\sum y}{n},\ S_{xx}=\sum(x-\bar{x})^2,\ S_{xy}=\sum(x-\bar{x})(y-\bar{y})xˉ=n∑x​, yˉ​=n∑y​, Sxx​=∑(x−xˉ)2, Sxy​=∑(x−xˉ)(y−yˉ​)
    ↓
    xˉ=4.5, yˉ=9.075, Sxx=42, Sxy=83.1\bar{x}=4.5,\ \bar{y}=9.075,\ S_{xx}=42,\ S_{xy}=83.1xˉ=4.5, yˉ​=9.075, Sxx​=42, Sxy​=83.1
  2. 2Slope
    m=SxySxxm=\frac{S_{xy}}{S_{xx}}m=Sxx​Sxy​​
    ↓
    m=83.142=1.9786m=\frac{83.1}{42}=1.9786m=4283.1​=1.9786
  3. 3Intercept
    b=yˉ−mxˉb=\bar{y}-m\bar{x}b=yˉ​−mxˉ
    ↓
    b=9.075−1.9786⋅4.5=0.17143b=9.075-1.9786\cdot 4.5=0.17143b=9.075−1.9786⋅4.5=0.17143
  4. 4Fit quality
    r2=1−SSresSStot, s=SSresn−2r^2=1-\frac{SS_{res}}{SS_{tot}},\ s=\sqrt{\frac{SS_{res}}{n-2}}r2=1−SStot​SSres​​, s=n−2SSres​​​
    ↓
    r2=0.9946, s=0.3864r^2=0.9946,\ s=0.3864r2=0.9946, s=0.3864

    Slope test: t = 33.19 with 6 degrees of freedom, p = 4.98e-8.

  1. Tools
  2. Statistics
  3. Linear Regression Calculator
  4. Least Squares Regression Line Calculator

About Least Squares Regression Line Calculator

This calculator finds the least squares regression line, the straight line that makes the sum of the squared vertical errors as small as possible. It opens on advertising spend against sales and shows every step. It is free, needs no sign-up and runs in your browser, so nothing you enter is uploaded.

The slope is the cross deviation sum Sxy divided by Sxx, and the intercept makes the line pass through the point of means. The steps panel writes both with your numbers and the equation is typeset in KaTeX.

Below the result you get r, r², the standard error of the estimate, a t test for the slope and a residual plot, so you can judge the fit as well as compute it.

How to use Least Squares Regression Line Calculator

  1. 1Paste two columns from a spreadsheet or type one x, y pair per line. A text first line is used as the axis names.
  2. 2Choose the model: linear, polynomial, exponential or logarithmic. For a polynomial, pick the degree.
  3. 3Read the equation and the statistics table. For the line, the slope p-value tests whether x helps predict y at all.
  4. 4Type an x value in the prediction box to get the predicted y and, for the linear model, its intervals.
  5. 5Check the residual plot. Residuals should scatter randomly around zero. A curve or a funnel means the model is wrong or the spread changes.
  6. 6Open the comparison table to see which model has the highest R², and look at adjusted R² before trusting a high degree.

Features

  • Least squares line with slope, intercept, r, r², standard error of the estimate and of the slope.
  • t test and p-value for the slope, with confidence intervals for slope and intercept.
  • Prediction interval for one new point and confidence interval for the mean response.
  • Polynomial regression of degree 2 to 6, exponential y = a·e^(bx) and logarithmic y = a + b·ln x.
  • Model comparison table with R² and adjusted R².
  • Equation in KaTeX, scatter plot with fitted curve and prediction band, and PNG download.
  • Residual plot and a residuals table with fitted values.
  • Step by step working for the least squares line, copyable as LaTeX.

The regression line

The line has slope m and intercept b, written ŷ = b + mx.

m = Σ(x − mean x)(y − mean y) / Σ(x − mean x)²
b = mean y − m × mean x

Worked examples

  • Ad spend 1 to 8 against sales (8 points) → gives ŷ = 0.1714 + 1.979x

    r² = 0.9946, so the line explains 99.5% of the variation in sales. Each extra unit of spend adds about 1.98 to sales.

Privacy: how it works

  • Everything is calculated by code running in your browser tab. Your data is not sent to Ulkaa or to any other server, and there is nothing to sign in to.

Tips

  • A high R² does not prove a good model. Look at the residual plot as well.
  • Prefer the lowest degree that fits. Adjusted R² drops when an extra term adds nothing.
  • For the exponential model, R² is measured on the original y, so it can be compared fairly with the line.
  • If the points form a curve that rises and levels off, try the logarithmic model.

Frequently asked questions

Is it really free?

Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.

Do I need an account?

No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.

Does it run in my browser?

Yes. Your data are processed by code running in your browser tab, on your own device.

Is my data uploaded?

No. Your data are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.

Why is it called least squares?

Because the line is chosen to make the sum of the squared residuals, the vertical gaps between points and line, as small as possible.

Does the line always pass through the means?

Yes. The least squares line always passes through the point (mean x, mean y).

What is a residual?

A residual is the observed y minus the y the line predicts. The residuals table lists all of them and they always add up to zero.

More Linear Regression Calculator pages

  • Linear Regression CalculatorPaste x, y data to fit a least squares line and compare it with polynomial, exponential and logarithmic models.
  • Line of Best Fit CalculatorPaste your points to see the best fit line on a scatter plot, with its equation and predictions.
  • Polynomial Regression CalculatorPaste x, y data to fit a quadratic, cubic or higher degree curve, up to degree 6.
  • Exponential Regression CalculatorPaste x, y data to fit y = a·e^(bx) and see the growth factor per step.

Ulkaa Apps

  • Ulkaa
  • Calendar
  • Task
  • Note
  • Disk
  • Call
  • Contact
  • Mail
  • Finance
  • Health
  • Office
  • Work
  • Workspace
  • Halum
  • Jaal
  • Islam
  • Game
  • Weather
  • Campus
  • News
  • Developer
  • Help
  • Account
About·Privacy·Terms·© 2026 Ulkaa

What is Ulkaa Tool?

Ulkaa Tool is a free collection of fast, privacy-friendly online tools from Ulkaa Network. Calculate your GPA and CGPA, edit rich text, count words and characters, replace text and more — all in your browser.

Every tool runs entirely in your browser — no sign-up, and your data never leaves your device.

Academic

  • GPA Calculator
  • CGPA Calculator
  • Citation Generator
  • Quiz Maker

Text

  • Rich Text Editor
  • Word Counter
  • Character Counter
  • Text Replacement

Ulkaa

  • Ulkaa
  • Ulkaa News
  • Ulkaa Campus
  • Ulkaa Tool
  • Ulkaa Game
  • Ulkaa Weather
  • Ulkaa Islam

Company

  • About Ulkaa
  • Careers
  • Support
  • Help
  • Privacy Policy
  • Terms of Service
  • Disclaimer
  • Sitemap

© 2015-26, Ulkaa. All rights reserved.
Facebook PageLinkedIn CompanyX (Twitter) ProfileInstagram ProfileGitHub Account
Table of values
sales against ad spend with the linear fit
PointDataLinear fit95% prediction band (upper)95% prediction band (lower)
1(1, 2.4)(0.72, 1.596000000000001)(1, 3.27528178054812)(1, 1.0247182194518827)
2(2, 3.7)(0.8145, 1.782975000000001)(1.175, 3.610180337424728)(1.175, 1.3823196625752747)
3(3, 6.5)(0.909, 1.9699500000000012)(1.35, 3.9455530402644765)(1.35, 1.7394469597355255)
4(4, 7.6)(1.0034999999999998, 2.1569250000000006)(1.525, 4.28141404930251)(1.525, 2.096085950697491)
5(5, 10.4)(1.0979999999999999, 2.3439000000000005)(1.7, 4.6177774201744)(1.7, 2.4522225798256017)
6(6, 11.8)(1.1925, 2.530875000000001)(1.875, 4.954657034000066)(1.875, 2.807842965999936)
7(7, 14.3)(1.287, 2.7178500000000008)(2.05, 5.292066522882447)(2.05, 3.162933477117555)
8(8, 15.9)(1.3815, 2.9048250000000007)(2.225, 5.630019191372704)(2.225, 3.5174808086272984)
9(1.476, 3.091800000000001)(2.4, 5.968527934603644)(2.4, 3.8714720653963575)
10(1.5705, 3.278775000000001)(2.575, 6.307605153943716)(2.575, 4.224894846056286)
11(1.665, 3.4657500000000008)(2.75, 6.647262671169584)(2.75, 4.577737328830417)
12(1.7594999999999998, 3.6527250000000007)(2.925, 6.987511642289798)(2.925, 4.929988357710203)
13(1.8539999999999999, 3.8397000000000006)(3.1, 7.3283624722685055)(3.1, 5.281637527731496)
14(1.9485, 4.026675000000001)(3.275, 7.669824731989818)(3.275, 5.632675268010182)
15(2.043, 4.213650000000001)(3.45, 8.011907078863645)(3.45, 5.9830929211363575)
16(2.1375, 4.400625000000002)(3.625, 8.354617182496856)(3.625, 6.332882817503147)
17(2.232, 4.587600000000001)(3.8, 8.697961656834973)(3.8, 6.682038343165028)
18(2.3265, 4.7745750000000005)(3.975, 9.041946000116235)(3.975, 7.030553999883766)
19(2.421, 4.961550000000001)(4.15, 9.386574543871124)(4.15, 7.3784254561288805)
20(2.5155, 5.148525)(4.325, 9.731850412047631)(4.325, 7.725649587952372)
21(2.61, 5.335500000000001)(4.5, 10.077775491149524)(4.5, 8.072224508850478)
22(2.7045, 5.522475000000001)(4.675, 10.42435041204763)(4.675, 8.418149587952371)
23(2.7989999999999995, 5.7094499999999995)(4.85, 10.771574543871122)(4.85, 8.763425456128878)
24(2.8934999999999995, 5.896425)(5.025, 11.119446000116236)(5.025, 9.108053999883767)
25(2.9879999999999995, 6.0834)(5.2, 11.467961656834973)(5.2, 9.452038343165029)
26(3.0824999999999996, 6.270375)(5.375, 11.817117182496855)(5.375, 9.795382817503146)
27(3.1769999999999996, 6.45735)(5.55, 12.166907078863645)(5.55, 10.138092921136355)
28(3.2714999999999996, 6.644325)(5.725, 12.517324731989818)(5.725, 10.48017526801018)
29(3.3659999999999997, 6.8313)(5.9, 12.868362472268506)(5.9, 10.821637527731495)
30(3.4604999999999997, 7.018275)(6.075, 13.220011642289798)(6.075, 11.162488357710203)
31(3.5549999999999997, 7.20525)(6.25, 13.572262671169582)(6.25, 11.502737328830417)
32(3.6494999999999997, 7.392225)(6.425, 13.925105153943715)(6.425, 11.842394846056283)
33(3.7439999999999998, 7.5792)(6.6, 14.278527934603643)(6.6, 12.181472065396354)
34(3.8385, 7.7661750000000005)(6.775, 14.632519191372705)(6.775, 12.519980808627299)
35(3.933, 7.95315)(6.95, 14.987066522882447)(6.95, 12.857933477117555)
36(4.0275, 8.140125000000001)(7.125, 15.342157034000065)(7.125, 13.195342965999936)
37(4.122, 8.3271)(7.3, 15.6977774201744)(7.3, 13.5322225798256)
38(4.2165, 8.514075)(7.475, 16.05391404930251)(7.475, 13.86858595069749)
39(4.311, 8.70105)(7.65, 16.410553040264478)(7.65, 14.204446959735526)
40(4.4055, 8.888025)(7.825, 16.76768033742473)(7.825, 14.539819662575274)
41(4.5, 9.075000000000001)(8, 17.125281780548118)(8, 14.874718219451882)
42(4.5945, 9.261975000000001)
43(4.689, 9.44895)
44(4.783499999999999, 9.635924999999999)
45(4.877999999999999, 9.822899999999999)
46(4.972499999999999, 10.009875)
47(5.066999999999999, 10.19685)
48(5.161499999999999, 10.383825)
49(5.255999999999999, 10.570799999999998)
50(5.350499999999999, 10.757774999999999)
51(5.444999999999999, 10.944749999999999)
52(5.539499999999999, 11.131725)
53(5.6339999999999995, 11.3187)
54(5.7284999999999995, 11.505675)
55(5.8229999999999995, 11.692649999999999)
56(5.9174999999999995, 11.879624999999999)
57(6.012, 12.0666)
58(6.1065, 12.253575)
59(6.201, 12.44055)
60(6.2955, 12.627525)
61(6.39, 12.814499999999999)
62(6.4845, 13.001475)
63(6.579, 13.18845)
64(6.6735, 13.375425)
65(6.768, 13.5624)
66(6.8625, 13.749375)
67(6.957, 13.93635)
68(7.0515, 14.123325)
69(7.145999999999999, 14.310299999999998)
70(7.2405, 14.497275)
71(7.334999999999999, 14.684249999999999)
72(7.4295, 14.871225)
73(7.523999999999999, 15.058199999999998)
74(7.6185, 15.245175)
75(7.712999999999999, 15.432149999999998)
76(7.8075, 15.619125)
77(7.901999999999999, 15.806099999999999)
78(7.9965, 15.993075000000001)
79(8.091, 16.18005)
80(8.185500000000001, 16.367025000000005)
81(8.28, 16.554000000000002)
Table of values
Residuals against x. Random scatter around zero means the model fits well.
PointResidualsZero
1(1, 0.24999999999999867)(1, 0)
2(2, -0.4285714285714297)(8, 0)
3(3, 0.39285714285714235)
4(4, -0.48571428571428577)
5(5, 0.3357142857142854)
6(6, -0.242857142857142)
7(7, 0.27857142857142847)
8(8, -0.09999999999999964)