Paritian

Statistics

Linear Regression Calculator

The straight line that fits a set of points best, with the equation, how much it explains, and a prediction.

Results

The line of best fit y = 2.0170 x + 0.0867
Slope 2.0170
Where it crosses zero 0.0867
Of the variation the line explains 99.81 %
Correlation (Pearson r) 0.9991
And y would be 24.2903
Typical distance from the line 0.2811
Uncertainty in the slope 0.0310
p value (two-tailed) 3.42015e-12
The slope is more than noise Yes
Direction Rising
Count 10

What this tool does

Least squares finds the one straight line that gets closest to every point at once — closest in the specific sense of making the squared vertical distances add up to the smallest possible total. Paste your x values and your y values, in the same order, and this page returns the equation, the share of the variation the line accounts for, and how uncertain the slope is. That last figure is the one most reports leave out, and it is the one that decides whether the trend you are about to describe is really there.

Formula

least squares: slope = Σ(x−x̄)(y−ȳ) ÷ Σ(x−x̄)² · the line passes through (x̄, ȳ)

Variables

SymbolMeaningUnit
x_valuesThe x values, one per line or separated by commas
y_valuesThe y values, in the same order
predict_xPredict y when x is
OUTThe line of best fit
SLSlope
ICWhere it crosses zero
R2Of the variation the line explains%
RRCorrelation (Pearson r)
PRAnd y would be
SETypical distance from the line
SBUncertainty in the slope
PVp value (two-tailed)
SGThe slope is more than noise
DRDirection
CTCount

Worked example

  • The x values, one per line or separated by commas1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  • The y values, in the same order2.1, 4.3, 5.9, 8.4, 9.8, 12.5, 14.1, 15.9, 18.6, 20.2
  • Predict y when x is12
  • The line of best fity = 2.0170 x + 0.0867
  • Slope2.0170
  • Where it crosses zero0.0867
  • Of the variation the line explains99.81 %
  • Correlation (Pearson r)0.9991
  • And y would be24.2903
  • Typical distance from the line0.2811
  • Uncertainty in the slope0.0310
  • p value (two-tailed)3.42015e-12
  • The slope is more than noiseYes
  • DirectionRising
  • Count10

Limitations

  • The calculation runs entirely in your browser. The values you type are never sent to a server.
  • The result is an estimate based only on the values you type. Real situations often include factors this calculator does not know about.

Frequently asked questions

What does the percentage explained actually mean?

It is how much of the up-and-down in your y values the straight line accounts for. At 100 per cent every point sits exactly on the line; at zero the line tells you nothing you would not get from the average of y. What it does not mean is that x causes y, or that the relationship is really a straight line — a perfect curve fitted with a straight line can still score above 90 per cent while being the wrong shape entirely. Plot the points before trusting the figure.

Can I predict outside the range of my data?

The arithmetic will happily give you a number, and that is the danger. A line fitted between x of one and ten says nothing about what happens at x of a hundred: nothing in your data speaks to that range, and real relationships bend, saturate or reverse. The prediction box here is most useful for filling a gap inside the range you measured. Outside it, the honest answer is that you are extrapolating and the line is an assumption, not a finding.