2.1.15 · D1Data Preprocessing & Feature Engineering

Foundations — Correlation analysis and multicollinearity

2,709 words12 min readBack to topic

Before we can measure overlap, we need to be fluent in every symbol the parent note throws at us. This page builds each one from nothing, in an order where every symbol is earned before it is used. Nothing here assumes you have seen statistics before.


0. What is a "feature"? (the raw material)

Everything starts with a table of numbers. Each row is one sample (one house, one patient, one photo). Each column is one feature — one measured quantity, like square footage.

Figure — Correlation analysis and multicollinearity

Look at the figure: the column of blue dots is the feature . Each dot is one . The subscript is just a pointer that says "which row" — means "the value in row 3". We need this pointer because every formula in the topic is a recipe applied to every row and then summed up.


1. The mean — the balance point

Before we can talk about "above average" or "below average", we need the average itself.

The symbol (Greek capital sigma) is just shorthand for "add these up". The bits around it are instructions:

Figure — Correlation analysis and multicollinearity

In the figure, is the horizontal line where the column would balance like a see-saw. Why the topic needs it: every measure of relationship asks "is this point above or below its own average?" — so the average is the reference line we measure from.


2. Deviation — distance from the balance point

This single quantity carries the sign that everything downstream depends on:

  • → the sample is above average.
  • → the sample is below average.
  • → the sample sits exactly on the average line.

Why the topic needs it: correlation is built from pairs of deviations. When we ask "do and move together?", we really ask "when is above its line, is also above its line?" — that is a statement about the signs of two deviations.


3. Variance and standard deviation — "room to vary"

We now measure how spread out a feature is.

The symbol is Greek small sigma. Why the topic needs it: correlation divides by to cancel units. Without , correlation would depend on whether you measured area in sqft or m², which would be nonsense.


4. Covariance — do two features move together?

Now we bring in a second feature (its values , mean ).

Figure — Correlation analysis and multicollinearity

Read the figure quadrant by quadrant (the crossing lines are vertical, horizontal):

  • Top-right (both above average): → pushes covariance up.
  • Bottom-left (both below average): → also pushes up.
  • Top-left / bottom-right (one above, one below): → pulls covariance down.

So covariance is positive when points cluster on the diagonal (move together), negative when they cluster on the anti-diagonal (move oppositely), and near zero when they scatter into all four quadrants equally.

Why the topic needs covariance: it is the raw "co-movement" number. But its size depends on units, so we normalise it next. Stacking every pairwise covariance into a grid gives the covariance matrix, which we notate and connect to in Section 6.


5. Correlation — covariance made unit-free

  • : perfect straight line sloping up.
  • : perfect straight line sloping down.
  • : no linear pattern (points may still form a curve!).

The reason the value can never escape is the Cauchy–Schwarz inequality, which guarantees . You do not need to prove it here — just know it is the mathematical fence that bounds .


6. Symbols for the regression machinery

The multicollinearity half of the topic lives inside linear regression. First, one indexing convention we will lean on throughout this section.

This feeds the Variance Inflation Factor: . As , the denominator and VIF .

Figure — Correlation analysis and multicollinearity

In the figure, the transpose simply flips the table across its diagonal: the entry in row , column of lands in row , column of . Nothing is invented or lost — the numbers are just relabelled by position.


Prerequisite map

samples and features Xi

mean x-bar

deviation xi minus mean

variance and std dev sigma

covariance Cov XY

correlation r

Correlation analysis

design matrix and X-T-X

condition number kappa

R-squared and VIF

Multicollinearity topic 2.1.15

Each arrow means "you must understand the tail before the head makes sense." Correlation needs both variance and covariance; multicollinearity needs correlation plus the matrix picture.


Equipment checklist

Test yourself — reveal only after answering out loud.

What does the subscript in point to?
The row number — which sample the value comes from.
What does the summation symbol tell you to do?
Add up the expression for every row from to .
Why do we compute before anything else?
It tells us, with a sign, whether a sample is above () or below () its own average — the raw ingredient of co-movement.
Why do we square deviations to get variance?
Raw deviations always sum to zero (they cancel); squaring makes them all positive so spread is measured, not cancelled.
Does it matter whether variance uses or when computing correlation ?
No — the factor appears in top and bottom of the fraction and cancels; it only changes the raw variance/covariance numbers.
What happens to correlation if a feature has zero variance?
It is undefined — you would divide by ; drop constant columns first.
What does represent in a picture?
The typical distance of the points from the mean line — the feature's "room to vary".
When is positive?
When the two features tend to be above/below their means together (points cluster on the rising diagonal).
Why divide covariance by to get ?
To cancel units and bound the result to , making feature pairs comparable.
Does mean the features are unrelated?
No — it only means no straight-line relationship; a curved relationship can still give .
What is the difference between the indices and ?
counts rows/samples (up to ); counts columns/features (up to ).
What does the hat in mean?
"Our data-based estimate of", as opposed to the unknown true value .
What is the target vector ?
The column of answers we are trying to predict — one number per row.
What is the formula for and what does it measure?
; the fraction of feature 's spread the other features can explain (0 = independent, near 1 = redundant).
How does relate to the covariance matrix ?
With mean-centred columns, — the same grid of pairwise covariances up to the factor .
How is the condition number computed?
As , the ratio of largest to smallest singular value of (equivalently of ).
What does the plain mean versus the bold ?
Plain is a single feature column; bold is the whole table (design matrix); is that table transposed.

See also: Feature Selection, Principal Component Analysis (PCA), Ridge Regression, Lasso Regression, Linear Regression Assumptions, Variance-Bias Tradeoff, Condition Number, and the parent 2.1.15 Correlation analysis and multicollinearity (Hinglish).