Skip to content
LeetQuant
QR03 Statistical Inference and Estimation

QR03 · Statistical Inference and Estimation · Lesson 1 of 4

Maximum Likelihood in Depth

The score and Fisher information matrix, why the MLE is asymptotically normal, the delta method, the likelihood-ratio, Wald and score tests, sandwich standard errors under misspecification, and fitting an MLE numerically.

20 min

Beyond the recipe

The foundation lesson on likelihood covered the recipe: write ℓ(θ)\ell(\theta), solve ℓ′(θ)=0\ell'(\theta) = 0, get a standard error from 1/nI(θ^)1/\sqrt{n I(\hat\theta)}. This lesson explains why that recipe works, what to do with several parameters and functions of them, how the three classical tests differ, and what survives when the model is wrong. That last point is the one interviewers push on: real returns are never exactly normal, so "the MLE standard error" is only right if you know which one to use.

The score and the information matrix

For a parameter vector θ∈Rp\theta \in \mathbb{R}^p and i.i.d. data, the score is the gradient of the log-likelihood,

sn(θ)=∇θ ℓ(θ)=∑i=1n∇θlog⁡f(xi;θ).s_n(\theta) = \nabla_\theta\, \ell(\theta) = \sum_{i=1}^n \nabla_\theta \log f(x_i; \theta) .

Two facts hold at the true θ0\theta_0 when the model is correct (and the support does not depend on θ\theta, so differentiation and integration can be swapped):

  1. The score has mean zero: E[∇log⁡f(X;θ0)]=∫∇f dx=∇∫f dx=0\mathbb{E}[\nabla \log f(X;\theta_0)] = \int \nabla f \, dx = \nabla \int f\,dx = 0.
  2. The information equality: the variance of the score equals minus the expected Hessian,
I(θ0)=Var⁡[∇log⁡f(X;θ0)]=−E[∇2log⁡f(X;θ0)].I(\theta_0) = \operatorname{Var}\big[\nabla \log f(X;\theta_0)\big] = -\mathbb{E}\big[\nabla^2 \log f(X;\theta_0)\big] .

I(θ)I(\theta) is the p×pp \times p Fisher information matrix per observation. For the normal model with θ=(μ,σ2)\theta = (\mu, \sigma^2),

I(μ,σ2)=(1/σ2001/(2σ4)).I(\mu, \sigma^2) = \begin{pmatrix} 1/\sigma^2 & 0 \\ 0 & 1/(2\sigma^4) \end{pmatrix} .

The off-diagonal zero says μ\mu and σ2\sigma^2 are orthogonal: not knowing one costs nothing when estimating the other. When the off-diagonal is non-zero, the standard error of one parameter is the square root of the corresponding diagonal entry of I−1I^{-1}, which is larger than 1/Ijj1/\sqrt{I_{jj}}: uncertainty about the nuisance parameters leaks in.

Why the MLE is asymptotically normal

Expand the score equation around θ0\theta_0:

0=sn(θ^)≈sn(θ0)+Hn(θ0) (θ^−θ0)⟹n (θ^−θ0)≈[−1nHn]−1sn(θ0)n.0 = s_n(\hat\theta) \approx s_n(\theta_0) + H_n(\theta_0)\,(\hat\theta - \theta_0) \quad\Longrightarrow\quad \sqrt n\,(\hat\theta - \theta_0) \approx \Big[-\tfrac1n H_n\Big]^{-1} \frac{s_n(\theta_0)}{\sqrt n} .

The score is a sum of i.i.d. mean-zero terms, so by the CLT sn/n→N(0,B)s_n/\sqrt n \to N(0, B) with B=Var⁡[∇log⁡f]B = \operatorname{Var}[\nabla \log f]. By the law of large numbers −Hn/n→A=−E[∇2log⁡f]-H_n/n \to A = -\mathbb{E}[\nabla^2 \log f]. Therefore

n (θ^−θ0)  →  N(0,  A−1BA−1).\sqrt n\,(\hat\theta - \theta_0) \;\to\; N\big(0,\; A^{-1} B A^{-1}\big) .

Under a correct model the information equality gives A=B=IA = B = I, and the variance collapses to the familiar I−1/nI^{-1}/n. Keep the general form in mind: it is the sandwich formula below.

The delta method

Parameters of interest are often functions of the fitted ones: a Sharpe ratio, a half-life, a volatility from a variance. If θ^≈N(θ,Σ)\hat\theta \approx N(\theta, \Sigma) and gg is smooth, a first-order Taylor expansion gives

g(θ^)≈N(g(θ),  ∇g(θ)⊤Σ ∇g(θ)).g(\hat\theta) \approx N\big(g(\theta),\; \nabla g(\theta)^\top \Sigma\, \nabla g(\theta)\big) .

In one dimension, SE⁡(g(θ^))≈∣g′(θ)∣ SE⁡(θ^)\operatorname{SE}(g(\hat\theta)) \approx |g'(\theta)|\,\operatorname{SE}(\hat\theta). It fails when ∇g=0\nabla g = 0 at the truth (use a second-order expansion) and is poor when gg is very curved over the width of the sampling distribution.

Worked example

the standard error of a Sharpe ratio

A strategy has 60 monthly returns with sample mean 1% and sample standard deviation 4%. Treating returns as i.i.d. normal, find the standard error of the monthly Sharpe ratio SR^=μ^/σ^\widehat{SR} = \hat\mu/\hat\sigma and a 95% interval for the annualised Sharpe ratio.

Show solution

The MLEs μ^\hat\mu and σ^2\hat\sigma^2 are asymptotically independent (the information matrix is diagonal) with Var⁡(μ^)=σ2/n\operatorname{Var}(\hat\mu) = \sigma^2/n and Var⁡(σ^2)=2σ4/n\operatorname{Var}(\hat\sigma^2) = 2\sigma^4/n. The delta method with dσ/dσ2=1/(2σ)d\sigma/d\sigma^2 = 1/(2\sigma) gives Var⁡(σ^)≈2σ4/n⋅1/(4σ2)=σ2/(2n)\operatorname{Var}(\hat\sigma) \approx 2\sigma^4/n \cdot 1/(4\sigma^2) = \sigma^2/(2n).

Now g(μ,σ)=μ/σg(\mu, \sigma) = \mu/\sigma has gradient (1/σ,  −μ/σ2)(1/\sigma,\; -\mu/\sigma^2), so

Var⁡(SR^)≈1σ2⋅σ2n+μ2σ4⋅σ22n=1+SR2/2n.\operatorname{Var}(\widehat{SR}) \approx \frac{1}{\sigma^2}\cdot\frac{\sigma^2}{n} + \frac{\mu^2}{\sigma^4}\cdot\frac{\sigma^2}{2n} = \frac{1 + SR^2/2}{n} .

With SR=0.01/0.04=0.25SR = 0.01/0.04 = 0.25 and n=60n = 60: SE⁡=1.03125/60≈0.131\operatorname{SE} = \sqrt{1.03125/60} \approx 0.131. The SR2/2SR^2/2 term barely matters at realistic Sharpe ratios, so SE⁡≈1/n\operatorname{SE} \approx 1/\sqrt n is the mental shortcut.

Annualising multiplies both by 12\sqrt{12} (assuming no autocorrelation): SR^ann≈0.866\widehat{SR}_{\text{ann}} \approx 0.866 with SE⁡≈0.454\operatorname{SE} \approx 0.454, so the 95% interval is 0.866±1.96×0.454≈[−0.02,  1.76]0.866 \pm 1.96 \times 0.454 \approx [-0.02,\; 1.76]. Five years of a Sharpe-0.87 track record does not exclude zero. A simulation of 200,000 such samples gives a standard deviation of 0.1340.134 for the monthly estimate, close to the asymptotic 0.1310.131; fat tails or autocorrelation would widen it further.

Three tests from one likelihood

To test H0:θ=θ0H_0: \theta = \theta_0 (or rr restrictions in general), let θ^\hat\theta be the unrestricted MLE and θ~\tilde\theta the restricted one. With total information In=nI\mathcal{I}_n = n I:

TestStatisticFits neededGeometry
Likelihood ratio2[ℓ(θ^)−ℓ(θ~)]2[\ell(\hat\theta) - \ell(\tilde\theta)]bothvertical drop in ℓ\ell
Wald(θ^−θ0)⊤In(θ^)(θ^−θ0)(\hat\theta - \theta_0)^\top \mathcal{I}_n(\hat\theta)(\hat\theta - \theta_0)unrestricted onlyhorizontal distance, scaled by curvature at θ^\hat\theta
Score (Lagrange multiplier)sn(θ~)⊤In(θ~)−1sn(θ~)s_n(\tilde\theta)^\top \mathcal{I}_n(\tilde\theta)^{-1} s_n(\tilde\theta)restricted onlyslope of ℓ\ell at the null

All three are asymptotically χr2\chi^2_r under H0H_0 and agree to first order, because all three approximate ℓ\ell by a quadratic. In finite samples they differ, and the differences have practical consequences:

  • Wald is not invariant to reparametrisation. Testing λ=2\lambda = 2 and testing log⁡λ=log⁡2\log\lambda = \log 2 give different Wald statistics, while the LR statistic is identical. Wald is also the worst behaved near a boundary.
  • The score test only needs the null model. That is why many specification tests (Breusch–Pagan for heteroskedasticity, the LM test for ARCH effects, tests for omitted variables) are score tests: fit the simple model once and check whether the log-likelihood would slope upward if you relaxed it.
  • LR is usually the most reliable in small samples and gives intervals (the set of θ0\theta_0 not rejected) that respect the shape of the likelihood. With nuisance parameters, maximise them out to get the profile likelihood and apply the same χ2\chi^2 cut-off.

Worked example

one null, three statistics

Over 50 days you see 130 order-book events of a given type, modelled as Poisson with daily rate λ\lambda. Test H0:λ=2H_0: \lambda = 2 with the Wald, score and LR tests, and compare Wald intervals on the λ\lambda and log⁡λ\log\lambda scales.

Show solution

λ^=130/50=2.6\hat\lambda = 130/50 = 2.6 and In(λ)=n/λ\mathcal{I}_n(\lambda) = n/\lambda.

Wald: (2.6−2)2×50/2.6=0.36×19.23≈6.92(2.6 - 2)^2 \times 50/2.6 = 0.36 \times 19.23 \approx 6.92, p-value 0.00850.0085.

Score: sn(2)=∑xi/λ0−n=65−50=15s_n(2) = \sum x_i/\lambda_0 - n = 65 - 50 = 15 and In(2)=25\mathcal{I}_n(2) = 25, so the statistic is 152/25=9.0015^2/25 = 9.00, p-value 0.00270.0027.

LR:

2[∑xilog⁡λ^λ0−n(λ^−λ0)]=2 [130log⁡1.3−30]=2 [34.107−30]≈8.21,2\Big[\textstyle\sum x_i \log\frac{\hat\lambda}{\lambda_0} - n(\hat\lambda - \lambda_0)\Big] = 2\,[130 \log 1.3 - 30] = 2\,[34.107 - 30] \approx 8.21 ,

p-value 0.00420.0042. All three reject at 5% (cut-off 3.843.84), but they range from 6.96.9 to 9.09.0. Wald uses the curvature at λ^=2.6\hat\lambda = 2.6, where the Poisson variance is larger and the likelihood flatter, so it is the smallest here.

Reparametrise: with η=log⁡λ\eta = \log\lambda, Var⁡(η^)≈1/(nλ^)=1/130\operatorname{Var}(\hat\eta) \approx 1/(n\hat\lambda) = 1/130, so Wald becomes (log⁡1.3)2×130≈8.95(\log 1.3)^2 \times 130 \approx 8.95. Same data, same hypothesis, a different answer. The 95% Wald interval is 2.6±1.962.6/50=[2.15,  3.05]2.6 \pm 1.96\sqrt{2.6/50} = [2.15,\; 3.05] on the λ\lambda scale and 2.6 e±1.96/130=[2.19,  3.09]2.6\, e^{\pm 1.96/\sqrt{130}} = [2.19,\; 3.09] on the log scale. The log-scale version is asymmetric, never goes negative and is closer to the LR interval, which is why rates, variances and odds are usually handled on the log scale.

When the model is wrong: the sandwich

If the data come from some gg that is not in the model family, the MLE still converges, to the pseudo-true value θ∗\theta^* that minimises the Kullback–Leibler divergence from gg to f(⋅;θ)f(\cdot;\theta). This is quasi-maximum likelihood (QMLE). Sometimes θ∗\theta^* is exactly what you want: a normal QMLE still estimates the mean and variance consistently whatever the true distribution. But the information equality fails (A≠BA \ne B), so I−1/nI^{-1}/n is the wrong variance. The asymptotic argument above still gives the sandwich

Var⁡^(θ^)=1nA^−1B^A^−1,A^=−1n∑∇2log⁡f(xi;θ^),B^=1n∑sisi⊤,\widehat{\operatorname{Var}}(\hat\theta) = \frac1n \hat A^{-1} \hat B \hat A^{-1}, \qquad \hat A = -\frac1n \sum \nabla^2 \log f(x_i;\hat\theta), \quad \hat B = \frac1n \sum s_i s_i^\top ,

where sis_i is observation ii's score at θ^\hat\theta. White (heteroskedasticity-robust) standard errors in OLS are exactly this; Newey–West adds autocovariances of the scores to B^\hat B for time series.

The variance of a variance. Fit a normal to returns with kurtosis κ=E[(X−μ)4]/σ4\kappa = \mathbb{E}[(X-\mu)^4]/\sigma^4. The per-observation score for σ2\sigma^2 is −1/(2σ2)+(x−μ)2/(2σ4)-1/(2\sigma^2) + (x-\mu)^2/(2\sigma^4), so A=1/(2σ4)A = 1/(2\sigma^4) while B=Var⁡[(X−μ)2]/(4σ8)=(κ−1)/(4σ4)B = \operatorname{Var}[(X-\mu)^2]/(4\sigma^8) = (\kappa - 1)/(4\sigma^4). The sandwich is

Var⁡(σ^2)≈A−1BA−1n=(κ−1) σ4n,versus the model’s 2σ4n.\operatorname{Var}(\hat\sigma^2) \approx \frac{A^{-1} B A^{-1}}{n} = \frac{(\kappa - 1)\,\sigma^4}{n}, \quad \text{versus the model's } \frac{2\sigma^4}{n} .

The normal answer is the special case κ=3\kappa = 3. For daily equity returns with kurtosis around 6, the true standard error of a variance estimate is 5/2≈1.58\sqrt{5/2} \approx 1.58 times the textbook one. The same thing happens with overdispersed counts: a Poisson QMLE of the mean is fine, but its sandwich variance is the sample variance over nn, not λ^/n\hat\lambda/n.

Numerical MLE

Most likelihoods (GARCH, Student-t, mixtures, logistic regression) have no closed-form maximiser. The standard tool is Newton–Raphson, θ←θ−H(θ)−1s(θ)\theta \leftarrow \theta - H(\theta)^{-1} s(\theta), or Fisher scoring, which replaces HH by −In(θ)-\mathcal{I}_n(\theta) and is more stable far from the optimum. Practical rules:

  • Reparametrise constraints away: optimise log⁡σ\log\sigma, the logit of a probability, or log⁡\log of GARCH coefficients, so the optimiser cannot step outside the parameter space.
  • Start well: use method-of-moments or robust estimates as starting values, and try several starts. Newton converges fast near a maximum and can diverge far from it, where the log-likelihood is convex.
  • Get standard errors from the Hessian at the optimum (observed information), and the sandwich if you doubt the model. A Hessian that is nearly singular means some parameter is barely identified.
  • Check the boundary and the gradient: a converged optimiser reports a point, not a guarantee. Confirm the gradient is near zero and the Hessian negative definite.

The Cauchy location model shows all of this in ten lines. Its likelihood can be multimodal and its mean does not exist, so the sample mean is useless and the MLE needs iteration.

import math

x = [-1.2, 0.3, 0.8, 1.1, 1.9, 2.4, 9.7, -0.4, 1.5, 0.6]


def score(m):  # d/dm of sum log f, f = 1 / (pi (1 + (x - m)^2))
    return sum(2 * (v - m) / (1 + (v - m) ** 2) for v in x)


def hessian(m):
    return sum(2 * ((v - m) ** 2 - 1) / (1 + (v - m) ** 2) ** 2 for v in x)


m = sorted(x)[len(x) // 2]  # start at a robust guess (upper median)
for it in range(20):
    step = score(m) / hessian(m)
    m -= step
    if abs(step) < 1e-10:
        break
obs_info = -hessian(m)
print(f"MLE {m:.4f} after {it + 1} steps")
print(f"SE observed {1 / math.sqrt(obs_info):.3f}, expected {math.sqrt(2 / len(x)):.3f}")
print(f"mean {sum(x) / len(x):.2f}")
# MLE 0.9068 after 4 steps
# SE observed 0.410, expected 0.447
# mean 1.67

The outlier at 9.7 drags the mean to 1.67 but barely moves the MLE (0.91). The Fisher information of the Cauchy location is 1/21/2 per observation, so the expected-information SE is 2/n=0.447\sqrt{2/n} = 0.447; the observed-information SE (0.4100.410) reflects this particular sample. Started at 5 or at 9.7 instead, the same Newton loop runs off to infinity, because the log-likelihood is convex out there: a concrete reason to start from a robust estimate.

Knowledge check

You estimate the variance of 200 i.i.d. normal returns by maximum likelihood. Using the delta method, what is the approximate standard error of log⁡σ^2\log \hat\sigma^2?

Knowledge check

Returns have kurtosis κ=9\kappa = 9 (excess kurtosis 6), but you fit a normal by maximum likelihood. By what factor does the model-based standard error 2σ4/n\sqrt{2\sigma^4/n} of σ^2\hat\sigma^2 understate the sandwich standard error?

Knowledge check

You want to test whether a fitted constant-variance model would improve by adding a GARCH term, but fitting the GARCH model is slow and unstable. Which classical test needs only the constant-variance fit?

Key takeaways

  • The score has mean zero and variance I(θ)I(\theta) at the truth; the information equality Var⁡(score)=−E[Hessian]\operatorname{Var}(\text{score}) = -\mathbb{E}[\text{Hessian}] is what makes I−1/nI^{-1}/n the asymptotic variance.
  • In general n(θ^−θ)→N(0,A−1BA−1)\sqrt n(\hat\theta - \theta) \to N(0, A^{-1}BA^{-1}); under misspecification use this sandwich (White, Newey–West), not I−1I^{-1}.
  • The delta method: Var⁡ g(θ^)≈∇g⊤Σ∇g\operatorname{Var}\,g(\hat\theta) \approx \nabla g^\top \Sigma \nabla g. A Sharpe ratio estimate has SE ≈(1+SR2/2)/n\approx \sqrt{(1 + SR^2/2)/n}.
  • LR, Wald and score tests are asymptotically equivalent; Wald depends on parametrisation, the score test needs only the null fit, LR is usually the most reliable.
  • Fit numerically on an unconstrained scale, from a robust start, and read standard errors off the Hessian at the optimum.

Practice problems

Finished reading?

Answer the 3 knowledge checks to complete this lesson (0 done).