Skip to content

Closed-form maximum likelihood weights for linear regression

Question

You observe NN pairs (xn,yn)(x_n,y_n), with xn∈RDx_n\in\mathbb{R}^D, and model each response as yn=xn⊤θ+εny_n=x_n^\top\theta+\varepsilon_n with i.i.d. Gaussian noise εn∼N(0,σ2)\varepsilon_n\sim N(0,\sigma^2), so responses are conditionally independent given their inputs. Stack the inputs as rows of a design matrix XX and the responses into a vector yy. Rather than using gradient descent, derive a closed-form expression for the maximum likelihood estimate

θMLE=arg⁡max⁡θ p(y∣X,θ).\theta_{\text{MLE}}=\arg\max_\theta\,p(y\mid X,\theta).

Hint: work with the log-likelihood.

Short answer

θMLE=(X⊤X)−1X⊤y\theta_{\text{MLE}}=(X^\top X)^{-1}X^\top y. The log-likelihood is a constant minus 12σ2∥y−Xθ∥2\tfrac{1}{2\sigma^2}\|y-X\theta\|^2, so maximising it is least squares. Setting the gradient X⊤(y−Xθ)X^\top(y-X\theta) to zero gives the normal equations X⊤Xθ=X⊤yX^\top X\theta=X^\top y, solvable when X⊤XX^\top X is invertible (full column rank).

Adapted from OpenQuant; question and answer rewritten by SelfMadeQuant.com.

See the hint and the full worked solution in the question bank (free account).

Open the worked solution

Lessons behind this question

Start with a free lesson: Basic Statistics and Regression is part of a free topic. Create a free account, no card needed, to read it in full with worked solutions.

Read it free