Lawfare Academy

Regression Analysis for Business · Chapter 2 of 8

OLS as projection, normal equations and partial regression

Return to the linked course unit →

DEVELOPED COURSE TEXT

OLS as projection, normal equations and partial regression

Derive the criterion and its geometry

Write the regression as y=X beta+e, where y is the 24-row development outcome vector and X has five columns. Ordinary least squares chooses beta to minimize the sum of squared residuals, (y-X beta) transposed times (y-X beta). Differentiating gives the normal equations X transposed X beta=X transposed y. If the columns are linearly independent, the formal solution is beta-hat=(X transposed X) inverse X transposed y. This expression explains the estimator; a numerical implementation should use a stable least-squares solver rather than explicitly invert a poorly conditioned matrix merely to fit coefficients.
The fitted vector is the orthogonal projection of y onto the column space of X. Consequently X transposed e-hat is zero up to floating-point error. With an intercept, residuals sum to zero and fitted values have the same sample mean as y. These identities hold algebraically even when the model has omitted variables or serially dependent errors. Residual orthogonality to included regressors therefore does not prove exogeneity or causal identification.

Interpret a coefficient through residualization

The Frisch–Waugh–Lovell argument gives a precise meaning to holding the other included variables fixed. Regress price on the intercept, advertising, promotion and month, and retain the residual price variation. Separately regress sales on those same controls and retain residual sales. The slope from residual sales on residual price equals the price coefficient in the full baseline model. This is a sample projection identity. It is not the same as finding otherwise identical customers or randomly assigning prices.
The derivation follows by removing the component of both variables in the controls' column space. If M_Z is the residual-maker for controls Z, the price coefficient is (p transposed M_Z p) inverse p transposed M_Z y. If M_Z p is nearly zero, price has little variation left after the controls and the estimate becomes imprecise. If it is exactly zero, the coefficient is unidentified because price is a linear combination of the other columns. More rows do not fix exact collinearity unless they add independent variation.

Read the fitted baseline in the original units

The output table reports the actual computed coefficients and three uncertainty calculations. The baseline price coefficient is about -1.417 hundreds of sales units per dollar, conditional on the included advertising, promotion and month columns. The advertising coefficient is about 2.464 hundreds per additional thousand dollars. The promotion coefficient is an adjusted level difference under this additive specification, not a percentage effect. The month coefficient is a linear trend conditional on the other variables.
The intercept predicts sales at zero price, zero advertising, no promotion and month zero. Those conditions are outside much of the observed domain, so its business interpretation is limited even though including it is important for fitting. Centering price or time changes the intercept's reference point without changing fitted values when the same model space is retained. A numerical coefficient should always travel with its variable definition, units, conditioning set and estimation window.

Distinguish fit quality from a valid response model

The baseline development R squared is about .913. This describes the fraction of centered in-sample sales variation explained by the fitted projection. It does not establish a causal price response, guarantee future accuracy or prove that the residual process satisfies a probability model. Adding a regressor cannot increase the least-squares residual sum of squares on the same rows, because the old model remains feasible with the new coefficient set to zero. Better training fit alone therefore cannot justify a richer specification.
Compare the residual vector, rank and singular values as well as coefficients. A rescaling of price from dollars to cents rescales its coefficient but leaves fitted values unchanged. In contrast, deleting the time trend changes the model space and can alter other coefficients. These operations answer different questions. The advanced analyst should be able to explain the projection, reproduce the fit and identify which changes are mere reparameterizations versus substantive specification revisions.

Worked records

Record 1

Fit baseline X=[1,price,advertising,promotion,month] on months 1–24.

TermEstimateConventional SEHC3 SEHAC(2) SE
Intercept81.2442968.4435148.8126386.406515
Price-1.4169080.3480110.3750500.311185
Advertising2.4643140.3972080.3094860.192137
Promotion6.8594571.2783511.6826121.262919
Month0.8589600.0921640.1041560.075177

Develop the reasoning

Computed coefficients are 81.244296, -1.416908, 2.464314, 6.859457, 0.858960. The script verifies that the norm of X transposed residual is below 1e-7. Full rank is 5; development RMSE is 2.370446 and R squared is 0.912751. These are numerical properties of the fitted record, not tests of a causal design.

Progressive practice — optional

1. Foundation

What normal-equation identity should fitted residuals satisfy?

Compare the worked reasoning

X transposed e-hat is zero up to numerical error; with an intercept residuals sum to zero.

Change the record

Errors are serially correlated.

Compare the changed-record reasoning

The algebraic identity still holds. Serial dependence affects uncertainty and model interpretation, not the least-squares first-order identity.

2. Application

Interpret a price coefficient of -1.416908 in the recorded units.

Compare the worked reasoning

One additional dollar is associated with 1.416908 fewer hundreds of sales units conditional on the included columns.

Change the record

Price is recorded in cents instead.

Compare the changed-record reasoning

The coefficient becomes -0.01416908 hundreds per cent; a 100-cent change gives the same fitted sales change.

3. Transfer

Does residualizing price on observed controls remove all confounding?

Compare the worked reasoning

No. It removes only linear projection on those included controls.

Change the record

Latent demand affects both price and sales.

Compare the changed-record reasoning

Residualized price can remain correlated with latent demand, so the coefficient can retain omitted-variable bias even though the FWL identity and residual orthogonality hold.

Sources and scope