Prerequisites: In order to understand the math in this article you should understand OLS projection matrices from this article.
Given the linear model:
We can partition the columns of into and to get:
For clarity, think of as the control variables and as the variables of interest.
Solving the least squares problem with the partitioned representation of the model, we find the normal equations:
From here we find 2 important results from two cases.
Having uncorrelated explanatory variables is equivalent to:
Given this condition, our normal equations are symmetric and independent.
Without loss of generality:
Thus, recovered coefficients are unchanged when uncorrelated regressors are included as controls.
If our variables of interest and controls are correlated, this is equivalent to:
Our normal equations form a system of (two) equations. After some algebra, we get the result
Where the variables with a tilde are partialled out by the control variables.
Therefore, controlling for variables in OLS is equivalent to regressing the residuals of the outcome variable on the residuals of the explanatory variables of interest.
Geometrically, this means that controlling for variables leaves us with a collection of the orthogonal component of the variables of interest as our new basis for the variables of interest. Instead of finding the combination of these vectors that will be in the shadow of , we find the combination of these vectors that will be in the shadow of .
By shadow, I mean the reachable (determined by ) point that minimizes the length of the residual vector that connects to by the relationship .