Worked examples — R-squared and adjusted R-squared
Before we start, let us re-anchor the four quantities every example below leans on, in plain words, so nothing uses a symbol you have not seen.
Recall The four quantities, in words (click to reveal)
What is ? ::: The plain average of the true values — the number you'd guess if you knew nothing else. What is ? ::: Add up, for every point, how far the true value sits from that average, squared. It measures how spread-out the data is to begin with. What is ? ::: Add up how far each true value sits from the model's guess, squared. It measures the error that is left over after the model tried. What is ? ::: — the fraction of the original spread the model managed to erase.
We square each gap so that a miss of and a miss of both count as badness, never cancelling. The units of every are "(units of ) squared", so when we divide one by another the units cancel and is a pure number — that is why it reads like a percentage.
Where the adjusted "rent" comes from
Before Ex 5, one gap from the parent note deserves filling: why is the penalty factor exactly ?
The scenario matrix
Every question about lives in one of these cells. Each example below is tagged with the cell it fills.
| Cell | What makes it special | Expected behaviour | Example |
|---|---|---|---|
| A. Perfect fit | Ex 1 | ||
| B. Typical good fit | small | Ex 2 | |
| C. Model = mean | Ex 3 | ||
| D. Worse than mean | Ex 4 | ||
| E. Adjusted penalty helps | useless feature added | but | Ex 5 |
| F. Degenerate d.o.f. | collapses | Ex 6 | |
| G. Real-world word problem | pick a model | reasoning + numbers | Ex 7 |
| H. Exam twist | from correlation | (simple reg.) | Ex 8 |
| Z. Degenerate target | undefined | callout above |
Ex 1 — Cell A: the perfect fit
Forecast: guess the answer before reading on. (It is the largest value can take.)
- Mean. . Why this step? The mean is the baseline every compares against — we always need it first.
- Total spread. . Why this step? This is the amount of variation the model is being asked to explain.
- Leftover error. . Why this step? Predictions equal the truth, so every gap is zero.
- Assemble. .
Verify: is the ceiling — it can only happen when , exactly our case. ✓

Ex 2 — Cell B: the typical good fit
Forecast: the errors are small but non-zero, so guess a number close to 1 but below it.
- Mean. . Why this step? The mean is our do-nothing baseline; measures how far past it the model gets.
- Total spread. . Why this step? Records the raw variation before the model helps.
- Leftover error. . Why this step? The squared misses that survive the model.
- Assemble. .
Verify: , and since our errors are tiny compared to the spread, a near-1 value is exactly what we forecast. ✓

Ex 3 — Cell C: model is no better than the mean
Forecast: if the model literally is the mean, how much extra variation did it explain? Guess the floor.
- Mean. . Why this step? We need the baseline first — and here the model happens to equal it, which is the whole point.
- Total spread. .
- Leftover error. . Why this step? Because everywhere, this sum is identical to .
- Assemble. .
Verify: . A model that always guesses the mean is the definition of "explains nothing beyond the baseline". ✓

This is the boundary between error-based metrics and the baseline: any real model must beat this to be worth keeping.
Ex 4 — Cell D: worse than the mean → negative R-squared
Forecast: the predictions are wildly off. Can go below its "floor" of 0? Guess yes or no.
- Mean. . Why this step? We still need the baseline to compare against — even a terrible model is judged relative to the mean.
- Total spread. .
- Leftover error. . Why this step? The model's guesses are far worse than the mean, so its leftover error explodes.
- Assemble. .
Verify: , so , so . Negative is not a bug — it is the metric shouting "you'd have done better predicting the average". This is exactly Common Mistake 3 from the parent note. ✓

Ex 5 — Cell E: adjusted R-squared catches a useless feature
Forecast: rose. Guess whether the adjusted score rose or fell.
Recall the penalty form (derived in the "rent" section above): .
- Before (). . Why this step? We divide the leftover-fraction by the degrees of freedom to charge rent for each parameter.
- Compute: , so .
- After (). . Why this step? One more feature means the denominator shrank from 7 to 6 — the rent went up.
- Compute: , so .
Verify: went (up), but went (down). The adjusted metric correctly flagged the noise feature — this is why we prefer it during Feature Selection. ✓
Ex 6 — Cell F: degenerate degrees of freedom
Forecast: almost as many features as data points. Guess: does stay near 0.99 or crash?
- Degrees of freedom left. . Why this step? This tiny number is the alarm — only 1 "free" data point remains after fitting.
- Apply. . Why this step? Dividing by 1 means the penalty factor 49 is applied at full force.
- Compute: .
Verify: the impressive collapses to . As , the denominator and the penalty balloons — a mathematical signature of Overfitting. If exactly, the denominator hits 0 and is undefined (division by zero). ✓
Ex 7 — Cell G: real-world word problem
Forecast: the predictions look close. Guess an above or below 0.9.
- Mean. dollars. Why this step? Baseline: "just predict the typical day's revenue".
- Total spread. deviations from are . (dollars²). Why this step? Measures how much revenue naturally bounces around.
- Leftover error. (dollars²). Why this step? The revenue the model still misses.
- Assemble. .
Verify: units: dollars²/dollars² cancel → pure number, good. means the model erases about 95.5% of the revenue variation. Above 0.9, as forecast. The owner should still confirm on new days via Cross-Validation before trusting it — training alone never proves generalisation. ✓

Ex 8 — Cell H: exam twist, R-squared from correlation
Forecast: guess the sign of before reading.
- Recall the identity. For simple linear regression, (stated in the parent note). Why this step? This shortcut only holds with one feature — it is the exam's trap to test whether you know that.
- Square it. . Why this step? Squaring destroys the sign — a negative correlation still explains variance.
- Address the misconception. tells you the direction of the relationship; tells you the strength of the fit. A strong negative trend fits just as well as a strong positive one.
Verify: , contradicting the student. A negative never makes negative because we square it. (The shortcut fails for multiple regression — do not carry it over.) ✓

Recall Self-test (click to reveal)
If , what is ? ::: Exactly 0 — the model matched the mean and nothing more. Can ordinary least squares with an intercept give a negative on training data? ::: No — never. With an intercept the fitted line always beats or ties the mean on the training set, so training is guaranteed. Negative needs a dropped intercept, a bad manual model, or held-out test data. Adding a noise feature: does what? does what? ::: stays same or rises; typically falls. What happens to when all are identical? ::: , so the formula divides by zero and is undefined. Simple regression with : ::: .
See also: Bias-Variance Tradeoff, Model Selection, Linear Regression, 2.2.08 R-squared and adjusted R-squared (Hinglish).