Calculators King

Regression and Correlation

Line of Best Fit Calculator

Typed pairs are fitted as y equals a plus b times x, residual SSE is reported, and a new x is converted into a predicted y on that line.

Worksheet

Press Calculate to see the result.

Typed pairs are fitted as y equals a plus b times x, residual SSE is reported, and a new x is converted into a predicted y on that line.

What this calculator answers

The least-squares line is the straight line that makes the squared vertical gaps as small as they can be. The intercept a is the line's height at x equal to zero, and the slope b is the change in predicted y for a one-unit step in x. Adding the squared gaps gives the residual sum of squares, SSE. This page then takes one new x and reads the line at that x. It does not test the slope and it does not print a p-value. Prediction here is arithmetic on the fitted line.

The page reports the least-squares intercept and slope, the residual SSE, and the predicted y at the x you supply. Supporting counts and intermediate terms sit under the headline so a reader can see what was divided by what. When a checkbox or a tail setting changes the divisor or the rejection region, that choice appears in the steps rather than vanishing into a silent default.

The formula, written out

Simple least-squares line uses this relationship.

y = a + b x, with b = sum of paired products / sum of squared x deviations

  • a. Intercept, the predicted y at x = 0.
  • b. Slope, the change in predicted y per unit x.
  • SSE. Sum of squared residuals from the line.
  • y hat. The predicted y at the new x.

The slope is the covariance-style numerator divided by the sum of squared x deviations. The intercept makes the line pass through the point of means. SSE adds the squared vertical misses. The algebra is the named textbook identity for this worksheet. Intermediate products and quotients appear in order so a calculator and a pencil can agree to the displayed rounding. If a neighbouring page uses a different divisor or a continuity correction, that page says so on its own ticket.

A full worked example

Example loaded in the worksheet

The form is prefilled with a small example so every arithmetic step can be checked by hand. Change one field after you finish the walkthrough and confirm the ticket moves the way the formula predicts.

There are 6 pairs. The mean of x is 3.5 and the mean of y is 5. The least-squares slope is 1.0857 and the intercept is 1.2. The fitted line is y = 1.2 + 1.0857x.

Residual SSE, the sum of squared vertical gaps, is 3.3714. At the new x of 7, predicted y = 1.2 + (1.0857)(7) = 8.8. The typed x values run from 1 to 6.

The new x is outside that range, so this prediction is an extrapolation. No p-value is computed on this page. The slope is a fitted number, not a tested claim.

Figures from the worked example
Fitted liney = 1.2 + 1.0857x
Predicted y8.8
Residual SSE3.3714
Slope1.0857
Intercept1.2

A second situation

Predict at x = 0 instead of x = 7

There are 6 pairs. The mean of x is 3.5 and the mean of y is 5. The least-squares slope is 1.0857 and the intercept is 1.2. The fitted line is y = 1.2 + 1.0857x.

Residual SSE, the sum of squared vertical gaps, is 3.3714. At the new x of 0, predicted y = 1.2 + (1.0857)(0) = 1.2. The typed x values run from 1 to 6.

The new x is outside that range, so this prediction is an extrapolation. No p-value is computed on this page. The slope is a fitted number, not a tested claim.

Figures from the worked example
Fitted liney = 1.2 + 1.0857x
Predicted y1.2
Residual SSE3.3714
Slope1.0857
Intercept1.2

Moving the new x from 7 to 0 changes only the prediction. The fitted line itself stays the same because the pairs did not change. The second example changes the feature that this formula is sensitive to, and the ticket shows the new figure beside the same definition. That contrast is the fastest way to see which input owns the movement.

What moves when the input moves

The prediction x moved from 7 to 10, farther outside the typed x values. The headline result went from y = 1.2 + 1.0857x to y = 1.2 + 1.0857x.

The nudged inputs

There are 6 pairs. The mean of x is 3.5 and the mean of y is 5. The least-squares slope is 1.0857 and the intercept is 1.2. The fitted line is y = 1.2 + 1.0857x.

Residual SSE, the sum of squared vertical gaps, is 3.3714. At the new x of 10, predicted y = 1.2 + (1.0857)(10) = 12.0571. The typed x values run from 1 to 6.

The new x is outside that range, so this prediction is an extrapolation. No p-value is computed on this page. The slope is a fitted number, not a tested claim.

Figures from the worked example
Fitted liney = 1.2 + 1.0857x
Predicted y12.0571
Residual SSE3.3714
Slope1.0857
Intercept1.2

How to read the result

Read the prediction as the line's value, not as a guaranteed future observation. If the new x sits outside the typed range, you are extrapolating. Say the unit, the sample size or contract terms, and the formula name in the same sentence as the figure. A number without those three pieces invites a later reader to invent a definition that this page never used.

Write the result with its unit, the inputs that produced it, and the name of the formula. Write the result with its unit, the inputs that produced it, and the name of the formula. If the ticket shows a decision sentence, quote the alpha and the tail with it. If the ticket shows a money or dose figure, quote the rate and the schedule that produced it.

Assumptions that have to stay true

  • A straight line is the shape you intend to fit.
  • The x column varies, so a unique slope exists.
  • The new x is on the same scale as the typed x values.
  • You want the fit and a prediction, not a hypothesis test.

If an assumption above is false, do not average the discomfort away. Change the worksheet or change the question. A correct arithmetic step on the wrong model is still the wrong answer for the decision you are trying to make.

Mistakes that change the answer

  • Quoting a p-value from this page. The inference page is the linear regression calculator.
  • Using the slope when a one-unit change in x is not a meaningful step.
  • Treating a prediction far outside the data as if it had been checked.
  • Swapping x and y and expecting the same line. The fit minimises vertical errors.

Where a different calculator is the honest choice

Use the linear regression calculator for the standard error, t, p-value, and a confidence interval for the slope. Use the correlation coefficient calculator when r is the headline. Use the quadratic regression calculator when a curve in x squared is the shape you need. Related links under the essay open pages that keep their own formulas instead of hiding a mode switch inside this ticket.

When the job changes, move to a page built for that job: Linear Regression Calculator, Correlation Coefficient Calculator, Quadratic Regression Calculator.

Check yourself

The fitted line is y = 1 + 2x. What is the prediction at x = 4?

The predicted y is 1 plus 2 times 4, which is 9.

Using the result in a sentence

A calibration line, a trend through a short series, and a classroom scatterplot are the usual reasons to read a prediction off a fitted line. Keep the count, the unit, and the assumption list beside any copy of the number that leaves this browser tab.

Least squares is sensitive to a point with a huge residual. The line is not a causal effect of x on y, and SSE equal to zero only means the typed points sit on the line. Pair the headline with the steps before you staff a route, set a grade boundary, or compare two contracts from a single number.

Questions people ask next

01What definition does the Line of Best Fit Calculator commit to?

This page uses Simple least-squares line: y = a + b x, with b = sum of paired products / sum of squared x deviations. The slope is the covariance-style numerator divided by the sum of squared x deviations. The intercept makes the line pass through the point of means. SSE adds the squared vertical misses. If a textbook uses a different divisor, a different continuity correction, or a different rounding rule, the last digits can move, so the definition is printed above the result. The worksheet asks for Pairs, one x y per line, New x to predict, and it refuses a blank that the formula cannot interpret. Keep that printed definition in the sentence you write next to the figure so a later reader can rebuild the arithmetic without guessing which convention you chose.

02How should the worked example be read out loud?

In the loaded example the fitted line is y = 1.2 + 1.0857x. Read the prediction as the line's value, not as a guaranteed future observation. If the new x sits outside the typed range, you are extrapolating. Say the unit and the count before you say whether the number is large or small. Read the steps in order rather than jumping to the headline, because the intermediate terms are where a swapped percent and proportion usually hide. If the ticket shows both a primary figure and a comparison figure, name which one you are quoting.

03What is the fastest way to get a misleading result?

Quoting a p-value from this page. The inference page is the linear regression calculator. Least squares is sensitive to a point with a huge residual. The line is not a causal effect of x on y, and SSE equal to zero only means the typed points sit on the line. A second common failure is leaving a checkbox or tail setting in the wrong state and then treating the number as if the default had matched your plan. Reset the example, change one input, and confirm the ticket moves in the direction the formula predicts before you trust a live run.

04When should I leave this page for a different calculator?

Use the linear regression calculator for the standard error, t, p-value, and a confidence interval for the slope. Use the correlation coefficient calculator when r is the headline. Use the quadratic regression calculator when a curve in x squared is the shape you need. The related links under the essay go to those worksheets, which keep their own formulas instead of hiding them in a mode switch. If the question changed from a summary to a test, from a payment to a refinance, or from a raw score to a percentile, switch pages rather than forcing this ticket to answer a job it was not built for.

05What belongs in the sentence next to the number?

The predicted y is 1 plus 2 times 4, which is 9. Name the formula, the sample size or the inputs, and the unit before you compare the figure with someone else's. A bare number without those three pieces cannot be audited when a score, a rate, or a lab value is challenged later. Store the inputs beside the result whenever the figure will travel into a report.