Linear Regression Slope Calculator Formula
Understand the math behind the linear regression slope calculator. Each variable explained with a worked example.
Formulas Used
Slope (b1)
slope = (n * sum_xy - sum_x * sum_y) / (n * sum_x2 - pow(sum_x, 2))Variables
| Variable | Description | Default |
|---|---|---|
n | Number of Data Points (n) | 10 |
sum_xy | Sum of x*y (Σxy) | 3500 |
sum_x | Sum of x (Σx) | 150 |
sum_y | Sum of y (Σy) | 200 |
sum_x2 | Sum of x² (Σx²) | 2850 |
How It Works
Linear Regression Slope
The slope of the least-squares regression line measures the average change in y for each one-unit increase in x.
Formula
b1 = (n × Σxy - Σx × Σy) / (n × Σx² - (Σx)²)
This is derived by minimizing the sum of squared residuals. A positive slope indicates a positive relationship; negative slope indicates an inverse relationship.
Worked Example
Given n=10, Σxy=3500, Σx=150, Σy=200, Σx²=2850.
- 01Numerator = 10(3500) - 150(200) = 35000 - 30000 = 5000
- 02Denominator = 10(2850) - 150² = 28500 - 22500 = 6000
- 03b1 = 5000 / 6000 = 0.8333
Frequently Asked Questions
What does the slope represent?
The slope b1 represents the predicted change in the response variable y for a one-unit increase in the predictor x. It quantifies the strength and direction of the linear relationship.
Can the slope be zero?
Yes. A slope of zero means there is no linear relationship between x and y. This is tested with a t-test where t = b1 / SE(b1). If t is not significant, the slope is not distinguishable from zero.
How does sample size affect the slope estimate?
Larger samples give more precise slope estimates (smaller standard error). The slope itself does not systematically change with sample size, but confidence intervals narrow.
Ready to run the numbers?
Open Linear Regression Slope Calculator