How do I calculate linear regression by hand?
Make a table with x, y, xy and x² for each point and add the columns. The slope is m = (nΣxy minus ΣxΣy) / (nΣx² minus (Σx)²) and the intercept is b = (Σy minus mΣx) / n. For x = 1 to 5 and y = 2, 4, 5, 4, 5 that gives m = 30/50 = 0.6 and b = 11/5 = 2.2, so y = 0.6x + 2.2. This page prints the same table and fills in both formulas so you can check each line.
What is the least squares regression line?
The straight line that makes the sum of the squared residuals as small as possible, where a residual is a point's actual y minus the y the line predicts. It is unique whenever the x values are not all equal. For the five points above no other line gets the sum of squares below 2.4.
What do the slope and the intercept mean?
The slope is how much y changes, on average, for each increase of 1 in x, in y units per x unit. The intercept is the predicted y when x is 0. The intercept only means something if x = 0 is inside or near the data; a regression of weight on height has an intercept at height 0 that describes no real person.
Is the line of best fit the same as the regression line?
Yes. In statistics the line of best fit is the least squares regression line, which is what this calculator computes. A line of best fit drawn by eye on paper is an estimate of it, and it should pass through the point of means, as the calculated line always does.
What is a good r squared for a regression line?
It depends on the field. r² is the share of the variation in y that the line accounts for, so 0.9 means 90%. Measurements from a controlled physics experiment often reach 0.99; data about people often stops at 0.3 to 0.5 and is still useful. A high r² does not prove a straight line is the right shape, so check the residuals too.
How many points do I need for linear regression?
Two points define a line, so the calculator accepts two, but a line through two points always fits perfectly and says nothing about the data. With three or more points the residuals, r and r² begin to carry information, and more points make the slope more reliable.
Can I use the regression line to predict?
Inside the range of your x values, yes: that is interpolation, and it is as good as the fit. Outside the range it is extrapolation, and nothing in the data says the trend continues. The test-score example on this page predicts about 103 points for 12 hours of study, on a test out of 100.
Why are the answers fractions instead of decimals?
Because the slope and intercept of a least squares line on rational data are rational numbers, and the fraction is the exact value. 162/35 is the slope; 4.6286 is a rounding of it, and every prediction made from the rounding carries the error. The Copy button gives decimals when you need them.