2.2.2 · D5Linear & Logistic Regression

Question bank — Multiple linear regression

2,141 words10 min readBack to topic

This deck attacks the ideas behind multiple linear regression, not the arithmetic. Read the prompt, say your answer out loud with a reason, then reveal. If your answer was "yes/no" with no because, count it wrong — every trap here is about the why.


Symbols and pictures this deck assumes

Before the traps, let us pin down every symbol and give each key idea one picture, so the deck is self-contained. Nothing below is used later without appearing here first.

Figure — Multiple linear regression
Figure — Multiple linear regression
Figure — Multiple linear regression

True or false — justify

True or false: the "linear" in multiple linear regression means the relationship between features and target must be a straight line.
False. "Linear" means linear in the coefficients — the model is a weighted sum of the 's. You can feed it or as features (that's Polynomial Regression) and it is still a linear model.
True or false: adding more features to the model can never increase the training MSE.
True. Extra features can only be given coefficient , which reproduces the smaller model, so the best fit never gets worse on training data. This is exactly why training error is a bad guide to feature choice — it invites Overfitting.
True or false: if is invertible, the Normal Equation gives the unique global minimum of the MSE.
True. The Hessian of is ; when is invertible it is positive definite, so the cost bowl curves up in every direction (strictly convex) and its single stationary point is the global minimum.
True or false: scaling one feature from metres to centimetres changes the model's predictions.
False. The coefficient simply rescales by the inverse factor ( shrinks by if grows by ), so and therefore are unchanged. Scaling matters for Gradient Descent speed (it makes the bowl round rather than a stretched ellipse) and for Ridge Regression penalties, not for the fitted predictions of ordinary least squares.
True or false: a coefficient tells you the effect of feature in isolation.
False. It tells you the effect of holding all other features fixed. Because features are correlated in real data, that "all else equal" world may never actually occur, so the coefficient is a conditional effect, not a marginal one.
True or false: if two features are perfectly correlated, the model is useless.
False for prediction, true for interpretation. Perfect collinearity makes singular (the flat-floored trench above) so individual coefficients are unidentifiable, but the fitted plane and its predictions can still be fine (a pseudoinverse or Ridge Regression recovers a usable ).
True or false: a negative intercept signals a bug in the fit.
False. is only "the prediction when all features are zero." If all-zero is far outside your data (e.g. a house of sq ft), that point is a meaningless extrapolation and its sign carries no physical meaning.
True or false: a high guarantees the model will predict well on new data.
False. measures fit on the data you already have; it never decreases as you add features. Good out-of-sample behaviour needs a validation set, and adjusted $R^2$ partially penalises the free-parameter inflation.

Spot the error

Spot the error: "We have examples and features, so we'll just use the Normal Equation ."
With examples fewer than features, (size with the bias column) has rank at most , so it is singular and cannot be inverted. Use regularization, a pseudoinverse, or drop features.
Spot the error: "MSE has a minimum, so I take and set it to zero — but I only did this for , and got the answer."
Recall is the MSE. The minimum requires the gradient to be zero in every direction at once. Setting only one partial to zero solves for one coefficient given the others; you must solve the whole system simultaneously.
Spot the error: " where has no leading column of ones — the intercept is inside anyway."
Without the ones column there is no feature to multiply by, so the model is forced through the origin ( when all ). The ones column is precisely what turns the intercept into "just another coefficient."
Spot the error: "I standardised my target but not my features before running least squares, to make the coefficients comparable."
For ordinary least squares this mixes two different fixes. Coefficient comparability comes from scaling the features; scaling alone just rescales all coefficients together. Feature scaling (Feature Scaling) is what puts on a common footing.
Spot the error: "Since , its gradient is , and I then solve ."
Two errors. First, because carries the , the true gradient is — dropping the is wrong (it happens not to change the root since we set it to zero, but the stated formula is still incorrect). Second, you cannot "divide" by a matrix: setting the gradient to zero gives , whose solution needs the inverse , not scalar division.
Spot the error: "The gradient came out as , so I set the to zero to find the minimum."
The constant factor is never zero (it just scales the gradient); you set the vector part to zero, which yields the Normal Equation.
Spot the error: " and are different terms, so the expansion has four distinct terms."
Both are scalars, and a scalar equals its own transpose, so . They combine into the single term.

Why questions

Why do we minimise the sum of squared errors instead of the sum of absolute errors?
Squaring makes the cost smooth and differentiable everywhere, giving a clean closed-form gradient and a single convex bowl; it also penalises large misses disproportionately. Absolute error is non-differentiable at zero and has no neat Normal Equation.
Why does adding to (Ridge) rescue a singular problem?
For any eigenvector with , we get , so every eigenvalue rises by exactly (the penalty strength). A zero eigenvalue (the flat trench floor) becomes , so the matrix turns strictly positive definite and hence invertible. See Ridge Regression.
Why is guaranteed to be symmetric?
Because . Symmetry is what lets us use the matrix-calculus rule .
Why might we prefer Gradient Descent over the Normal Equation even when is invertible?
Gradient Descent rolls downhill on the cost bowl step by step instead of inverting a matrix. Inverting an matrix costs roughly , brutal for thousands of features; gradient descent scales far better and streams over data, at the price of choosing a learning rate and iterating.
Why does the Normal Equation involve rather than just ?
collects, for each feature, the dot product of that feature's column with the target — i.e. "how strongly does this feature co-vary with ." That is the quantity the optimal weights must match.
Why can the same data give a positive simple-regression slope for a feature but a negative coefficient in the multiple model?
Because the multiple model holds other correlated features constant. A confounder can create a spurious marginal trend that reverses once its influence is removed — a form of Simpson's paradox; compare with Simple Linear Regression.

Edge cases

What happens if you fit the model with exactly examples (one per coefficient) and all points are in "general position"?
The plane passes through every point with zero residual — the system is exactly determined. Training MSE is , but this tells you nothing about generalisation; it is the boundary just before over-determination.
What does the Normal Equation output if you accidentally include a feature that is constant (same value for every example)?
That column is a multiple of the ones column, creating perfect collinearity, so becomes singular and the plain inverse fails. Drop the constant feature or use a pseudoinverse.
What is the model's prediction structure when you have only the intercept (no features at all)?
With just the ones column, least squares sets to the mean of , so for every input. This is the baseline that compares against.
If two features are strongly (but not perfectly) collinear, does the Normal Equation still run?
Yes — is technically invertible, but nearly singular (a nearly flat trench), so the inverse has huge entries and coefficients become wildly unstable to tiny data changes. Predictions may still be okay while interpretations are worthless; regularisation stabilises it.
What happens to the coefficients if you duplicate an entire column of ?
Perfect collinearity again: the two identical features are indistinguishable, so infinitely many pairs with a fixed sum fit equally well. is singular; only the combined effect is identifiable.
Recall One-line self-test

The single most common trap ::: " is the effect of " — always add "holding the other features constant," and remember it may be conditional on a world your data never actually contains.