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
- Paste matching x and y values.
- Choose a confidence level.
- Read the line, R², the t test and the interval for the slope.
OLS Regression Formula
Slope and intercept
Standard error of the slope
OLS Regression Variables Explained
| Symbol | Meaning | Notes |
|---|---|---|
| b | Slope of the line | Sxy / Sxx |
| SE(b) | Standard error of the slope | √(MSE / Sxx) |
| t | Test statistic for the slope | b / SE(b), df = n − 2 |
| R² | Share of variation explained | SSR / SST |
OLS Regression Worked Example
With the example values loaded in the calculator above, the steps are:
- n = 8, x̄ = 4.5, ȳ = 9.075, Sxx = 42, Sxy = 83.1.
- Slope b = Sxy ÷ Sxx = 1.97857. Intercept a = ȳ − b·x̄ = 0.171429.
- SSE = Σ(y − ŷ)² = 0.775714, SST = 165.195, SSR = SST − SSE = 164.419. R² = 0.995304.
- MSE = SSE ÷ (n − 2) = 0.129286, so the residual standard error is 0.359563.
- 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.