📊 Statistics & Probability

Linear Regression Calculator

Fit a linear regression line to your data. Free regression calculator with slope, intercept, R², and predictions.

Loading calculator…
Share: WhatsApp Facebook X / Twitter

What This Calculator Tells You

Simple linear regression fits the straight line that best describes how one variable (Y) changes with another (X). The result is an equation, y = m·x + b, that you can use to estimate Y for a new X — for example, how many leads an extra $1,000 of ad spend is likely to bring.

The calculator returns the slope (m), the intercept (b), R² and the full equation, using the least-squares method.

What to Enter

  • X values — the variable you control or that comes first (ad spend, square footage, price).
  • Y values — the outcome you want to predict (leads, home price, units sold), in the same order as X.

Separate values with commas, spaces or new lines. Both lists need the same number of values, and X needs at least two different values.

Worked Examples

1. Ad spend and leads

Monthly ad spend in $ thousands (2, 3, 4, 5, 6, 7) against leads (11, 14, 15, 19, 21, 24).

  • Result → y = 2.571x + 5.762, R² = 0.986.
  • Each extra $1,000 of spend has come with about 2.6 more leads. At $8,000 the line predicts 2.571 × 8 + 5.762 ≈ 26 leads.

2. Home size and price

Square footage (1,200–2,400) against sale price ($250,000–$430,000) for five comparable homes.

  • Result → slope 151.67, intercept 68,000, R² = 0.999.
  • Each additional square foot adds about $152 to the price in this neighborhood. The intercept ($68,000) is not meaningful on its own — no home has zero square feet.

3. Price and units sold

Prices of $8–$12 against weekly units (500, 470, 430, 410, 380).

  • Result → y = −30.000x + 738.000, R² = 0.991.
  • Every $1 price increase has cost about 30 units a week — useful input for pricing decisions.

How It’s Calculated

Slope b = Σ((x − x̄)(y − ȳ)) ÷ Σ((x − x̄)²). Intercept a = ȳ − b × x̄.

How to Read Your Result

  • Slope (m): how much Y changes, on average, for a one-unit increase in X. Its sign shows direction.
  • Intercept (b): the predicted Y when X is zero. Often just a mathematical anchor rather than a real-world value.
  • R²: the share of the variation in Y explained by the line. 0.99 is a near-perfect fit; 0.3 means most variation comes from other factors.
  • Predict carefully: estimates are most reliable inside the range of X values you entered. Extending far beyond it is guesswork.
  • To measure strength and direction without a prediction line, use the correlation calculator.

Common Mistakes to Avoid

  • Extrapolating far outside your data. A line fitted to $2k–$7k of spend says little about $50k.
  • Assuming cause. A strong fit shows association, not that X drives Y.
  • Forcing a straight line onto a curve. If growth levels off or accelerates, a linear model will mislead. Plot the data first.
  • Swapping X and Y. Regressing Y on X gives a different line from regressing X on Y. Put the variable you want to predict in Y.
  • Using too few points. With five or six points, one unusual value can swing the slope.
Built and maintained by GenAlpha Tools Editorial. Formula tested against known answers and edge cases · last reviewed October 2026. How we calculate · Report an error

When to Use This Calculator

  • Estimate the return on extra marketing spend.
  • Price a property or product from comparable data.
  • Forecast simple trends from recent history.
  • Check statistics homework.

Frequently Asked Questions

What is the least-squares method?

It chooses the line that makes the sum of the squared vertical distances between each point and the line as small as possible.

What is the difference between regression and correlation?

Correlation measures how strongly two variables move together. Regression goes further and gives an equation to predict one from the other. See correlation vs regression.

What is a good R² value?

It depends on the field. Physical measurements often exceed 0.9; in marketing and social data, 0.4–0.6 can still be useful. Always look at the plotted data too.

Can I use more than one X variable?

Not here — this is simple (one-variable) regression. Multiple regression needs a spreadsheet's regression tool or statistical software.

Why does it say "Undefined"?

If every X value is the same, there is no horizontal spread to fit a line through, so the slope cannot be calculated.

Do you store the values I enter?

No. All calculations happen in your browser. Your data never leaves your device.

Related Guides

Related Calculators