Ravindra BagaleCourses & study guides मराठी Track your progress

30. Statistics for Analysts

30.5 Simple Regression with SLOPE, INTERCEPT and LINEST: Predict Orders from Ad Spend

Example first. Amir's marketing head asks: "If we spend ₹12,000 on ads tomorrow, how many orders should we expect?" A straight line through the 20 days answers it: Orders ≈ 176.38 + 17.60 × AdSpend. For AdSpend 12 (thousand), that is about 388 orders. SLOPE and INTERCEPT give the two numbers; LINEST gives them plus the statistics that tell you how much to trust them. This lesson reads every cell of the LINEST output and shows the one trap that catches almost everyone with several X columns.

SLOPE, INTERCEPT and LINEST — in 30 seconds

What: Simple linear regression fits the straight line y = m·x + b that makes the squared vertical distances from the points as small as possible (least squares). SLOPE returns m, INTERCEPT returns b, and LINEST returns both plus statistics.

Why: It turns a correlation into a usable rule: each extra ₹1,000 of ads goes with about 17.6 more orders, and it predicts y for a new x with a measure of error.

Tiny example: =SLOPE(E2:E21,B2:B21) returns 17.5964 and =INTERCEPT(E2:E21,B2:B21) returns 176.3762. Prediction for AdSpend 12: =FORECAST.LINEAR(12,E2:E21,B2:B21) = 387.53.

First look at the data (before → after):

SLOPE, INTERCEPT and LINEST: before and after tables, fictional Blinkit Maharashtra data

Expected result — LINEST(E2:E21,B2:B21,TRUE,TRUE)

Column 1 Column 2
17.5964 176.3762
2.1182 22.3673
0.7931 29.1826
69.0073 18
58768.51 15329.29
Before table and formula as text

Before — Days (part)

AdSpend (x) Orders (y)
5 301
8 335
6 283
10 381
12 407
… …

Formula / click path

=SLOPE(E2:E21,B2:B21)   =INTERCEPT(E2:E21,B2:B21)
=LINEST(E2:E21,B2:B21,TRUE,TRUE)   (spills 5 rows × 2 columns)
=FORECAST.LINEAR(12,E2:E21,B2:B21)

Do it step by step:

  1. In H2 type =SLOPE(E2:E21,B2:B21) (17.5964) and in H3 =INTERCEPT(E2:E21,B2:B21) (176.3762). Note the order: y first, then x.
  2. In J2 type =LINEST(E2:E21,B2:B21,TRUE,TRUE). A 5 × 2 block spills; the first row is slope and intercept again.
  3. Read R² in the third row (0.7931) and the standard error of y next to it (29.18 orders).
  4. Predict: in H5 type =FORECAST.LINEAR(12,E2:E21,B2:B21) for AdSpend 12. Result 387.53.
  5. Check by hand: =H3+H2*12 gives the same 387.53.
  6. Write the result with its error: "about 388 orders, typically within ±29".

Every cell of LINEST(E2:E21,B2:B21,TRUE,TRUE)

Row Column 1 Value Column 2 Value
1 slope m 17.5964 intercept b 176.3762
2 standard error of m 2.1182 standard error of b 22.3673
3 R² (r²) 0.7931 standard error of y (sey) 29.1826
4 F statistic 69.0073 degrees of freedom (df) 18
5 regression sum of squares 58768.51 residual sum of squares 15329.29

The arguments: LINEST(known_y's, known_x's, const, stats). const TRUE (or omitted) calculates the intercept normally; FALSE forces the line through 0, which is almost never right for business data. stats TRUE adds rows 2 to 5. Without it, LINEST returns only the first row.

Reading it in plain words

  • Slope 17.60: on days with ₹1,000 more ad spend, orders were higher by about 17.60 on average.
  • Intercept 176.38: the line's value at AdSpend 0. It is outside the data (the lowest spend was 5), so do not read it as "orders with no ads".
  • Standard error of the slope 2.12: the slope is 8.31 times its standard error (the t statistic), far above 2, so the link is very unlikely to be chance.
  • R² 0.7931: about 79% of the day-to-day variation in orders goes with ad spend; the rest is other things (discount, rain, chance). For one X column, R² = CORREL² (0.891² = 0.7931).
  • sey 29.18: a typical prediction misses by about 29 orders. Same as =STEYX(E2:E21,B2:B21).
  • F 69.01 with df 18: tests whether the whole line is better than just the average. =F.DIST.RT(69.01,1,18) gives a probability of 1.43E-07, so yes.
  • Sums of squares: regression 58768.51 + residual 15329.29 = total 74097.80. R² = regression ÷ total.

Pick single cells from LINEST. =INDEX(LINEST(E2:E21,B2:B21,TRUE,TRUE),3,1) returns R² alone (0.7931). Microsoft documents =INDEX(LINEST(known_y's,known_x's),1) for the slope and …,2) for the intercept.

TREND gives the fitted line for many x values at once. =TREND(E2:E21,B2:B21) spills the 20 fitted values; =TREND(E2:E21,B2:B21,{10;12;14}) spills predictions for AdSpend 10, 12 and 14: 352.34, 387.53, 422.73.

The trap: several X columns come back in REVERSE order. With three X columns (AdSpend, Discount, Rain in B, C, D):

=LINEST(E2:E21,B2:D21,TRUE,TRUE)

Row Column 1 Column 2 Column 3 Column 4
1 (coefficients) -2.1382 ← Rain 2.9686 ← Discount 11.3239 ← AdSpend 229.2739 ← intercept
2 (standard errors) 0.1911 0.8852 0.9293 7.0492
3 R² 0.9883 sey 7.3466 #N/A #N/A
4 F 452.30 df 16 #N/A #N/A
5 ssreg 73234.25 ssresid 863.55 #N/A #N/A

The first coefficient belongs to the last X column. Microsoft's documentation states the order as {mn, mn-1, …, m1, b}. Label the output by hand every time. Rows 3 to 5 use only two columns; the other cells show #N/A, which is normal. Wrap the formula in IFERROR(…,"") to hide them.

Notice the slope changed. Alone, AdSpend has a slope of 17.60. With Discount and Rain in the model, it is 11.32. On campaign days Amir raised ads and discounts together, so the simple slope gave ads credit for part of the discount effect. Lesson 30.6 reads this three-X model line by line with the ToolPak.

Every number on this page was computed with Excel's documented formulas and re-checked twice: in LibreOffice Calc 25.2 with the same formulas, and in Python with scipy and statsmodels.

Microsoft sources (checked 7 October 2026): LINEST function.

Practice task (try it before you open the answer):

  1. Use SLOPE and INTERCEPT to predict orders for AdSpend 9 (thousand).
  2. What does =INDEX(LINEST(E2:E21,B2:B21,TRUE,TRUE),3,2) return, and what does it mean?
  3. In the three-X LINEST, which cell holds the Discount coefficient?
Answer
  1. =INTERCEPT(E2:E21,B2:B21)+SLOPE(E2:E21,B2:B21)*9 = 334.74, about 335 orders (or =FORECAST.LINEAR(9,E2:E21,B2:B21)).
  2. 29.18: the standard error of the y estimate. A typical prediction misses by about 29 orders.
  3. Row 1, column 2 (2.9686), because the columns come back in reverse order: Rain, Discount, AdSpend, intercept.

Ravindra Bagale's Tip

Type the labels "Rain, Discount, AdSpend, Intercept" above a multi-column LINEST before you read a single number. The reversed order has fooled many experienced analysts.

Loading practice tasks...

  1. Slope (Easy): Slope of orders C2:C9 on spend B2:B9, rounded to 3 decimals.
  2. Intercept (Easy): Intercept of orders C2:C9 on spend B2:B9, rounded to 2 decimals.
  3. R squared (Easy): R squared of C2:C9 on B2:B9, rounded to 3 decimals.
  4. Predict for ₹50k (Medium): Predicted orders for spend B10 with FORECAST.LINEAR, rounded to 0 decimals.
  5. Predict by hand (Medium): Intercept + slope × B10, rounded to 0 decimals.
  6. Fitted value week 3 (Medium): Predicted orders for B4, rounded to 1 decimal.
  7. Residual week 3 (Medium): C4 minus the predicted orders for B4, rounded to 1 decimal.
  8. Spend for 600 orders (Hard): (600 − intercept) ÷ slope, rounded to 1 decimal.
  9. Pune-only average orders (Hard): Average orders where City is "Pune".
  10. Orders per ₹1,000 overall (Hard): Total orders ÷ total spend, rounded to 2 decimals.