Simple linear regression fits the straight line y = intercept + slope × x that best predicts one number from another. The slope says how much y changes, on average, for each one-unit change in x.
Slope = Σ (x − x̄)(y − ȳ) ÷ Σ (x − x̄)²; Intercept = ȳ − slope × x̄
On the 30-day sample below: 6.42.
When to use it
It turns "spend and orders move together" into a number you can plan with: roughly how many extra orders each extra ₹1,000 of ad spend has gone with.
Worked example
The slope here is multiplied by 1,000, so it reads as extra website orders per extra ₹1,000 of daily ad spend. It describes the past association, not what more spend will cause.
=SLOPE(C2:C31,B2:B31)*1000| Day | Ad spend (₹) | Website orders |
|---|---|---|
| 1 | ₹3,800 | 24 |
| 2 | ₹3,000 | 27 |
| 3 | ₹3,900 | 22 |
| 4 | ₹3,200 | 30 |
| 5 | ₹4,000 | 28 |
| 6 | ₹4,100 | 25 |
| 7 | ₹3,100 | 31 |
| 8 | ₹3,600 | 29 |
| 9 | ₹4,100 | 26 |
| 10 | ₹3,500 | 33 |
| 11 | ₹4,300 | 30 |
| 12 | ₹4,500 | 28 |
| 13 | ₹3,900 | 35 |
| 14 | ₹3,900 | 32 |
| 15 | ₹4,300 | 29 |
| 16 | ₹3,700 | 34 |
| 17 | ₹7,200 | 61 |
| 18 | ₹4,800 | 31 |
| 19 | ₹3,800 | 36 |
| 20 | ₹4,500 | 33 |
| 21 | ₹4,500 | 30 |
| 22 | ₹4,000 | 37 |
| 23 | ₹4,200 | 35 |
| 24 | ₹4,800 | 32 |
| 25 | ₹4,300 | 38 |
| 26 | ₹5,000 | 36 |
| 27 | ₹3,900 | 34 |
| 28 | ₹5,000 | 40 |
| 29 | ₹5,200 | 37 |
| 30 | ₹4,700 | 39 |
Common mistakes
- Regression on observational data is still correlation; it does not prove the spend caused the orders.
- Do not predict far outside the range of x you have. A line fitted between ₹3,000 and ₹7,200 says nothing about ₹20,000.
- Check the residuals: a pattern in them means a straight line is the wrong shape.
Calculate it yourself
Related methods
See all statistics methods or the business metrics they are used on.
Guides that use it
Further reading
Questions people ask
- What is linear regression?
- Simple linear regression fits the straight line y = intercept + slope × x that best predicts one number from another. The slope says how much y changes, on average, for each one-unit change in x.
- What is the formula for linear regression?
- Slope = Σ (x − x̄)(y − ȳ) ÷ Σ (x − x̄)²; Intercept = ȳ − slope × x̄. On the 30-day sample data the result is 6.42.
- How do you calculate linear regression in Excel?
- Use =SLOPE(C2:C31,B2:B31)*1000 with the data in rows 2 to 31. The same formula works in Google Sheets.
About the data on this page
The figures come from a small made-up dataset, printed above in full so you can check every number by hand. Download it as daily.csv. The results are computed from those rows when the page is built, and the Excel formulas, SQL and Python on these pages are run against the same rows before publishing, so the code and the answers agree.
To get these numbers from your own data without writing formulas, try AnalyzeIt: ask in plain words and it shows the working behind every figure.
Legal entity
Devansh Yadav
Moradabad, Uttar Pradesh
Governing law: Courts at Moradabad, Uttar Pradesh
Phone: +91 8433475698
Legal: legal@analyzeit.in