OLS Regression Calculator

This OLS regression calculator fits an ordinary least squares line and tests it, with standard errors, a t test, an F test and a confidence interval.

Checks on your data

  • Standard errors use the residual variance SSE ÷ (n − 2).
  • These tests assume a roughly linear relationship, independent errors, constant spread of residuals and roughly normal residuals. Check the residual column and plot.
  • A significant slope shows association, not cause.

Results

OLS line
ŷ = 0.17143 + 1.9786x
Slope (b)
1.97857
Intercept (a)
0.171429
R²
0.995304
Adjusted R²
0.994522
Standard error of the slope
0.0554818
Standard error of the intercept
0.280169
t for the slope
35.66
p-value for the slope (two-tailed)
< 0.0001
95% CI for the slope
1.8428 to 2.1143
Residual standard error
0.359563
F statistic (1, n − 2)
1272
p-value for F
< 0.0001
Degrees of freedom (residual)
6
OLS fit (R² = 0.995)
510152468xy
Fitted values and residuals
xyŷresidual
12.32.150.15
24.14.1286-0.028571
35.86.1071-0.30714
48.48.08570.31429
59.710.064-0.36429
612.512.0430.45714
713.614.021-0.42143
816.2160.2
Show step-by-step solution
  1. n = 8, x̄ = 4.5, ȳ = 9.075, Sxx = 42, Sxy = 83.1.
  2. Slope b = Sxy ÷ Sxx = 1.97857. Intercept a = ȳ − b·x̄ = 0.171429.
  3. SSE = Σ(y − ŷ)² = 0.775714, SST = 165.195, SSR = SST − SSE = 164.419. R² = 0.995304.
  4. MSE = SSE ÷ (n − 2) = 0.129286, so the residual standard error is 0.359563.
  5. SE(b) = √(MSE ÷ Sxx) = 0.0554818, t = b ÷ SE(b) = 35.66 with 6 degrees of freedom.
SlopeSxy / Sxx
SE(b)√(MSE / Sxx)
R²SSR / SST

What Is OLS Regression?

Ordinary least squares, or OLS, picks the line that makes the sum of squared residuals as small as possible. Beyond the slope and intercept, you usually need to know how precise they are.

This calculator gives the standard errors of both coefficients, the t test and p-value for the slope, a confidence interval for the slope, R², adjusted R², the residual standard error and the F test.

It handles one predictor. Check the residual table and the plot to see whether a straight line really suits your data.

How to Use the OLS Regression Calculator

  1. Paste matching x and y values.
  2. Choose a confidence level.
  3. Read the line, R², the t test and the interval for the slope.

OLS Regression Formula

Slope and intercept

b=SxySxx,a=yˉ−bxˉb=\frac{S_{xy}}{S_{xx}},\quad a=\bar y-b\bar x

Standard error of the slope

SE(b)=SSE/(n−2)SxxSE(b)=\sqrt{\frac{SSE/(n-2)}{S_{xx}}}

OLS Regression Variables Explained

SymbolMeaningNotes
bSlope of the lineSxy / Sxx
SE(b)Standard error of the slope√(MSE / Sxx)
tTest statistic for the slopeb / SE(b), df = n − 2
R²Share of variation explainedSSR / SST

OLS Regression Worked Example

With the example values loaded in the calculator above, the steps are:

  1. n = 8, x̄ = 4.5, ȳ = 9.075, Sxx = 42, Sxy = 83.1.
  2. Slope b = Sxy ÷ Sxx = 1.97857. Intercept a = ȳ − b·x̄ = 0.171429.
  3. SSE = Σ(y − ŷ)² = 0.775714, SST = 165.195, SSR = SST − SSE = 164.419. R² = 0.995304.
  4. MSE = SSE ÷ (n − 2) = 0.129286, so the residual standard error is 0.359563.
  5. SE(b) = √(MSE ÷ Sxx) = 0.0554818, t = b ÷ SE(b) = 35.66 with 6 degrees of freedom.

Result: OLS line = ŷ = 0.17143 + 1.9786x; Slope (b) = 1.97857.

What the output means

The slope is the average change in y for one more unit of x. The t test asks whether the true slope could be zero. The confidence interval gives a plausible range for it.

R² is the share of the variation in y explained by x. The F test in simple regression is equivalent to the slope t test.

Assumptions

The tests assume a straight-line relationship, independent errors, roughly equal spread of residuals and roughly normal residuals. Plot the residuals if the sample is small.

Where OLS Regression Is Used

Testing a relationship

See whether the slope is significantly different from zero.

Reporting results

Get the coefficient, standard error, t and interval in one place.

Checking software output

Match hand or Excel regression results.

Common OLS Regression Mistakes to Avoid

  • With few points, the interval for the slope is wide. Look at it, not only the p-value.
  • Do not extrapolate far outside your x range.

OLS Regression Terms and Definitions

Residual
The observed y minus the fitted ŷ.
SSE
The sum of squared residuals.

OLS Regression FAQs

What does OLS minimise?

The sum of squared vertical distances between the points and the line.

How is the slope tested?

With t = b ÷ SE(b) on n − 2 degrees of freedom.

What is adjusted R²?

R² corrected for the number of predictors. With one predictor it is close to R² unless n is small.

Can I use more than one predictor?

This calculator does one predictor. Multiple regression needs matrix methods.

Related calculators

Last updated 2026-11-09. See our disclaimer.