Interactive statistics

56 free interactive lessons: from mean and median to A/B tests and Bayes. Drag the charts and build intuition. No sign-up.

Module 7: Relationships & regression

Multiple regression and controlling for variables

Simple regression looks at the relationship of x and y alone — and is therefore easily fooled. The analyst's real workhorse is multiple regression: it estimates the effect of x while holding other factors constant. This is where the practical answer to "correlation ≠ causation" lives.

x →
● z = 0● z = 1pooled slope (no control): 0.76

Set the true effect to 0 and crank up the confounder strength: the pooled red line will show a "relationship" that isn’t there. Controlling for z (within-group lines) removes it. That is what multiple regression does — estimates the effect of x while holding z constant.

Before you are two groups of points by a hidden factor z (gray — z=0, teal — z=1). There is no control right now: the red line is the pooled regression of y on x. It goes up — as if x strongly affected y.

What it means

Multiple regression is the analyst's most frequent tool after descriptive statistics. "Does tenure affect salary once role and city are accounted for?", "the effect of a promo on revenue controlling for season and channel" — these are all coefficients, all else equal.

Its main strength and main danger are one and the same: what exactly you put in the model. Forgot an important confounder — the effect is distorted; included the wrong thing (see the collider in the next lesson) — also distorted. So the set of controls is chosen by the logic of the problem, not "everything in".

Where it shows up

Econometrics and the social sciences rest almost entirely on multiple regression: estimate the effect of education on income holding age, gender, region constant.

In product work — estimate a feature's contribution to retention controlling for account age and platform, when a clean A/B on that feature is impossible.

Definitions
Multiple regressiony = b₀ + b₁x + b₂z + …
a regression on several predictors at once; estimates each one's contribution with the rest fixed.
Controlling for a variable
include a factor in the model (or compare at equal values of it) to remove its influence from the effect estimate.
All else equal (ceteris paribus)
how a coefficient reads: the effect of one predictor with the rest held fixed.
Confounder
a factor that affects both x and y, thereby creating a spurious relationship between them.
When the method lies (assumptions)

The "all else equal" coefficient is honest only if the right confounders are in the model and the relationship is roughly linear. An omitted important factor biases the estimate (omitted variable bias).

Strongly correlated predictors (multicollinearity) make individual coefficients unstable. And controlling does not turn observational data into an experiment — the risk of unaccounted factors remains.

Next →
Enjoying the materials?

This site is built by the DataSlice Telegram channel: data analytics in plain words — real cases, metrics, careers. The channel is in Russian.

Open the Telegram channel