---
title: "Simple regression in Excel: reading R² and residuals"
description: "How to read R², STEYX, LINEST and residual plots in Excel when analysing ad spend and sales so three common regression traps do not distort budgets."
url: "https://khoi.co.uk/blog/hoi-quy-don-doc-r2-va-phan-du"
lang: en-GB
author: "Le Quoc Khoi"
date: 2026-11-03
updated: 2026-11-26
topics: ["Data & analytics"]
tags: ["Simple regression", "Excel", "Residual analysis", "R²", "Correlation and causation"]
---

# Simple regression in Excel without fooling yourself

## Key takeaways

- Across 12 illustrative retail branches in dataset A, `=SLOPE` outputs 7.59 million VND of revenue per million VND of ad spend, `=RSQ` reaches 0.868 and `=STEYX` shows 39.7 million VND of typical scatter (12 per cent of the 319 million VND mean); `=LINEST` returns all three with standard errors and F-statistics.
- R² measures the share of revenue variance captured by the line while STEYX states typical error in cash terms (James et al., 2021, pp. 69-70); neither warns you when a straight line is fitted across a saturating media curve.
- Simulated datasets B and C post strong R² scores (0.947 and 0.716) despite flawed models: dataset B conceals diminishing marginal paid-media returns, while dataset C hangs on one 90-million-VND flagship branch (hat value 0.92 versus a 0.17 sample mean) (James et al., 2021, pp. 93-99).
- Observational slopes measure co-movement: dataset A has a true ad effect of 1.0, yet simple regression inflates the slope to 7.59 because larger floor plates get bigger ad budgets and earn higher baseline sales (James et al., 2021, p. 74).

When a marketing deck presents 12 retail branches in Excel with `=RSQ` at 0.87 and `=SLOPE` at 7.59 to argue that every extra million VND of paid media brings back 7.6 million VND in sales, I pause before signing off. High R² neither establishes causal ROAS nor flags ad saturation or a single flagship store skewing the fit. Running the four checks in the [simple linear regression workflow](https://khoi.co.uk/framework/simple-regression-workflow) (scatter inspection, `LINEST` standard errors, residual diagnostics and omitted size controls) protects working capital from spreadsheet illusions; pair this with [five questions to ask before trusting a chart](https://khoi.co.uk/blog/nam-cau-hoi-doc-bieu-do).

## Four quick Excel checks to run before trusting a regression slope

Before debating marketing budgets from two summary cells, run four diagnostic checks directly inside the workbook:

| Audit step | Excel formula or chart | Warning sign to halt budget sign-off |
|:--|:--|:--|
| 1. Price the typical miss | Compare `=STEYX(Y_range, X_range)` against store gross margin | High R² paired with a cash scatter wider than branch profit buffer |
| 2. Plot the residuals | Scatter-plot `Residual` against `Spend` | Inverted-U curve showing paid-media saturation at higher spend |
| 3. Flag extreme-X stores | Compute hat value `h_i` per row against `2/n` | One flagship branch at 3–5× average `h_i` tilting the whole slope |
| 4. Control for store scale | Add floor area or footfall into multi-column `=LINEST` | Ad slope collapses once physical store size enters the equation |

Dataset A lists 12 hypothetical retail branches (millions of VND and square metres). Columns one to three show recorded numbers; columns four and five show fitted values from `130.9 + 7.59 × Spend` and vertical residuals:

```
Spend    Revenue   Floor area   Fitted    Residual
    8        233           75    191.7        41.3
   10        217           80    206.8        10.2
   14        194           40    237.2       -43.2
   18        231           60    267.6       -36.6
   19        226           55    275.1       -49.1
   21        339          110    290.3        48.7
   25        308           95    320.7       -12.7
   25        379          150    320.7        58.3
   31        331          120    366.2       -35.2
   34        389          135    389.0         0.0
   43        489          170    457.3        31.7
   50        497          190    510.4       -13.4
```

With `Spend` in `A2:A13` and `Revenue` in `B2:B13`, five standard formulas return:

```
=SLOPE(B2:B13,A2:A13)                    7.59   revenue difference associated with each extra million spent
=INTERCEPT(B2:B13,A2:A13)                130.9  fitted line value at zero advertising spend
=RSQ(B2:B13,A2:A13)                      0.868  share of revenue variance explained
=STEYX(B2:B13,A2:A13)                    39.7   typical residual scatter around the line, million VND
=INDEX(LINEST(B2:B13,A2:A13,1,1),2,1)    0.936  standard error of the slope coefficient
```

Entering `=LINEST(B2:B13,A2:A13,TRUE,TRUE)` outputs a five-row array: slope and intercept on row one, standard errors on row two, R² and STEYX on row three, the F-statistic and degrees of freedom on row four, and regression plus residual sums of squares on row five. Wrapping `INDEX` around `LINEST` extracts individual cells cleanly for management tables.

## What R² = 0.87 and STEYX reveal — and what they hide

In dataset A, `R² = 0.868` indicates that linear spend differences account for 86.8 per cent of revenue variance around the 319.4 million VND branch mean, matching the squared Pearson correlation `=CORREL(A2:A13,B2:B13)^2` in single-variable regression (James et al., 2021, pp. 70-71). Beside it, `STEYX = 39.7` million VND expresses residual error in cash: even if planners knew the true population line exactly, individual branches would still miss predictions by roughly 40 million VND (James et al., 2021, p. 69).

Dividing the `7.59` slope by its `0.936` standard error yields `t = 8.11` on `n − 2 = 10` degrees of freedom (`=T.DIST.2T(8.11,10)` gives `p ≈ 0.00001`), placing the 95 per cent confidence interval at `7.59 ± T.INV.2T(0.05,10) × 0.936`, or `5.50` to `9.68` million VND (James et al., 2021, pp. 66-67). While that tiny p-value rules out pure chance (James et al., 2021, pp. 67-68), acceptable R² levels depend entirely on domain noise: behavioural marketing models below 0.20 can guide profitable targeting, whereas a suspiciously tidy 0.87 across retail stores usually signals an unmeasured scale factor (James et al., 2021, p. 70).

## Why a 7.59 regression slope is not incremental ad ROAS

Least-squares slopes record the average difference in Y accompanying a one-unit difference in X across observed rows, pushing every omitted sales driver into the error term (James et al., 2021, p. 63). Treating `7.59` as marginal ROAS misallocates budget whenever budget rules track store size.

Dataset A was generated from a known equation: `Revenue = 100 + 1.0 × Spend + 1.8 × Floor_Area + Noise (SD 16)`. Because retail chains routinely assign larger ad budgets to bigger premises, spend and floor area carry a `0.87` correlation; regressing sales on spend alone credits floor-space volume to advertising and inflates the true `1.0` lift to `7.59`.

James and colleagues demonstrate the same confounding in media mix records: newspaper ad spend appears profitable in isolation, then collapses near zero once television and radio budgets enter a multiple regression because newspaper bookings rose alongside radio bursts (James et al., 2021, p. 74).

Placing `Floor area` beside `Spend` and running `=LINEST(C2:C13, A2:B13, TRUE, TRUE)` (noting Excel outputs coefficients in reverse column order) pulls the ad slope down to `2.78` (95 per cent confidence band `0.87` to `4.70`, covering the true `1.0`), assigns `1.48` to floor area and lifts R² to `0.977`. Keep prediction separate from causal inference (James et al., 2021, pp. 19-20): regression estimates expected turnover for a new branch of comparable size, whereas measuring true incremental ROAS from a 10 million VND spend top-up requires a controlled pilot with matched holdout stores.

## Catching ad saturation and extreme flagship stores with residuals and hat values

Plotting vertical residuals `eᵢ = yᵢ − ŷᵢ` against X checks whether a straight line fits the underlying response (James et al., 2021, pp. 93-94). Three visual patterns call a halt: a U or inverted-U arc exposing curvature, a funnel shape marking shifting error variance (heteroscedasticity), and consecutive time-ordered points trailing together under autocorrelation (James et al., 2021, pp. 94-96).

Calculate branch residuals in cell `D2` and copy down to `D13`:

```
D2: =B2-(INTERCEPT($B$2:$B$13,$A$2:$A$13)+SLOPE($B$2:$B$13,$A$2:$A$13)*A2)
```

Dataset B simulates 12 weeks of online paid social spend (5 to 60 million VND weekly) governed by saturating demand `420 × (1 − e^(-spend/30))`. Simple linear regression prints `R² = 0.947`, slope `5.29` and `p < 10⁻⁷`, yet the residual row traces a textbook inverted U:

```
Spend:       5  10  15  20  25  30  35  40  45  50  55  60
Revenue:    64 122 163 196 233 257 290 321 322 335 357 366
Residual:  -43 -11   3  10  21  18  25  29   4 -10 -14 -32
```

Deep negative errors at both extremes and positive errors across mid-range spend reflect diminishing marginal returns. Adding a `Spend²` column in two-variable `LINEST` (or transforming X via `log X` or `√X` (James et al., 2021, p. 94)) raises R² to `0.996` and cuts `STEYX` from `23.6` million to `6.5` million VND.

A second distortion comes from high-hat-value points sitting far out along X, distinct from Y-axis outliers (James et al., 2021, pp. 97-98). Single-predictor hat values follow `hᵢ = 1/n + (xᵢ − x̄)² / Σ(xⱼ − x̄)²`, averaging `(p + 1)/n = 2/12 = 0.167` (James et al., 2021, p. 99), calculated in Excel as:

```
E2: =1/COUNT($A$2:$A$13)+(A2-AVERAGE($A$2:$A$13))^2/DEVSQ($A$2:$A$13)
```

In dataset A, branch 12 (spend 50 million VND) posts `h = 0.435` while staying close to the trend (residual `−13.4`). Dataset C pairs 11 neighbourhood shops spending 8 to 28 million VND (random sales 178 to 274 million VND) with one city-centre flagship spending 90 million VND and taking 430 million VND:

```
Spend:       8  10  12  14  15  17  19  21  24  26  28  90
Revenue:   231 268 264 216 222 215 246 228 251 178 274 430
```

| Regression run on dataset C | R² | Slope coefficient | Slope p-value | Standard error STEYX |
|:--|--:|--:|--:|--:|
| All 12 branches pooled | 0.716 | 2.42 | 0.0005 | 34.8 |
| Dropping the 90m VND flagship | 0.016 | −0.55 | 0.71 | 29.7 |

At `h = 0.924` (over five times the sample mean), the flagship pulls the fitted line almost through itself, leaving a modest `+17.8` million VND residual at that store compared with `−79.6` million VND elsewhere (James et al., 2021, pp. 98-99). My standing rule when reviewing branch performance sheets is non-negotiable: print `=SLOPE` and `=RSQ` both with and without any high-hat-value flagship on the same page before touching media allocations.

## Extrapolation risk outside observed spend and Gauss-Markov boundaries

Safe revenue planning stays inside observed spend bounds (8 to 50 million VND in dataset A) and uses prediction intervals when setting single-store targets. In Excel, the 95 per cent prediction interval at spend `x0` is:

```
=FORECAST(x0,B2:B13,A2:A13) ± T.INV.2T(0.05,10)*STEYX(B2:B13,A2:A13)*SQRT(1+1/COUNT(A2:A13)+(x0-AVERAGE(A2:A13))^2/DEVSQ(A2:A13))
```

At `x0 = 30` million VND in dataset A, `=FORECAST` returns `358.6` million VND; the 95 per cent confidence band for the chain average spans `±27.7` million VND (`[330.9, 386.3]`), whereas the single-branch prediction band widens more than threefold to `±92.8` million VND (`[265.9, 451.4]`) (James et al., 2021, p. 82). Likewise, the `130.9` million VND zero-spend intercept sits below every observed store and cannot tell management what revenue would survive a total ad freeze.

Dataset B shows the cash cost of extrapolating past historical ceilings: pushing spend to 80 million and 100 million VND yields linear promises of `504` million and `609` million VND, while true demand stalls at `391` million and `405` million VND beneath its `420` million VND cap. Historical `R² = 0.947` gives zero warning of that shortfall.

Diagnostic formulas and statistical bounds throughout this guide follow Chapter 3 of Gareth James, Daniela Witten, Trevor Hastie and Robert Tibshirani (2021, 2nd edition, *An Introduction to Statistical Learning with Applications in R*) alongside Microsoft's technical specification for `LINEST`. Keep in mind that textbook `t`-tests, `F`-tests and prediction bands assume correct linear form and Gauss-Markov conditions of constant variance, independent observations and approximately normal errors (James et al., 2021, pp. 82, 93-96).

## Frequently asked questions

### When is SLOPE enough and when should analysts switch to LINEST in Excel?

On clean single-predictor data, both return the exact same 7.59 slope in dataset A. LINEST adds standard errors, R², the F-statistic and degrees of freedom in one array, and handles collinear multi-predictor tables via QR decomposition where SLOPE cannot.

### Should managers delete outliers to clean up R² before a budget review?

Delete an observation only after source records confirm a typing or logging mistake (James et al., 2021, p. 98). Extreme stores usually point to an omitted operational driver such as floor area or footfall, so report regression lines both with and without the unusual branch.

### Should single-store revenue targets use a confidence interval or a prediction interval?

Always use the prediction interval for an individual store. Confidence intervals bound the chain-wide mean at a given spend, whereas prediction intervals include single-site scatter and run far wider (James et al., 2021, p. 82): at 30 million VND spend in dataset A, the 95 per cent prediction half-width is 92.8 million VND versus 27.7 million VND for the confidence band.

### Can simple regression run directly on twelve consecutive months of ad spend and revenue?

Excel will print coefficients, yet adjacent monthly errors commonly track one another and depress standard errors artificially (James et al., 2021, p. 94). Narrower intervals and inflated t-statistics then tempt overspending; plot residuals in calendar order first and see seasonal forecasting in Excel .

## References

- James, G. et al. (2021) *An introduction to statistical learning: with applications in R (2nd edn)*. New York: Springer. https://doi.org/10.1007/978-1-0716-1418-1

---

Canonical HTML version: https://khoi.co.uk/blog/hoi-quy-don-doc-r2-va-phan-du

> A personal blog by Le Quoc Khoi, not affiliated with, sponsored or reviewed by the University of Greenwich. “Greenwich” and “University of Greenwich” are names belonging to their respective owners. No copyrighted study materials are published here; theory and cases are retold in the author's own words and may not be fully accurate, so check the original sources.
