2.2.8 · D5Linear & Logistic Regression

Question bank — R-squared and adjusted R-squared

1,477 words7 min readBack to topic

Two quick reminders so every symbol below is earned:

  • — how badly your predictions miss the true values (leftover error).
  • — how spread out the data is around its mean (the baseline "predict the average" error).
  • , and with = data points, = number of predictors.

True or false — justify

A high guarantees the model predicts well on new, unseen data.
False. scores fit on the data the model already saw; a model can memorize training noise, giving high yet failing on new data — this is Overfitting. Only held-out Cross-Validation tests generalization.
means the model is completely random and useless.
Roughly true in effect but precise reason matters: means , i.e. the model does exactly as well as always predicting the mean — no better, no worse, not "random noise".
can never be negative.
False. If the model is worse than predicting the mean (e.g. regression forced through the origin, or a badly misspecified model), then and .
Adding any new feature can never decrease the training .
True. The optimizer can always set the new coefficient to 0 and recover the old fit, so can only stay the same or shrink — is non-decreasing in on training data.
Adding a new feature can never decrease adjusted .
False. carries the penalty factor that grows with ; a weak feature raises without shrinking enough, so drops. That's the whole point of the adjustment.
For simple linear regression, equals the square of the Pearson correlation .
True for one predictor with an intercept: . This does NOT extend to multiple regression, where is the squared correlation between and , not between and any single .
is always less than or equal to .
True whenever , because the penalty factor multiplies the non-negative quantity , pulling down (they're equal only when or ).
A model with is always better than one with .
False. If the two models were fit on different datasets, or the 0.98 model used far more features and overfit, the comparison is meaningless. only compares models on the same target and data, and even then Overfitting can inflate it.

Spot the error

"My went from 0.80 to 0.85 after adding 10 features, so the model definitely improved."
The error: training cannot decrease when features are added, so an increase is expected regardless of whether the features help. Check or cross-validated error — the rise may be pure Overfitting.
" with 48 features and 50 data points — an excellent model."
The error: only degree of freedom remains, so the model is fitting noise. collapses to about 0.51 here, exposing the disaster that raw hid.
"I removed the intercept to simplify the model, and now is negative — must be a code bug."
Not a bug. Forcing the line through the origin when the data has a nonzero mean makes predictions worse than the mean baseline, so and legitimately goes negative.
" tells me how much of the variance in my model explains."
The error: explains variance in the target (via ), not in the inputs . The predictors are the tools, not the thing being explained.
"To pick the best subset of features, I'll just choose whichever gives the highest ."
The error: highest always means "use every feature," so this rule never removes anything. Use , cross-validated score, or proper Feature Selection / Model Selection criteria instead.
" can also be interpreted directly as a proportion of variance explained."
The error: unlike , is an adjusted comparison of variance estimates and has no clean "percent explained" meaning — it can even go negative for tiny samples with many predictors.

Why questions

Why do we compare against the mean specifically, and not zero?
The mean is the best constant predictor when you know nothing about — it minimizes squared error among all constants. So is the "informed baseline," making a fair measure of how much the model beats knowing nothing.
Why does always increase (or stay flat) as you add features, mathematically?
The least-squares fit minimizes over more parameters; the old solution is still available (set new coefficients to 0), so the new minimum can only be the old one. Smaller forces larger .
Why divide by instead of just in the adjusted formula?
Each estimated parameter (intercept + slopes) "uses up" a degree of freedom, so is the unbiased variance estimate. Using is exactly what injects the complexity penalty.
Why does the penalty factor get harsher when is small?
With few data points, each added predictor eats a larger fraction of the available degrees of freedom, so shrinks fast and the factor balloons — small samples punish extra features much more, discouraging Overfitting.
Why is alone not a good tool for Feature Selection?
Because it monotonically rewards more features, it can't tell a helpful feature from a noisy one. You need a criterion that trades fit against complexity — , AIC/BIC, or Cross-Validation error.
Why does a high training sometimes signal high variance in the Bias-Variance Tradeoff sense?
A very flexible model can drive near zero on training data (high ) by chasing noise, which is exactly the high-variance regime — great train fit, poor test performance.
Why does hold for simple regression but break for multiple regression?
With one predictor, the fitted line's explained variance equals the squared linear correlation between and . With many predictors there's no single to correlate with; becomes the squared correlation between and the combined prediction .

Edge cases

What is when the model predicts perfectly ( for all )?
, so — the maximum. Every wiggle in is accounted for.
What is when every prediction equals the mean ()?
, so . The model has learned nothing beyond the baseline.
What happens to when (only an intercept, no predictors)?
The factor , so . With no features to penalize, the two metrics coincide.
What happens to the adjusted formula as (features approach data points)?
The denominator , so the penalty factor blows up toward infinity and . This is the math screaming that you have too many features for your data.
If two variables are perfectly correlated with the target and you include both, what breaks?
The design becomes (near-)singular — infinitely many coefficient combinations give the same fit, so is well-defined but individual coefficients are not. This is why collinearity matters even when looks fine; see Feature Selection.
What does mean if the target is constant (all equal)?
Then and is undefined. There's no variance to explain, so has no meaning — the metric assumes the target actually varies.
Recall Self-check before moving on

One-line summary of the whole page ::: measures training fit and always rewards more features; penalizes complexity so it can fall — but neither replaces Cross-Validation for judging real predictive power.