2.1.15 · D4Data Preprocessing & Feature Engineering

Exercises — Correlation analysis and multicollinearity

2,944 words13 min readBack to topic

This is your self-test arena for the parent topic. Every problem below has a fully worked solution hidden inside a collapsible callout — read the problem, try it on paper, then reveal. Problems climb five levels:

Before we start, one shared picture. Correlation is geometry: center each feature (subtract its mean) so it becomes a vector of deviations, and then is the cosine of the angle between those two vectors.

Figure — Correlation analysis and multicollinearity

Level 1 — Recognition

L1.1

Given this correlation matrix, which pair of features is perfectly redundant, and which single feature carries independent information?

Recall Solution

What to look for: off-diagonal entries near mean two features are essentially the same vector (angle near or ).

  • → features 1 and 2 are almost perfectly aligned → redundant pair. Keep one, drop the other (see Feature Selection).
  • Feature 3 has — near , so it is nearly orthogonal to both → carries independent information. Answer: redundant pair = ; independent feature = .

L1.2

A feature has . What does that tell you about its relationship to the other features?

Recall Solution

. Setting forces , so . is how well the other features predict . means they predict it not at all is linearly uncorrelated with every other predictor. No inflation of its coefficient's variance.

L1.3

True or false: guarantees and are independent.

Recall Solution

False. measures only the linear (straight-line) part of the relationship — the cosine of the deviation-vectors. Two features can sit on a perfect parabola ( over symmetric ) and have while being fully dependent. means "no linear dependence," not "independent."


Level 2 — Application

L2.1

Compute for , by hand.

Recall Solution

Center them. .

  • , .
  • Dot product: .
  • ; .

L2.2

A regression of on the other features gives . Find and the factor by which the coefficient's standard error inflates.

Recall Solution

Variance inflates by VIF; standard error is , so it inflates by . Reading: VIF sits exactly on the common "severe multicollinearity" threshold. You are about less certain of this coefficient than if were clean.

L2.3

The design matrix has singular values . Find and classify the multicollinearity.

Recall Solution

Rule of thumb: moderate, severe. Here mild/acceptable. See Condition Number.

L2.4

has eigenvalues . Find .

Recall Solution

Singular values of = square roots of eigenvalues of . So Watch the square root — using directly would be , not .


Level 3 — Analysis

L3.1

exactly (an affine transform). Without computing sums, state and justify geometrically.

Recall Solution

Adding the constant shifts but centering subtracts the mean, so the constant vanishes: the deviation vector of is the deviation vector of . A vector and a positive multiple of itself point the same way — angle — so The scale factor is cancelled by the length-normalization in the denominator. (If it were , they'd point opposite → .)

L3.2

Two features have . What is the angle between their deviation-vectors, and what fraction of one feature's variance is "explained" by a straight-line fit to the other?

The figure below is the picture to hold while you solve this — it shows exactly the case: two centered feature-vectors at angle , and the projection of one onto the other, whose squared length is the "explained" fraction .

Figure — Correlation analysis and multicollinearity
Recall Solution
  • Angle: . In the figure, that's the arc between the black and red arrows.
  • Explained variance: projecting the red vector onto the black one keeps only the part of that a straight line from can reproduce. The length of that projection, relative to the full red vector, is ; the variance (length squared) it reproduces is therefore . So , i.e. 36% explained. The remaining is the perpendicular part of the red arrow — genuinely unexplained by the linear fit.

L3.3

A model shows high overall, yet every individual coefficient is statistically insignificant. Diagnose the cause and name the numeric symptom you'd check.

Recall Solution

Diagnosis: multicollinearity. The features together predict well (high ), but because they overlap heavily, the model cannot decide which one deserves credit — so each coefficient has a huge standard error and looks insignificant individually. Symptoms to check: high VIF () on several features, and a large condition number . This is the classic "significant model, insignificant parts" signature.


Level 4 — Synthesis

L4.1

Your dataset has (sqft), (rooms) with , both strong price predictors. Compare three fixes — drop one feature, ridge, PCA — on interpretability and information loss.

Recall Solution
Fix What it does Interpretability Information loss
Drop one Keep sqft, delete rooms High — clean single coef Small (they overlap )
Ridge Add penalty, keep both Medium — coefs shrink & stabilize, but still two knobs None (uses both)
PCA Rotate to orthogonal components Low — "component 1" is a mix of sqft+rooms None, but axes lose plain meaning
Reasoning: ridge fights instability by penalizing large coefficients, trading a little bias for a big variance drop (Variance-Bias Tradeoff) — it keeps both correlated features but tames the exploding . PCA removes collinearity by construction (new axes are orthogonal, so for the retained block) but sacrifices readable coefficients. Dropping is simplest and, at , barely loses information.
Recommendation: for an interpretable pricing model, drop one. For pure prediction accuracy with correlated signals, ridge.

L4.2

Explain why Lasso and Ridge behave differently on a group of highly correlated features.

Recall Solution
  • Ridge ( penalty) tends to spread the coefficient across correlated features, shrinking them together toward similar small values — it keeps the whole group.
  • Lasso ( penalty) tends to pick one feature from the correlated group and zero the rest, doing implicit feature selection — but the choice can be unstable (which one it keeps flips with small data changes, precisely because they're near-identical). Why: the penalty's sharp corners land the solution on an axis (a zero coefficient), while 's round contour never forces exact zeros. Correlation makes the group interchangeable, so Lasso arbitrates arbitrarily.

Level 5 — Mastery

L5.1

Prove that using the Cauchy–Schwarz inequality.

Recall Solution

Let centered deviation-vectors be and . Cauchy–Schwarz states The left side is ; the right side is the denominator of . Dividing both sides by the (positive) right side: Equality () holds exactly when and are proportional, — i.e. , a perfect line. This is the cosine bound: .

L5.2

Derive the VIF formula's role: show that , and explain the limit .

Recall Solution

Where the denominator comes from — no black box. In OLS the coefficient covariance is , and is its -th diagonal entry. The key fact is what that diagonal entry equals, and here is the geometric reason.

Step 1 — split into "explained by others" + "unique." Regress column on all the other feature-columns. This splits into two orthogonal pieces: The residual is, by construction, perpendicular to every other feature — it is the only direction in that no other feature can imitate.

Step 2 — only the unique part can estimate . In multiple regression, is determined entirely by projecting onto that unique residual direction . So its variance depends only on how long is, i.e. on (the residual sum of squares). A standard OLS identity (the Frisch–Waugh result) makes this exact: Intuition: a short residual means has almost no direction of its own → tiny denominator → huge variance. This is the WHY of the blow-up in plain geometry: inverting a near-singular matrix is exactly "dividing by a tiny residual length."

Step 3 — rewrite via . By definition of from that same regression, Step 4 — substitute: Limit. As becomes perfectly predictable from the others, , so and : the variance blows up. Geometrically, the unique residual shrinks to zero length, leaving nothing to estimate its own coefficient with.

L5.3

Show that if features are perfectly orthogonal (all pairwise , columns of orthonormal after centering), then can equal and every .

Recall Solution

Orthonormal centered columns mean (identity). Then:

  • VIF: each is uncorrelated with the others, so regressing on them gives , hence for all .
  • Condition number: eigenvalues of are all , so and is the best possible — a perfectly well-conditioned problem, no error amplification. This is exactly the state PCA engineers (orthogonal components) and what standardizing + decorrelating aims for.

Recall Self-test checklist (reveal after finishing)

Read a correlation matrix for redundancy? ::: L1 ✓ Compute , VIF, from raw numbers? ::: L2 ✓ Explain a high--yet-insignificant model? ::: L3 ✓ Choose drop vs ridge vs PCA by redundancy strength? ::: L4 ✓ Prove the bound and derive VIF? ::: L5 ✓


Connections