Calculate Ordinary Least Squares (OLS) Linear Regression

Enter independent X values, dependent Y values, and optional prediction X value.

Values for independent variable X.
Values for dependent variable Y.
X value to predict outcome $\hat{y}$ (e.g. 6).

Calculation Results

Primary Metric Output --
Metric Breakdown 1--
Metric Breakdown 2--
Metric Breakdown 3--
Metric Breakdown 4--
Metric Breakdown 5--
Mathematical Standard--

Calculated using Ordinary Least Squares (OLS) equations: \beta_1 = \frac{\sum (x - \bar{x})(y - \bar{y})}{\sum (x - \bar{x})^2}, \quad \beta_0 = \bar{y} - \beta_1 \bar{x}

*Note: Simple Linear Regression fits a straight trend line minimizing sum of squared vertical residuals (errors).

Quick Summary

The Simple Linear Regression Calculator fits the OLS line $\hat{y} = \beta_0 + \beta_1 x$, evaluating slope $\beta_1$, intercept $\beta_0$, $R^2$, and predicting $Y$ for any target $X$.

Formula Explanation

\hat{y} = \beta_0 + \beta_1 x
\beta_1 = \frac{SS_{XY}}{SS_{XX}}, \quad \beta_0 = \bar{y} - \beta_1 \bar{x}

How It Works

Simple linear regression models the relationship between an independent variable $X$ and a dependent variable $Y$. The Simple Linear Regression Calculator computes least squares coefficients minimizing residual sum of squares $\sum (y_i - \hat{y}_i)^2$.

Step-by-Step Worked Example

Practical Problem: Fit a linear regression for $X = \{1, 2, 3, 4, 5\}$ and $Y = \{2, 4, 5, 4, 5\}$ ($\bar{x} = 3, \bar{y} = 4$). Predict $\hat{y}$ for $X = 6$.

  1. Step 1: Calculate $SS_{XX}$ and $SS_{XY}$: $SS_{XX} = 10.0$, $SS_{XY} = 6.0$.
  2. Step 2: Calculate Slope ($\beta_1$): $\beta_1 = 6.0 / 10.0 = \mathbf{0.6000}$.
  3. Step 3: Calculate Intercept ($\beta_0$): $\beta_0 = 4.0 - (0.6000 \times 3.0) = 4.0 - 1.80 = \mathbf{2.2000}$.
  4. Step 4: Formulate Regression Equation: $\hat{y} = 0.6000x + 2.2000$.
  5. Step 5: Predict for $X = 6$: $\hat{y} = 0.6000(6) + 2.2000 = 3.60 + 2.20 = \mathbf{5.8000}$.

Real-World Calculation Examples

Scenario 1: Linear Model (y = 0.60x + 2.20)

Parameters: X = 1..5, Y = 2..5
Result: Slope = 0.60, Intercept = 2.20 ($R^2 = 60.0\%$).

Scenario 2: Ad Spending vs Monthly Revenue

Parameters: X = $1,000 Ad spend, Y = Revenue
Result: Predicts revenue return per ad dollar.

Scenario 3: Temperature vs Ice Cream Sales

Parameters: Daily temperature vs sales revenue
Result: Positive linear trend prediction.

Scenario 4: Machine Operational Hours vs Maintenance Cost

Parameters: Machine age vs repair costs
Result: Linear cost forecasting model.

Key Benefits of Using This Calculator

Instant OLS Parameter Estimation

Calculates exact least squares slope $\beta_1$ and intercept $\beta_0$.

Target Value Prediction

Predicts dependent outcome $\hat{y}$ for any user-defined $X$.

Standard Error of Estimate

Computes $S_e$ residual error standard deviation.

100% Free & Client-Side

Executes locally in your browser with zero latency or web server transmission.

Frequently Asked Questions (FAQ)

What is Simple Linear Regression?

Simple Linear Regression models the linear relationship between one independent predictor $X$ and one continuous outcome $Y$.

What does slope $\beta_1$ represent?

Slope $\beta_1$ represents the estimated change in outcome $Y$ for every 1-unit increase in predictor $X$.

What does intercept $\beta_0$ represent?

Intercept $\beta_0$ represents the predicted value of outcome $Y$ when predictor $X = 0$.

How do I run simple linear regression in Excel?

Use formulas =SLOPE(known_y, known_x) and =INTERCEPT(known_y, known_x), or the Data Analysis Toolpak.

What is Ordinary Least Squares (OLS)?

OLS is an optimization technique that minimizes the sum of squared vertical distances (residuals) between data points and the regression line.

What assumptions are required for linear regression?

1. Linearity. 2. Independence of errors. 3. Homoscedasticity (equal variance). 4. Normality of residuals.

What is a residual ($e_i$)?

A residual $e_i = y_i - \hat{y}_i$ is the vertical difference between observed $y_i$ and predicted $\hat{y}_i$.

What is difference between simple and multiple regression?

Simple regression uses 1 predictor variable; multiple regression uses 2 or more predictor variables ($X_1, X_2, \dots, X_k$).

What is extrapolation danger in regression?

Extrapolation predicting $\hat{y}$ for $X$ values far outside the original data range can produce highly inaccurate estimates.

How is slope significance tested?

Using $t$-test $t = \frac{\beta_1}{SE(\beta_1)}$ with $df = n - 2$.