Calculators King

Regression and Correlation

Linear Regression Calculator

The fitted slope is reported with its standard error, t statistic, degrees of freedom, two-sided p-value, and a ninety-five percent confidence interval.

Worksheet

Press Calculate to see the result.

The fitted slope is reported with its standard error, t statistic, degrees of freedom, two-sided p-value, and a ninety-five percent confidence interval.

What this calculator answers

The line of best fit tells you the slope. A regression test asks whether that slope is distinguishable from zero once residual noise is taken into account. The standard error of the slope uses the residual variance and the spread of x. Dividing the slope by that standard error produces a t statistic with n minus 2 degrees of freedom. A 95 percent interval adds and subtracts a critical t times the standard error. This is the inference page. An optional new x can still be read off the line, but the headline is the test of the slope.

The page reports the least-squares line, the slope standard error, t, degrees of freedom, a two-sided p-value, and a 95 percent confidence interval for the slope. 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

t inference for a simple regression slope uses this relationship.

t = b / se(b), df = n - 2, interval = b plus or minus t-critical times se(b)

  • b. The least-squares slope.
  • se(b). The standard error of the slope.
  • df. Degrees of freedom, n minus 2.
  • t-critical. The two-sided 0.05 critical value of t.

Under the usual normal-error model, (b minus the true slope) divided by se(b) follows a t distribution with n minus 2 degrees of freedom. The interval is that statement rearranged around the estimated slope. 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, so the residual degrees of freedom are 4. The fitted line is y = 1.2 + 1.0857x. Residual SSE is 3.3714 and the slope standard error is 0.2195.

t = 1.0857 / 0.2195 = 4.9472. The two-sided p-value is 0.0078. The two-sided 5 percent critical t on 4 degrees of freedom is 2.7764.

The 95 percent interval is 1.0857 plus or minus 2.7764 times 0.2195, from 0.4764 to 1.695. That interval excludes 0. At the optional x of 7, the line predicts 8.8. This is not a prediction interval.

Figures from the worked example
Slope1.0857
95% CI for slope0.4764 to 1.695
Standard error0.2195
t4.9472
Two-sided p-value0.0078
Degrees of freedom4
Fitted liney = 1.2 + 1.0857x
Predicted y8.8

A second situation

The same pairs with the prediction left blank

There are 6 pairs, so the residual degrees of freedom are 4. The fitted line is y = 1.2 + 1.0857x. Residual SSE is 3.3714 and the slope standard error is 0.2195.

t = 1.0857 / 0.2195 = 4.9472. The two-sided p-value is 0.0078. The two-sided 5 percent critical t on 4 degrees of freedom is 2.7764.

The 95 percent interval is 1.0857 plus or minus 2.7764 times 0.2195, from 0.4764 to 1.695. That interval excludes 0. No prediction x was entered, so the page stops at the slope inference.

Figures from the worked example
Slope1.0857
95% CI for slope0.4764 to 1.695
Standard error0.2195
t4.9472
Two-sided p-value0.0078
Degrees of freedom4
Fitted liney = 1.2 + 1.0857x

Changing two of the y values refits both the slope and its standard error. The interval can move even when the pair count stays the same. 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 second y changed from 4 to 3 and the fifth y changed from 7 to 6. The headline result went from 1.0857 to 1.0857.

The nudged inputs

There are 6 pairs, so the residual degrees of freedom are 4. The fitted line is y = 0.8667 + 1.0857x. Residual SSE is 2.7048 and the slope standard error is 0.1966.

t = 1.0857 / 0.1966 = 5.5233. The two-sided p-value is 0.0052. The two-sided 5 percent critical t on 4 degrees of freedom is 2.7764.

The 95 percent interval is 1.0857 plus or minus 2.7764 times 0.1966, from 0.54 to 1.6315. That interval excludes 0. At the optional x of 7, the line predicts 8.4667. This is not a prediction interval.

Figures from the worked example
Slope1.0857
95% CI for slope0.54 to 1.6315
Standard error0.1966
t5.5233
Two-sided p-value0.0052
Degrees of freedom4
Fitted liney = 0.8667 + 1.0857x
Predicted y8.4667

How to read the result

If the interval excludes zero, the two-sided test at 0.05 rejects a slope of zero. The interval is about the slope, not about a single future y. 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

  • Errors are treated as independent with constant spread around a straight line.
  • You want a two-sided test of a zero slope at 0.05.
  • At least three pairs are present.
  • The x values are not all the same.

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

  • Reading the prediction interval for a new y as if this page had built one. The interval here is for the slope.
  • Using the line of best fit page and inventing a p-value it does not compute.
  • Ignoring a tiny standard error that came from a huge range of x.
  • Quoting the interval after the x column was constant. The standard error is then undefined.

Where a different calculator is the honest choice

Use the line of best fit calculator when you only want the line, the residual SSE, and a prediction. Use Pearson's correlation test when the parameter of interest is r rather than the slope. Use multiple linear regression when a second predictor belongs in the fit. 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: Line of Best Fit Calculator, Pearson's Correlation Test Calculator, Multiple Linear Regression Calculator.

Check yourself

The slope is 2, its standard error is 1, and the two-sided critical t is 2.5. Does a 95 percent interval include 0?

The interval is 2 plus or minus 2.5, from minus 0.5 to 4.5, so it does include 0.

Using the result in a sentence

A calibration slope, a dose-response line, and a simple trend test are the jobs that need the standard error beside the fitted line. Keep the count, the unit, and the assumption list beside any copy of the number that leaves this browser tab.

The interval is only as good as the straight-line, constant-spread model. One high-leverage point can shrink the standard error or move the slope a long way. 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 Linear Regression Calculator commit to?

This page uses t inference for a simple regression slope: t = b / se(b), df = n - 2, interval = b plus or minus t-critical times se(b). Under the usual normal-error model, (b minus the true slope) divided by se(b) follows a t distribution with n minus 2 degrees of freedom. The interval is that statement rearranged around the estimated slope. 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, Optional 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 slope is 1.0857. If the interval excludes zero, the two-sided test at 0.05 rejects a slope of zero. The interval is about the slope, not about a single future y. 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?

Reading the prediction interval for a new y as if this page had built one. The interval here is for the slope. The interval is only as good as the straight-line, constant-spread model. One high-leverage point can shrink the standard error or move the slope a long way. 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 line of best fit calculator when you only want the line, the residual SSE, and a prediction. Use Pearson's correlation test when the parameter of interest is r rather than the slope. Use multiple linear regression when a second predictor belongs in the fit. 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 interval is 2 plus or minus 2.5, from minus 0.5 to 4.5, so it does include 0. 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.