Math for Causal Inference
All simulators

The Gradient of the Sum of Squares

Click anywhere on the SSR surface to see −∇S = 2X′(y − Xβ) point downhill toward the OLS estimate.

Day 24: Matrix Calculus & Gradients
-101230.511.5β₀ (intercept)β₁ (slope)
β (your point)
(2.50, 0.400)
S(β)
8.100
minimum 0.111
∇S = −2X′(y − Xβ)
(-7.20, -45.40)
OLS β̂
(1.080, 0.977)
∇S = 0 here
Hessian 2X′X
[12 42; 42 182]
eigenvalues 191.8, 2.19

Contours of the sum of squared residuals S(β₀, β₁) for six data points. Click or drag anywhere: the orange arrow is −∇S = 2X′(y − Xβ), the direction of steepest descent (drawn at a fixed length). It points across the contours toward lower S and vanishes only at the OLS estimate.