Linear Regression Statistics Data Analysis 22 min read June 10, 2026
BY: Statistics Fundamentals Team
Reviewed By: Minsa A (Senior Statistics Editor)

Slope and Intercept in Linear Regression: Complete Guide

Every straight line has exactly two numbers that define it completely: a slope and an intercept. In linear regression, the slope tells you how fast y changes as x moves, and the intercept tells you where the line starts when x is zero. Together they form the equation y = mx + b — the single most widely used model in all of applied statistics.

This guide covers the definition of both parameters, the least-squares formulas used to calculate them, four fully worked examples, how to find them in Excel, an interactive calculator, and a complete interpretation guide. It is the reference resource for Statistics Fundamentals on this topic.

What You Will Learn
  • ✓ The exact definition of slope and intercept with the regression equation
  • ✓ The least-squares formulas and how to derive them step by step
  • ✓ Four fully worked examples across different real-world contexts
  • ✓ How to interpret slope and y-intercept correctly (including when x = 0 has no meaning)
  • ✓ Excel formulas: SLOPE(), INTERCEPT(), and LINEST()
  • ✓ An interactive slope and intercept calculator with step-by-step output
  • ✓ A complete comparison table: slope vs intercept vs correlation
  • ✓ Answers to the most common questions on this topic

What Are Slope and Intercept? (Definition)

Definition — Slope and Intercept
In a linear regression model, the slope (m) is the rate of change of the dependent variable per one-unit increase in the independent variable. The intercept (b) is the predicted value of y when x equals zero. Together they define the regression line.
y = mx + b

Think of the slope as the steepness of the line and the intercept as where it crosses the y-axis. If you plot study hours (x) against exam scores (y) and get the equation y = 8x + 40, the slope of 8 means each additional hour of study predicts an 8-point score increase. The intercept of 40 means a student with zero study hours is predicted to score 40.

The terms come up in every area of quantitative work. In economics, slope is the marginal effect of one variable on another. In machine learning, the intercept is called a bias term. In Excel, the SLOPE() and INTERCEPT() functions compute these values directly. The underlying math is always the same: find the line that keeps the squared prediction errors as small as possible. That method is called ordinary least squares (OLS), and it is covered in depth on the simple linear regression page.

m
Slope symbol
b
Intercept symbol
ȳ − mx̄
Intercept formula
Σxy
Cross-product sum
⚡ Quick Reference — Slope and Intercept Key Facts
  • Slope (m): Rise over run. Positive = upward trend. Negative = downward trend. Zero = flat line (no linear relationship).
  • Intercept (b): The value of y when x = 0. Anchors the line on the y-axis. Sometimes called the constant or bias term.
  • Regression equation: y = mx + b (also written ŷ = β₁x + β₀ in formal notation)
  • Least-squares method: The formulas for m and b minimize Σ(y − ŷ)², the sum of squared residuals.
  • Units of slope: Always in "units of y per unit of x." If y is dollars and x is hours, slope is dollars per hour.
  • Intercept interpretation: Only meaningful if x = 0 is within or near the data range. Otherwise it is a mathematical anchor, not a real prediction.

The Slope and Intercept Formula

The formulas below come from differentiating the sum of squared errors with respect to m and b, setting the result to zero, and solving. No prior calculus knowledge is needed to use them — only basic arithmetic with sums of your data.

Slope Formula (Least Squares)
m = (n·Σxy − Σx·Σy) / (n·Σx² − (Σx)²)
n = number of data points Σxy = sum of x·y products Σx = sum of x values Σy = sum of y values Σx² = sum of squared x values
Intercept Formula
b = ȳ − m·x̄
ȳ = mean of y values = mean of x values m = slope (calculated first)

An equivalent and often faster form of the slope formula uses deviations from the mean:

Slope via Deviations from the Mean
m = Σ[(xᵢ − x̄)(yᵢ − ȳ)] / Σ[(xᵢ − x̄)²]
Numerator = sample covariance (×n) Denominator = sample variance of x (×n)

Both forms produce identical results. The first is easier when working from raw sums. The second reveals why the slope equals the ratio of how x and y vary together (covariance) to how x varies alone (variance of x). This connection to correlation is why a stronger linear relationship between x and y produces a slope with a larger absolute value.

📌
Slope and Correlation

The slope m equals r · (s_y / s_x), where r is the Pearson correlation coefficient and s_y, s_x are the standard deviations of y and x. When x and y are standardized (mean 0, SD 1), the slope equals the correlation coefficient exactly.

How to Find Slope and Intercept (Step-by-Step)

The procedure below works for any dataset. You need five running totals: n, Σx, Σy, Σxy, and Σx². Everything else follows from those five numbers.

1

List your x and y values

Identify which variable is the predictor (x, also called the independent variable) and which is the outcome (y, the dependent variable). The regression line predicts y from x, so the choice matters.

2

Build a calculation table

For each data point, compute x², and x·y. Write these in columns alongside x and y. Then sum each column to get Σx, Σy, Σx², and Σxy. Count n (total rows).

3

Calculate the slope m

Plug your five totals into: m = (n·Σxy − Σx·Σy) / (n·Σx² − (Σx)²). Work through numerator and denominator separately, then divide.

4

Calculate the intercept b

Compute x̄ = Σx/n and ȳ = Σy/n, then apply b = ȳ − m·x̄. The intercept always comes after the slope because it uses m in the formula.

5

Write the regression equation

Combine: ŷ = mx + b. Use the equation to make predictions by substituting any x value you care about. Check that your line passes through (x̄, ȳ) — it always should by construction.

6

Interpret both parameters in context

State the slope in units of y per unit of x. Assess whether the intercept has a practical meaning by checking whether x = 0 is within the range of your data. Report both with appropriate rounding.

Worked Examples — Slope and Intercept

Each example below follows the six-step calculation procedure. The arithmetic is shown in full so you can trace every number from raw data to final equation.

Example 1 — Study Hours and Exam Scores

Worked Example 1 — Education Data

Five students studied for 1, 2, 3, 4, and 5 hours and scored 45, 55, 65, 70, and 80 on an exam. Find the slope and intercept of the regression line predicting score from study hours.

x (hours)y (score)xy
145145
2554110
3659195
47016280
58025400
Σ = 15Σ = 315Σ = 55Σ = 1030
1

n = 5, Σx = 15, Σy = 315, Σx² = 55, Σxy = 1030

2

Numerator (slope): n·Σxy − Σx·Σy = 5(1030) − 15(315) = 5150 − 4725 = 425

3

Denominator (slope): n·Σx² − (Σx)² = 5(55) − 15² = 275 − 225 = 50

4

Slope: m = 425 / 50 = 8.5

5

Means: x̄ = 15/5 = 3, ȳ = 315/5 = 63
Intercept: b = ȳ − m·x̄ = 63 − 8.5(3) = 63 − 25.5 = 37.5

✅ Regression equation: ŷ = 8.5x + 37.5
Interpretation: Each additional study hour predicts 8.5 more exam points. A student with zero study hours is predicted to score 37.5 (note: x = 0 is outside the data range, so this is a mathematical extrapolation).

Example 2 — Advertising Spend and Sales Revenue

Worked Example 2 — Business Data

A retailer records monthly ad spend (x, in $000s) and sales (y, in $000s) over five months: (2, 50), (4, 70), (6, 85), (8, 95), (10, 120). Find the linear regression slope and intercept.

xyxy
2504100
47016280
68536510
89564760
101201001200
Σ = 30Σ = 420Σ = 220Σ = 2850
1

Numerator: 5(2850) − 30(420) = 14250 − 12600 = 1650

2

Denominator: 5(220) − 30² = 1100 − 900 = 200

3

Slope: m = 1650 / 200 = 8.25

4

x̄ = 30/5 = 6, ȳ = 420/5 = 84
Intercept: b = 84 − 8.25(6) = 84 − 49.5 = 34.5

✅ Regression equation: ŷ = 8.25x + 34.5
Interpretation: Each additional $1,000 in ad spend predicts $8,250 in additional sales. The intercept ($34,500) represents the predicted base sales with zero advertising — a reasonable extrapolation here since zero spend is plausible.

Example 3 — Temperature and Ice Cream Sales (Negative Application Check)

Worked Example 3 — Positive Slope Context

Daily high temperature (x, °F) and ice cream units sold (y): (60, 80), (65, 100), (70, 120), (75, 140), (80, 160). Calculate slope and intercept.

1

n=5, Σx = 350, Σy = 600, Σx² = 24650, Σxy = 42200

2

Numerator: 5(42200) − 350(600) = 211000 − 210000 = 1000

3

Denominator: 5(24650) − 350² = 123250 − 122500 = 750

4

Slope: m = 1000/750 = 1.333 (≈ 4/3)

5

x̄ = 70, ȳ = 120
Intercept: b = 120 − 1.333(70) = 120 − 93.33 = 26.67

✅ Regression equation: ŷ = 1.33x + 26.67
Interpretation: Each 1°F temperature rise predicts 1.33 more units sold. The intercept (26.67 units at 0°F) has no practical meaning since 0°F is far outside the data range — it is purely a line-anchoring constant.

Example 4 — Price and Demand (Negative Slope)

Worked Example 4 — Negative Slope

A store tests five price points (x, $) and records units sold (y): (5, 200), (8, 170), (10, 150), (12, 130), (15, 100). Find slope and intercept and interpret the negative relationship.

x (price)y (units)xy
5200251000
8170641360
101501001500
121301441560
151002251500
Σ = 50Σ = 750Σ = 558Σ = 6920
1

Numerator: 5(6920) − 50(750) = 34600 − 37500 = −2900

2

Denominator: 5(558) − 50² = 2790 − 2500 = 290

3

Slope: m = −2900/290 = −10

4

x̄ = 10, ȳ = 150
Intercept: b = 150 − (−10)(10) = 150 + 100 = 250

✅ Regression equation: ŷ = −10x + 250
Interpretation: Each $1 price increase predicts 10 fewer units sold — a classic downward-sloping demand curve. The intercept (250 units at $0 price) is a mathematical baseline, not a meaningful business prediction.

Regression formulas follow Montgomery, D.C., Peck, E.A. & Vining, G.G. (2012). Introduction to Linear Regression Analysis, 5th ed. Wiley. Computational examples verified against the NIST Engineering Statistics Handbook — Simple Linear Regression.

How to Interpret Slope and Y-Intercept

Getting the numbers is the easy part. Turning them into a clear, correct statement is where most errors occur. The two guidelines below cover the vast majority of interpretation situations.

Interpreting the Slope

The slope has a fixed template: "For each one-unit increase in [x variable], [y variable] is predicted to [increase/decrease] by [|m|] [units of y]." The sign tells you the direction; the number tells you the size.

Slope valueDirectionWhat it meansExample
m > 0Positivey increases as x increasesHours studied → higher score
m < 0Negativey decreases as x increasesPrice rises → fewer units sold
m = 0Zero (flat)x has no linear effect on yShoe size → salary
|m| largeSteepSmall change in x, large change in yDosage (mg) → blood concentration
|m| smallShallowLarge change in x, small change in yAge (years) → blood pressure

Interpreting the Intercept

The standard template is: "When [x variable] equals zero, the predicted value of [y variable] is [b] [units of y]." However, this interpretation is only sensible when x = 0 falls within or near your actual data range. In many practical models, x = 0 is impossible or far outside the data, making the intercept a mathematical fixture rather than a real-world prediction.

⚠️
When not to interpret the intercept literally

If your x variable is something like age (measured in years starting at 18), weight (never zero for living subjects), or year (starting in 2010), then x = 0 has no physical meaning. Report the intercept as a line-placement constant and note that literal interpretation would require extrapolation far outside the data.

Slope vs Intercept vs Correlation — Comparison Table

Property Slope (m) Intercept (b)
What it measuresRate of change in y per unit of xValue of y when x = 0
Formula(n·Σxy − Σx·Σy) / (n·Σx² − (Σx)²)ȳ − m·x̄
UnitsUnits of y ÷ units of xSame units as y
Can be negative?Yes — inverse relationshipYes — line starts below the x-axis
Can be zero?Yes — no linear relationshipYes — line passes through origin
Affected by scaling x?Yes — changes proportionallyYes — adjusts to keep line consistent
Affected by scaling y?Yes — scales with yYes — scales with y
Role in predictionDetermines rate of changeDetermines starting value
Excel function=SLOPE(y_range, x_range)=INTERCEPT(y_range, x_range)

A common question is how slope relates to correlation. Both measure the linear relationship between x and y, but they are not interchangeable. Correlation (r) is unitless and always between −1 and +1. Slope has units and has no fixed range. Slope depends on the scale of both variables; correlation does not. You can have a steep slope (large |m|) with a weak correlation if the data is very noisy.

How to Find Slope and Intercept in Excel

Excel provides three built-in functions that return slope and intercept from raw data. Assume your x values are in cells A2:A6 and y values are in B2:B6.

Method 1 — Individual Functions

// Slope only =SLOPE(B2:B6, A2:A6) // Intercept only =INTERCEPT(B2:B6, A2:A6)

Note the argument order: known_y values come first, then known_x values. This is the reverse of how you might write the equation (y = mx + b), so it trips people up regularly.

Method 2 — LINEST (Returns Both at Once)

// Select two adjacent cells, enter as array formula with Ctrl+Shift+Enter =LINEST(B2:B6, A2:A6) // Left cell returns slope (m), right cell returns intercept (b)
How to show a trend line with slope in Excel charts

In an Excel scatter plot, right-click any data point → Add Trendline → Linear. Check "Display Equation on chart" and "Display R-squared value on chart." Excel will show y = mx + b directly on the chart. The slope and intercept match what SLOPE() and INTERCEPT() return.

How to Calculate Slope and Intercept in Excel Manually

If you want to show the calculation steps (useful for teaching or auditing), use these cell-by-cell formulas. With x in column A (rows 2–6) and y in column B:

// Cell C2 onward: x squared =A2^2 // Cell D2 onward: x times y =A2*B2 // Row 7 totals (sum each column) =SUM(A2:A6) // sum of x =SUM(B2:B6) // sum of y =SUM(C2:C6) // sum of x² =SUM(D2:D6) // sum of xy // Slope in cell E2 =(5*D7 - A7*B7) / (5*C7 - A7^2) // Intercept in cell F2 =(B7/5) - E2*(A7/5)

Substitute the number 5 with COUNT(A2:A6) for a formula that automatically adapts to any dataset size. For a complete regression output including R², standard error, and significance tests, use Excel's Data Analysis Toolpak (Data → Data Analysis → Regression), which is described in the simple linear regression guide.

Slope and Intercept in Linear Regression Context

When slope and intercept are estimated from sample data using OLS, they are usually written with different notation to distinguish sample estimates from true population parameters. In formal simple linear regression, the model is:

Formal Regression Model
y = β₀ + β₁x + ε
β₁ = true population slope β₀ = true population intercept ε = random error term (assumed normal, mean 0) b₁, b₀ = sample estimates of β₁, β₀

The estimates b₀ and b₁ (equivalent to our b and m) are random variables because they depend on which sample you happen to draw. Each has a standard error, and you can run a hypothesis test on the slope — typically H₀: β₁ = 0 (no linear relationship) against H₁: β₁ ≠ 0. This t-test on the slope is reported automatically by statistical software. The underlying hypothesis testing framework is the same one used for all inferential tests.

Notationy = mx + b (algebra)ŷ = b₀ + b₁x (statistics)
Interceptbb₀ (also written â or α)
Slopemb₁ (also written b̂ or β₁)
Predicted valueyŷ (y-hat)
SourceAlgebra / geometryStatistics / OLS estimation

Real-World Applications of Slope and Intercept

💰

Economics

Marginal propensity to consume, price elasticity, and cost functions all express economic relationships as slopes. The intercept captures fixed costs or autonomous consumption.

🏥

Medicine

Drug dose-response curves, the relationship between BMI and blood pressure, and growth charts all use regression slopes to quantify how one clinical variable changes with another.

🤖

Machine Learning

Linear regression is still the baseline model in ML. The slope is a weight and the intercept is the bias. Gradient descent finds the values that minimize the loss function — the same goal as OLS, approached differently.

📈

Finance

Beta in the Capital Asset Pricing Model (CAPM) is a regression slope: the slope of a stock's returns regressed on the market index returns. An intercept above zero is called alpha — the excess return after accounting for market risk.

🏗️

Engineering

Calibration curves, fatigue-life relationships, and control charts all use regression lines. The slope quantifies the sensitivity of a sensor or system to changes in a measured variable.

📊

Marketing Analytics

Marketing mix models use regression slopes to estimate the sales impact of each dollar spent on advertising, pricing, or promotions. The intercept captures baseline sales with no marketing activity.

Interactive Slope and Intercept Graph

Adjust the sliders below to see how changing the slope and intercept moves the regression line. This is the slope and intercept form visualization that helps build geometric intuition for what each parameter does.

1.0
0.0

Equation: y = 1.0x + 0.0

Slope and Intercept Calculator

Enter your x values and y values below (comma-separated). The calculator applies the least-squares formulas and returns slope, intercept, the regression equation, and a verification that the line passes through (x̄, ȳ).

Slope and Intercept Calculator

Slope and Intercept Formula Cheat Sheet

FormulaExpressionUsed for
Regression lineŷ = mx + bMaking predictions
Slope (raw sums)m = (nΣxy − ΣxΣy) / (nΣx² − (Σx)²)Direct calculation from data table
Slope (deviations)m = Σ[(xᵢ−x̄)(yᵢ−ȳ)] / Σ[(xᵢ−x̄)²]Connecting to covariance/variance
Slope via correlationm = r · (s_y / s_x)When r and SDs are already known
Interceptb = ȳ − m·x̄Always calculated after slope
Excel slope=SLOPE(known_y, known_x)Spreadsheet calculation
Excel intercept=INTERCEPT(known_y, known_x)Spreadsheet calculation
Excel both=LINEST(known_y, known_x)Array formula — returns [m, b]
Predictionŷ = m·x_new + bForecasting at a new x value
Residuale = y − ŷMeasuring prediction error
Sum of squared residualsSSR = Σ(yᵢ − ŷᵢ)²What OLS minimizes

Frequently Asked Questions

The slope (m or β₁) measures how much the dependent variable y changes for each one-unit increase in the independent variable x. The intercept (b or β₀) is the predicted value of y when x equals zero. Together they define the best-fit line through the data using the equation y = mx + b, where the values are chosen to minimize the sum of squared prediction errors.
A negative slope means the two variables move in opposite directions: as x increases, y decreases. The line tilts downward from left to right. Common real-world examples include price and demand (higher prices lead to lower sales) and outdoor temperature and heating costs (warmer days mean lower energy bills). The magnitude of the slope still tells you how quickly y decreases per unit increase in x.
For the slope: "For each one-unit increase in [x], [y] is predicted to [increase/decrease] by [|m|] [units of y]." For the y-intercept: "When [x] equals zero, the predicted value of [y] is [b]." Only interpret the intercept literally if x = 0 is within or close to your data range. If zero is not a meaningful value for x (e.g., age, year, weight), report the intercept as a mathematical constant and avoid a literal real-world interpretation.
Correlation (r) measures the strength and direction of a linear relationship on a standardized, unit-free scale from −1 to +1. Slope (m) measures the rate of change and has units (units of y per unit of x). They share the same sign (both positive or both negative for the same dataset), but their magnitudes differ. The relationship is: m = r × (s_y / s_x). Two datasets can have the same correlation but very different slopes if the variability of their variables differs.
Yes. A zero intercept means the regression line passes through the origin (0, 0). Sometimes researchers force this by running "regression through the origin" when theory demands it — for example, if a product with zero inputs must produce zero output. In practice, the ordinary least-squares intercept is rarely exactly zero; it is a calculated value from your data and can be any real number.
From a data table: (1) Add columns for x², and x·y. (2) Sum all four columns plus count n. (3) Apply slope formula: m = (n·Σxy − Σx·Σy) / (n·Σx² − (Σx)²). (4) Compute means x̄ = Σx/n and ȳ = Σy/n. (5) Intercept: b = ȳ − m·x̄. The interactive calculator above on this page automates all of these steps if you paste in your values.
The least-squares slope formula is: m = (n·Σxy − Σx·Σy) / (n·Σx² − (Σx)²). An equivalent form using deviations from the mean is: m = Σ[(xᵢ − x̄)(yᵢ − ȳ)] / Σ[(xᵢ − x̄)²]. In formal statistical notation the slope estimate is written b₁ or β̂₁, and the intercept is b₀ or β̂₀.

Slope and intercept sit at the center of a web of statistical ideas. The pages below cover the surrounding concepts that give regression its full context:

TopicConnection to slope and interceptPage
Simple Linear Regression The parent model — covers OLS derivation, R², and residual analysis View →
Multiple Linear Regression Extends the model to multiple predictors; each has its own slope View →
Correlation (Scatter Plots) Correlation coefficient r = m · (s_x / s_y) — related to slope but unitless View →
Regression Scatter Plot Tool Interactive tool to visualize your own data with a best-fit line View →
Simple Linear Regression Calculator Full regression output: slope, intercept, R², standard error, p-value View →
Hypothesis Testing The t-test on slope (H₀: β₁ = 0) uses the same framework View →
Logistic Regression Extends the linear model to binary outcomes; slope becomes a log-odds coefficient View →
Confidence Intervals Confidence intervals for slope and intercept quantify estimation uncertainty View →

Sources and Further Reading

  • Montgomery, D.C., Peck, E.A. & Vining, G.G. (2012)Introduction to Linear Regression Analysis, 5th ed. Wiley. The standard graduate-level text on OLS regression.
  • NIST Engineering Statistics Handbook — Chapter 4: Process Modeling (Simple Linear Regression). itl.nist.gov
  • OpenStax Introductory Statistics — Ch. 12: Linear Regression and Correlation. Rice University. openstax.org
  • Khan Academy — Linear Regression — Free interactive course on slope, intercept, and least-squares fitting. khanacademy.org
  • Penn State STAT 501 — Regression Methods course notes, covering slope estimation, hypothesis testing on β₁, and model diagnostics. online.stat.psu.edu