2.1.15 · D3Data Preprocessing & Feature Engineering

Worked examples — Correlation analysis and multicollinearity

3,024 words14 min readBack to topic

This page is the drill floor for Correlation Analysis and Multicollinearity. We take every situation the topic can hand you — perfect positive, perfect negative, zero, degenerate (constant) features, a real word problem, and an exam trap — and grind each one to a checked number.

Nothing here uses a symbol you have not met. But a handful of symbols do a lot of work, so let us pin them down before the first example, in plain words.

The figure below draws this for five dots. The dashed lavender lines are the two averages and ; they split the plane into four boxes. Green dots sit in an "agree" box (both above average, or both below) and add a positive product; coral dots sit in a "disagree" box and add a negative product. Correlation is the running total of these green-minus-coral contributions, then rescaled to land in .

Figure — Correlation analysis and multicollinearity

The scenario matrix

Every problem this topic throws lives in one of these cells. The examples that follow are labelled with the cell they cover.

Cell Scenario class What makes it tricky Covered by
A Perfect positive () Scaled copy of a feature Ex 1
B Perfect negative () Reflected copy — sign of numerator flips Ex 2
C Genuinely zero () Numerator cancels; watch for nonlinear traps Ex 3
D Partial / mixed sign Real messy data, $0< r
E Degenerate input A constant feature → division by zero Ex 5
F Limiting behaviour so Ex 6
G Real-world word problem Translate business words → numbers Ex 7
H Exam twist High individual but a hidden third feature; condition number Ex 8

The master recipe (used in every numeric example)


Example 1 — Cell A: Perfect positive correlation


Example 2 — Cell B: Perfect negative correlation

The figure below shows the two extremes side by side: on the left the perfect up-slope (), on the right the perfect down-slope (). Every dot lies exactly on the lavender line, which is what "perfect" means — no wobble at all.

Figure — Correlation analysis and multicollinearity

Example 3 — Cell C: Genuine zero (and the nonlinear trap)


Example 4 — Cell D: Partial / mixed correlation


Example 5 — Cell E: Degenerate input (a constant feature)


Example 6 — Cell F: Limiting behaviour of VIF

Before the numbers, we owe two definitions this example depends on.

The figure plots the VIF curve. Notice how flat it is on the left (VIF barely above for up to about ) and how it rockets upward near the right wall — the coral line marks the "severe" cutoff, and both green dots sit far above it.

Figure — Correlation analysis and multicollinearity

Example 7 — Cell G: Real-world word problem


Example 8 — Cell H: Exam twist (hidden collinearity + condition number)

This example uses two new words. Let us earn them first.

The figure draws and as arrows: they point in exactly the same direction (just different lengths), so the data cloud is a flat line — the visual meaning of .

Figure — Correlation analysis and multicollinearity

Recall

Recall Which cell of the matrix does each result live in?

from a scaled copy () ::: Cell A (perfect positive) from a reflected feature () ::: Cell B (perfect negative) but (nonlinear) ::: Cell C (linear-only blindness) , a strong-but-imperfect real link ::: Cell D (partial / mixed) A constant column giving undefined ::: Cell E (degenerate, ) as ::: Cell F (limiting behaviour) A perfect café temperature-vs-sales line () ::: Cell G (real-world word problem) Dropping one collinear feature still leaves , ::: Cell H (hidden collinearity)

Recall What does

mean physically? The factor by which a coefficient's standard error is inflated ::: e.g. less certain about that effect.

Recall Why does dropping one of three perfectly collinear features not always fix multicollinearity?

Because the survivor may still be a scaled copy of the one you kept ::: e.g. , so and persist — you must keep exactly one.