Maximum Likelihood Estimation › Formula

Michael BrenndoerferOctober 25, 202621 min read
Machine Learning from ScratchAll chapters
Part 3 of 15Model Fundamentals and Diagnostics
Chapter 29Maximum Likelihood Estimation › Formula
Reading section 4 of 10 · Formula · 21 minSection 4 of 10 · 21 min

Section 4 of 10 · 21 min read

Maximum Likelihood Estimation › FormulaSection view · Sections in this chapter4 / 10 ↓
Reading tools Definitions, links & notes

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Notes & comments

We can build the likelihood in three steps. First, hold the observed data fixed; they are no longer random quantities to be predicted. Second, choose a probability model that assigns a probability or density to each observation for any candidate parameter value. Third, compare candidate parameter values by asking which one gives the entire observed sample the highest combined plausibility. The formula below is simply the bookkeeping for those three steps.

Suppose we observe independent and identically distributed data y1,…,yny_1,\dots,y_n. Let f(yi;θ)f(y_i;\theta) be the probability mass function for discrete data or the probability density function for continuous data, where θ\theta is a parameter or a vector of parameters. The likelihood is

L(θ;y1,…,yn)=∏i=1nf(yi;θ).L(\theta; y_1,\dots,y_n) = \prod_{i=1}^{n} f(y_i;\theta).

where:

  • L(θ;y1,…,yn)L(\theta; y_1,\dots,y_n): the likelihood of the parameter θ\theta given the full observed sample
  • nn: the number of observations in the sample
  • yiy_i: the ii-th observed data value, held fixed as θ\theta varies
  • f(yi;θ)f(y_i;\theta): the probability mass (discrete case) or probability density (continuous case) assigned to yiy_i by the model with parameter θ\theta
  • ∏i=1n\prod_{i=1}^{n}: the product over all observations from i=1i=1 to i=ni=n

The product symbol ∏i=1n\prod_{i=1}^{n} means that we multiply the terms for i=1i=1 through i=ni=n. That multiplication is not an arbitrary convention. Independence is exactly what makes the joint probability or joint density of the sample factor into one term per observation. If the observations were dependent, the product of marginal terms would not be the joint distribution, and the likelihood would have to be built from the joint model instead. The semicolon in f(yi;θ)f(y_i;\theta) separates the observed data yiy_i from the parameter θ\theta; it reminds us that the data are fixed and θ\theta is the input we are varying. For discrete data, each f(yi;θ)f(y_i;\theta) is a probability, so the product is the probability of the observed sequence under independence. For continuous data, each term is a density, so the product is a likelihood density rather than the probability of observing an exact value.

The log-likelihood is

ℓ(θ)=log⁡L(θ;y1,…,yn)=log⁡∏i=1nf(yi;θ)(substitute the likelihood)=∑i=1nlog⁡f(yi;θ)(log of a product is a sum).\begin{aligned} \ell(\theta) &= \log L(\theta; y_1,\dots,y_n) \\ &= \log \prod_{i=1}^{n} f(y_i;\theta) && \text{(substitute the likelihood)} \\ &= \sum_{i=1}^{n} \log f(y_i;\theta) && \text{(log of a product is a sum)}. \end{aligned}

The symbols in this expression are:

  • ℓ(θ)\ell(\theta): the log-likelihood, the natural logarithm of the likelihood
  • log⁡\log: the natural logarithm
  • ∑i=1n\sum_{i=1}^{n}: the sum over all observations from i=1i=1 to i=ni=n
  • the remaining symbols are defined as above.

The logarithm is monotone increasing. If L(θ1)>L(θ2)L(\theta_1) > L(\theta_2), then ℓ(θ1)>ℓ(θ2)\ell(\theta_1) > \ell(\theta_2). Therefore the parameter that maximizes LL also maximizes ℓ\ell. Logs turn products into sums, which are easier to differentiate and much less likely to underflow when nn is large. It is common to see negative log-likelihood minimized instead, because optimization software usually minimizes rather than maximizes. These three facts, factorization under independence, monotone transformation, and numerical stability, explain nearly every manipulation that follows.

Likelihood and log-likelihood

The likelihood is a function of the parameter, not a probability distribution over the parameter. This point deserves emphasis. If we compute L(0.3)=0.002L(0.3)=0.002 and L(0.6)=0.010L(0.6)=0.010, we can say that the observed data are five times more likely under 0.60.6 than under 0.30.3 in the likelihood ratio sense. We cannot say that there is a 1% probability that the parameter equals 0.60.6. To obtain a probability distribution over θ\theta, we would need a prior distribution and a normalization step, which leads to Bayesian inference. Here we remain in the frequentist likelihood framework.

The independence assumption is what allows us to multiply the individual terms. If observations are correlated, the product of marginal probabilities is not the joint probability, and the likelihood must be built from the joint distribution instead. Identically distributed means that every observation has the same distribution. Independent observations may instead have different densities, all indexed by a shared parameter; their likelihood is still the product of those individual densities. Dependence requires a joint model.

For discrete data, the likelihood is a probability of the observed data. For continuous data, it is a density. A density can be greater than one when the distribution is concentrated over a narrow range, so a likelihood value above one is not an error. For estimation, what matters is the relative size of the likelihood at different parameter values, not whether the number looks like a probability.

To turn this function into an estimate, we need a way to locate its peak. The score is the first derivative of the log-likelihood:

s(θ)=∂ℓ(θ)∂θ.s(\theta) = \frac{\partial \ell(\theta)}{\partial \theta}.

where:

  • s(θ)s(\theta): the score, the first derivative of the log-likelihood with respect to the parameter
  • θ\theta: the parameter (or parameter vector) being estimated
  • ∂ℓ(θ)/∂θ\partial \ell(\theta)/\partial \theta: the partial derivative of the log-likelihood with respect to θ\theta

At a differentiable maximum in the interior of the parameter space, the score is zero:

s(θ^)=0.s(\hat\theta)=0.

This equation is called the score equation or the likelihood equation. In simple models we can solve it algebraically. In more complex models we solve it numerically. The score tells us the local slope of the log-likelihood. A positive score means increasing θ\theta increases the log-likelihood, and a negative score means decreasing θ\theta increases it. A zero score means we are at a flat point, which could be a maximum, a minimum, or a saddle point. A negative second derivative gives a strict local maximum in one dimension; a positive one gives a strict local minimum. A zero second derivative is inconclusive. For a vector parameter, negative definiteness of the Hessian is a sufficient local maximum test.

Bernoulli and Gaussian worked estimators

The general formula becomes concrete only after we choose a probability model. You now derive two estimators that appear constantly in practice. The first is the Bernoulli probability, which gives us the sample proportion. The second is the Gaussian mean and variance, which gives us the sample mean and the maximum likelihood variance. These derivations show how the general likelihood formula becomes a concrete estimate.

For Bernoulli data, each observation is either 11 or 00. Assume n>0n>0, and let p∈[0,1]p\in[0,1] be the probability of a success. For 0<p<10<p<1, the probability mass is

f(yi;p)=pyi(1−p)1−yi.f(y_i;p)=p^{y_i}(1-p)^{1-y_i}.

where:

  • yiy_i: the ii-th observation, taking the value 11 for a success or 00 for a failure
  • pp: the probability of a success, the unknown parameter
  • 1−p1-p: the probability of a failure

When yi=1y_i=1, this becomes p1(1−p)0=pp^1(1-p)^0=p. When yi=0y_i=0, it becomes p0(1−p)1=1−pp^0(1-p)^1=1-p. If we observe kk successes and n−kn-k failures, then the product over all observations is

L(p)=pk(1−p)n−k.L(p)=p^{k}(1-p)^{n-k}.

where:

  • kk: the number of observed successes
  • n−kn-k: the number of observed failures
  • pp: the success probability

The log-likelihood is

ℓ(p)=klog⁡p+(n−k)log⁡(1−p).\ell(p)=k\log p+(n-k)\log(1-p).

where:

  • ℓ(p)\ell(p): the log-likelihood for the Bernoulli success probability pp
  • kk: the number of observed successes
  • n−kn-k: the number of observed failures
  • pp: the success probability

Differentiating with respect to pp gives

dℓdp=kp−n−k1−p.\frac{d\ell}{dp}=\frac{k}{p}-\frac{n-k}{1-p}.

where:

  • dℓdp\frac{d\ell}{dp}: the derivative of the Bernoulli log-likelihood with respect to pp
  • kp\frac{k}{p}: the term contributed by the successes
  • −n−k1−p-\frac{n-k}{1-p}: the derivative term contributed by the failures

Setting this equal to zero, we multiply both sides by p(1−p)p(1-p):

k(1−p)−p(n−k)=0.k(1-p)-p(n-k)=0.

where:

  • kk: the number of observed successes
  • 1−p1-p: the candidate failure probability
  • n−kn-k: the number of observed failures
  • pp: the success probability

Expanding gives k−kp−pn+pk=0k-kp-pn+pk=0, and the −kp+pk-kp+pk terms cancel, leaving k−pn=0k-pn=0. Therefore

p^=kn.\hat p=\frac{k}{n}.

The second derivative is

d2ℓdp2=−kp2−n−k(1−p)2<0,\frac{d^2\ell}{dp^2}=-\frac{k}{p^2}-\frac{n-k}{(1-p)^2}<0,

where:

  • d2ℓdp2\frac{d^2\ell}{dp^2}: the second derivative of the Bernoulli log-likelihood
  • kp2\frac{k}{p^2}: the magnitude of the negative curvature contribution from the successes
  • n−k(1−p)2\frac{n-k}{(1-p)^2}: the magnitude of the negative curvature contribution from the failures

This derivative is negative for 0<p<10<p<1. With 0<k<n0<k<n, the stationary point is the unique global maximum. On the closed parameter space [0,1][0,1], k=0k=0 or k=nk=n puts the maximum at p=0p=0 or p=1p=1, using the limiting convention 0log⁡0=00\log 0=0. The plug-in Wald standard error is zero there, but that does not establish zero uncertainty. The interior information formula below is not valid at those endpoints.

If we only record the count kk rather than the exact sequence of successes and failures, the binomial likelihood is (nk)pk(1−p)n−k\binom{n}{k}p^k(1-p)^{n-k}. The binomial coefficient does not depend on pp, so it does not change the maximizing value. That is why we can work with the simpler Bernoulli form.

For Gaussian data, suppose yi∼N(μ,σ2)y_i\sim N(\mu,\sigma^2). The density is

f(yi;μ,σ2)=12πσ2exp⁡[−(yi−μ)22σ2].f(y_i;\mu,\sigma^2)=\frac{1}{\sqrt{2\pi\sigma^2}} \exp\left[-\frac{(y_i-\mu)^2}{2\sigma^2}\right].

where:

  • μ\mu: the mean of the normal distribution
  • σ2\sigma^2: the variance of the normal distribution
  • σ\sigma: the standard deviation, the positive square root of the variance
  • exp⁡[⋅]\exp[\cdot]: the exponential function

The log-likelihood for all nn observations is

ℓ(μ,σ2)=−n2log⁡(2π)−n2log⁡(σ2)−12σ2∑i=1n(yi−μ)2.\ell(\mu,\sigma^2) = -\frac{n}{2}\log(2\pi) -\frac{n}{2}\log(\sigma^2) -\frac{1}{2\sigma^2}\sum_{i=1}^{n}(y_i-\mu)^2.

where:

  • ℓ(μ,σ2)\ell(\mu,\sigma^2): the Gaussian log-likelihood for all nn observations
  • nn: the number of observations
  • log⁡(2π)\log(2\pi): the constant log term from the normalizing factor
  • log⁡(σ2)\log(\sigma^2): the log of the variance
  • 12σ2∑i=1n(yi−μ)2\frac{1}{2\sigma^2}\sum_{i=1}^{n}(y_i-\mu)^2: the sum of squared deviations divided by twice the variance

To estimate μ\mu, we differentiate with respect to μ\mu. The first two terms do not depend on μ\mu, and the derivative of the squared term brings down a factor of −2(yi−μ)-2(y_i-\mu):

∂ℓ∂μ=1σ2∑i=1n(yi−μ).\frac{\partial \ell}{\partial \mu} = \frac{1}{\sigma^2}\sum_{i=1}^{n}(y_i-\mu).

where:

  • ∂ℓ∂μ\frac{\partial \ell}{\partial \mu}: the score with respect to the Gaussian mean
  • σ2\sigma^2: the variance of the normal distribution
  • yi−μy_i-\mu: the deviation of the ii-th observation from the candidate mean

Setting this to zero gives

∑i=1n(yi−μ)=0⟹∑i=1nyi−nμ=0⟹μ^=1n∑i=1nyi=yˉ.\sum_{i=1}^{n}(y_i-\mu)=0 \quad\Longrightarrow\quad \sum_{i=1}^{n}y_i-n\mu=0 \quad\Longrightarrow\quad \hat\mu=\frac{1}{n}\sum_{i=1}^{n}y_i=\bar y.

where:

  • ∑i=1n(yi−μ)=0\sum_{i=1}^{n}(y_i-\mu)=0: the score set to zero
  • ∑i=1nyi\sum_{i=1}^{n}y_i: the sum of all observations
  • nμn\mu: the sum if every observation were equal to μ\mu
  • μ^\hat\mu: the maximum likelihood estimate of the mean
  • yˉ\bar y: the sample mean

The maximum likelihood estimate of the mean is the sample mean. This result does not depend on the value of σ2\sigma^2.

To estimate the variance, let v=σ2v=\sigma^2 and write the sum of squared deviations as

SSE=∑i=1n(yi−yˉ)2.\mathrm{SSE}=\sum_{i=1}^{n}(y_i-\bar y)^2.

After substituting μ=yˉ\mu=\bar y, the profile log-likelihood for v>0v>0 becomes

ℓ(yˉ,v)=−n2log⁡(2π)−n2log⁡v−SSE2v.\ell(\bar y,v) = -\frac{n}{2}\log(2\pi) -\frac{n}{2}\log v -\frac{\mathrm{SSE}}{2v}.

where:

  • ℓ(yˉ,v)\ell(\bar y,v): the Gaussian log-likelihood with the mean fixed at its fitted value and candidate variance vv
  • nn: the number of observations
  • vv: the candidate variance σ2\sigma^2
  • SSE\mathrm{SSE}: the sum of squared deviations from the sample mean

Differentiating with respect to vv gives

∂ℓ∂v=−n2v+SSE2v2.\frac{\partial \ell}{\partial v} = -\frac{n}{2v}+\frac{\mathrm{SSE}}{2v^2}.

Setting this to zero, we multiply by 2v22v^2:

−nv+SSE=0⟹v^=SSEn.-nv+\mathrm{SSE}=0 \quad\Longrightarrow\quad \hat v=\frac{\mathrm{SSE}}{n}.

where:

  • nn: the number of observations
  • vv: the candidate variance
  • SSE\mathrm{SSE}: the sum of squared deviations from the sample mean
  • v^\hat v: the maximum likelihood variance estimate

If SSE>0\mathrm{SSE}>0, the profile likelihood rises for v<SSE/nv<\mathrm{SSE}/n and falls for v>SSE/nv>\mathrm{SSE}/n, so this is the global maximum over v>0v>0. If all observations are identical, SSE=0\mathrm{SSE}=0 and the Gaussian likelihood is unbounded as vv tends to zero: no positive-variance MLE is attained. For nondegenerate i.i.d. Gaussian samples, the variance estimator is biased downward because

E[SSEn]=n−1nσ2.\mathbb{E}\left[\frac{\mathrm{SSE}}{n}\right] =\frac{n-1}{n}\sigma^2.

where:

  • E[⋅]\mathbb{E}[\cdot]: expectation over repeated samples
  • SSE\mathrm{SSE}: the sum of squared deviations from the sample mean
  • nn: the number of observations
  • σ2\sigma^2: the true variance

The bias shrinks as nn grows, and the estimator is consistent, but it is not unbiased. This is a concrete reminder that maximum likelihood and unbiasedness are different properties.

The Gaussian likelihood also explains why squared error appears so often in regression. If we model y=Xβ+εy=X\beta+\varepsilon with ε∼N(0,σ2I)\varepsilon\sim N(0,\sigma^2 I), the log-likelihood is

ℓ(β,σ2)=−n2log⁡(2πσ2)−12σ2(y−Xβ)⊤(y−Xβ).\ell(\beta,\sigma^2) = -\frac{n}{2}\log(2\pi\sigma^2) -\frac{1}{2\sigma^2}(y-X\beta)^\top(y-X\beta).

Here yy is a column vector of responses, XX is a matrix with one row per observation and one column per predictor, β\beta is a column vector of coefficients, and II is the identity matrix. The expression (y−Xβ)⊤(y−Xβ)(y-X\beta)^\top(y-X\beta) is exactly the sum of squared errors written in matrix notation. For a fixed σ2\sigma^2, maximizing the likelihood over β\beta is the same as minimizing the sum of squared errors. We will see the full regression derivation in the later chapters on ordinary least squares, but the likelihood connection is already visible here.

Four normal densities

The mean controls the center of the distribution, and the standard deviation controls its width. When you evaluate a likelihood, you are not plotting a distribution over μ\mu or σ\sigma. You are comparing candidate distributions over the observed data yy.

PythonIn [3]
CollapseExpand
import matplotlib.pyplot as plt
from book_plot_style import PALETTE, polish_axes, theme_color, use_book_style

use_book_style()
fig, ax = plt.subplots(figsize=(6.0, 4.0))


plot_colors = [
    PALETTE["primary"],
    PALETTE["amber"],
    PALETTE["teal"],
    PALETTE["muted"],
]
for (mu, sigma, label), density, color in zip(
    normal_variants, normal_densities, plot_colors
):
    ax.plot(x_grid, density, color=color, label=label)
ax.set_xlabel("Observation y")
ax.set_ylabel("Density f(y)")
ax.set_title("Candidate normal distributions")
ax.legend()
polish_axes(ax)
plt.show()
VisualizationOut [3]
CollapseExpand
Four bell-shaped curves with different centers and widths on an axis of observation values.
Four candidate normal densities over observation values, each with a different mean and standard deviation. Centers shift with the mean and widths grow with the standard deviation, and all four are distributions over y rather than likelihood curves over the parameters.

Score, curvature, and numerical estimation

The score equation s(θ^)=0s(\hat\theta)=0 is the first-order condition for a maximum. To confirm a maximum and to measure uncertainty, we use the second derivative. Intuitively, the first derivative tells us where the likelihood is flat, while the second derivative tells us how quickly it curves away from that flat point. A sharp peak is informative. A broad, nearly flat peak is not. The observed information is

J(θ^)=−d2ℓ(θ)dθ2∣θ=θ^.J(\hat\theta)=-\left.\frac{d^2\ell(\theta)}{d\theta^2}\right|_{\theta=\hat\theta}.

where:

  • J(θ^)J(\hat\theta): the observed information, evaluated at the estimate θ^\hat\theta
  • θ^\hat\theta: the maximum likelihood estimate of the parameter
  • d2ℓ(θ)/dθ2d^2\ell(\theta)/d\theta^2: the second derivative of the log-likelihood with respect to θ\theta
  • the vertical bar with subscript θ=θ^\theta=\hat\theta: evaluation of the second derivative at the estimate

For a vector parameter, the second derivative becomes a Hessian matrix, and the observed information is the negative Hessian:

J(θ^)=−∇2ℓ(θ^).J(\hat\theta)=-\nabla^2\ell(\hat\theta).

The Fisher information is the expected value of the observed information under the model:

In(θ)=Eθ[J(θ)]=Eθ[−∇2ℓ(θ)],I_n(\theta) = \mathbb{E}_{\theta}\left[J(\theta)\right] = \mathbb{E}_{\theta}\left[-\nabla^2\ell(\theta)\right],

where:

  • In(θ)I_n(\theta): the Fisher information in the full sample for the parameter θ\theta
  • Eθ[⋅]\mathbb{E}_{\theta}[\cdot]: the expectation taken over repeated samples generated with the true parameter equal to θ\theta
  • ∇2ℓ(θ)\nabla^2\ell(\theta): the Hessian of the log-likelihood (the matrix of second partial derivatives)

For a correctly specified regular i.i.d. model, In(θ)=nI1(θ)I_n(\theta)=nI_1(\theta), where I1I_1 is per-observation information. Under the usual consistency and derivative-convergence conditions, J(θ^)/nJ(\hat\theta)/n and In(θ^)/nI_n(\hat\theta)/n converge to the same nonsingular limit. This statement concerns information per observation; their unnormalized difference need not tend to zero.

At a regular interior estimate with positive information, a large-sample standard error for a scalar parameter is

se^(θ^)≈J(θ^)−1=1−ℓ′′(θ^).\widehat{\mathrm{se}}(\hat\theta) \approx \sqrt{J(\hat\theta)^{-1}} = \sqrt{\frac{1}{-\ell''(\hat\theta)}}.

where:

  • se^(θ^)\widehat{\mathrm{se}}(\hat\theta): the approximate standard error of the estimate
  • J(θ^)−1J(\hat\theta)^{-1}: the reciprocal of the observed information (the inverse information matrix in the vector case)
  • ℓ′′(θ^)\ell''(\hat\theta): the second derivative of the log-likelihood evaluated at the estimate

For a regular interior vector estimate with nonsingular positive-definite observed information, its inverse approximates the covariance matrix:

Cov^(θ^)≈[−∇2ℓ(θ^)]−1.\widehat{\mathrm{Cov}}(\hat\theta) \approx \left[-\nabla^2\ell(\hat\theta)\right]^{-1}.

The diagonal entries give approximate variances, and their square roots give approximate standard errors. This is where the shape of the likelihood becomes uncertainty: a sharply curved peak has large information and small standard error, while a flat peak has small information and large standard error.

The quadratic approximation below shows why curvature is used as a local summary of information. Near the peak, the log-likelihood and its second-order approximation almost coincide; farther away, the approximation drifts from the exact curve.

PythonIn [4]
CollapseExpand
bernoulli_p_hat_quad = 12 / 20
bernoulli_info_quad = 20 / (bernoulli_p_hat_quad * (1 - bernoulli_p_hat_quad))
bernoulli_p_grid_quad = np.linspace(0.35, 0.85, 500)
bernoulli_loglik_quad = 12 * np.log(bernoulli_p_grid_quad) + 8 * np.log(
    1 - bernoulli_p_grid_quad
)
bernoulli_loglik_quad_relative = bernoulli_loglik_quad - (
    12 * np.log(bernoulli_p_hat_quad) + 8 * np.log1p(-bernoulli_p_hat_quad)
)
bernoulli_quadratic_approx = (
    -0.5
    * bernoulli_info_quad
    * (bernoulli_p_grid_quad - bernoulli_p_hat_quad) ** 2
)
VisualizationOut [5]
CollapseExpand
Bernoulli log-likelihood and its quadratic approximation around the MLE.
Bernoulli log-likelihood and its quadratic approximation around the maximum likelihood estimate. The approximation matches the curve near the peak and summarizes local curvature through the observed information, while diverging in the tails where the second-order expansion no longer holds.

For the Bernoulli model with 0<k<n0<k<n, the observed information at p^=k/n\hat p=k/n is

J(p^)=np^(1−p^),J(\hat p)=\frac{n}{\hat p(1-\hat p)},

where:

  • J(p^)J(\hat p): the observed information for the Bernoulli probability
  • nn: the number of trials
  • p^\hat p: the estimated success probability
  • 1−p^1-\hat p: the estimated failure probability

so the approximate standard error is

se^(p^)=p^(1−p^)n.\widehat{\mathrm{se}}(\hat p) = \sqrt{\frac{\hat p(1-\hat p)}{n}}.

where:

  • se^(p^)\widehat{\mathrm{se}}(\hat p): the approximate standard error of the Bernoulli estimate
  • p^\hat p: the estimated success probability
  • 1−p^1-\hat p: the estimated failure probability
  • nn: the number of trials

This is the familiar standard error of a sample proportion. For the Gaussian mean with known variance, the observed information is n/σ2n/\sigma^2, so the standard error is σ/n\sigma/\sqrt{n}. For the Gaussian variance, the observed information at v^=SSE/n\hat v=\mathrm{SSE}/n is n/(2v^2)n/(2\hat v^2). The approximate standard error is therefore v^2/n\hat v\sqrt{2/n}, where v^=σ^2\hat v=\hat\sigma^2 is the variance estimate.

When no closed-form solution exists, you can maximize the log-likelihood numerically. A simple one-dimensional approach is a grid search: evaluate the log-likelihood on a fine grid of parameter values and choose the grid point with the largest value. Grid search is easy to reason about but becomes impractical in more than a few dimensions.

A more scalable approach is Newton-Raphson. It comes from a second-order Taylor expansion of the objective around the current iterate, and it approximately solves the score equation ∇ℓ(θ)=0\nabla\ell(\theta)=0 at each step. To maximize ℓ(θ)\ell(\theta), you update

θt+1=θt−[∇2ℓ(θt)]−1∇ℓ(θt).\theta_{t+1} = \theta_t - \left[\nabla^2\ell(\theta_t)\right]^{-1} \nabla\ell(\theta_t).

where:

  • θt\theta_t: the parameter value at iteration tt
  • θt+1\theta_{t+1}: the updated parameter value
  • ∇ℓ(θt)\nabla\ell(\theta_t): the gradient (score) of the log-likelihood at θt\theta_t
  • ∇2ℓ(θt)\nabla^2\ell(\theta_t): the Hessian matrix of second derivatives at θt\theta_t
  • [⋅]−1[\cdot]^{-1}: the matrix inverse

The gradient points in the direction of increase, and the inverse Hessian rescales that direction. The update is equivalent to solving ∇2ℓ(θt)(θt+1−θt)=−∇ℓ(θt)\nabla^2\ell(\theta_t)(\theta_{t+1}-\theta_t) = -\nabla\ell(\theta_t), which makes the score approximately zero after the step. When the Hessian is negative definite and the score is nonzero, the Newton direction is an ascent direction, but the full step can overshoot and decrease the likelihood. A line search can shorten the step. If the starting value is poor or the Hessian is not negative definite, Newton-Raphson can diverge. Practical implementations often minimize the negative log-likelihood with quasi-Newton methods, add bounds, or reparameterize positive quantities using logarithms. For example, instead of optimizing σ2\sigma^2 directly, you can optimize log⁡σ\log\sigma and exponentiate the result. This keeps the standard deviation positive.

Identifiability, sampling uncertainty, and limitations

A model is identifiable if different parameter values produce different distributions for the data. Formally, if

Pθ1(A)=Pθ2(A)for every measurable event AP_{\theta_1}(A)=P_{\theta_2}(A) \quad\text{for every measurable event }A

implies θ1=θ2\theta_1=\theta_2, then the parameter is identifiable. Here Pθ(A)P_\theta(A) is the model probability of an event AA. If distinct parameters give the same distribution, no amount of data from that model can distinguish those equivalent values. A continuous equivalence can create a flat ridge, while a discrete label symmetry can create separate equivalent peaks. A mixture model with unlabeled components is a classic example: swapping the labels of two components gives the same likelihood. In linear regression, perfectly collinear predictor columns make X⊤XX^\top X singular, so different coefficient vectors can produce the same fitted values. We discussed the practical consequences of that in Multicollinearity.

Identifiability is a property of the model and the data design, not a property of the optimizer. A numerical optimizer may return a point on a flat ridge, but the data do not distinguish that point from the other equivalent points. Before trusting an estimate, ask whether the data contain enough variation to distinguish the parameters. If not, we need to simplify the model, collect more informative data, or impose a constraint.

Sampling uncertainty is different from identifiability. Even in an identifiable model, the maximum likelihood estimate is a random variable because it depends on a random sample. For a correctly specified identifiable model with an interior true parameter, sufficient smoothness, nonsingular Fisher information, a consistent maximizing solution, and the derivative-convergence conditions used in the asymptotic argument, we obtain:

n(θ^−θ0)→dN(0,I1(θ0)−1),\sqrt{n}\left(\hat\theta-\theta_0\right) \xrightarrow{d} N\left(0,I_1(\theta_0)^{-1}\right),

where:

  • n\sqrt{n}: the square root of sample size, which scales the centered estimation error to a nondegenerate limit under the stated regularity conditions
  • θ^\hat\theta: the maximum likelihood estimate
  • θ0\theta_0: the true parameter value
  • →d\xrightarrow{d}: convergence in distribution as n→∞n\to\infty
  • N(0,I1(θ0)−1)N(0,I_1(\theta_0)^{-1}): the limiting normal distribution with mean zero and covariance I1(θ0)−1I_1(\theta_0)^{-1}
  • I1(θ0)I_1(\theta_0): the per-observation Fisher information evaluated at the true parameter θ0\theta_0

This is the basis for the curvature-based standard errors above. The approximation can be poor in small samples, near boundaries, or when the model is misspecified. Alternatives include profile likelihood, a bootstrap appropriate to the sampling design, and Bayesian inference with an explicit prior. Each requires its own assumptions and coverage or sensitivity checks; none automatically repairs a boundary or a misspecified model.

Maximum likelihood also has failure modes that are worth recognizing. The likelihood can be unbounded, as in a Gaussian mixture when a component variance collapses to zero around a single point. In logistic regression, complete separation can push coefficients toward infinity because the likelihood keeps increasing as the separating boundary becomes sharper. Non-concave likelihoods can have multiple local maxima, so different starting values may produce different answers. And if the model is wrong, the estimate may be precise but precisely wrong.

Mathematical Properties

Maximum likelihood has several properties that make it useful beyond the basic examples. The first is invariance under reparameterization. If θ^\hat\theta is the maximum likelihood estimate of θ\theta, and gg is a one-to-one function, then g(θ^)g(\hat\theta) is the maximum likelihood estimate of g(θ)g(\theta). For example, if 0<p^<10<\hat p<1, then p^/(1−p^)\hat p/(1-\hat p) is the finite maximum likelihood estimate of the odds. This property is convenient, but it does not mean that standard errors transform by simply plugging in the transformed estimate. Uncertainty usually requires the delta method or a profile-likelihood calculation.

The second property is additivity for independent observations. The log-likelihood is a sum of per-observation log-density or log-mass contributions, so each new independent observation adds one term. This makes the likelihood scalable and explains why the curvature typically grows with sample size. In regular models, information adds across independent observations. For a correctly specified regular i.i.d. model with fixed, finite, positive definite per-observation information, total information is proportional to nn, and the usual large-sample standard errors shrink at rate 1/n1/\sqrt{n}.

Under regularity conditions, maximum likelihood estimators are consistent and asymptotically efficient. Consistency means the estimate converges to the true parameter as the sample size grows. Asymptotic efficiency means attaining the inverse-Fisher-information bound within the regular estimator class. It does not compare every possible consistent estimator at every parameter value. These are large-sample guarantees. They do not imply that the estimate is unbiased in a small sample, that the model is correct, or that the likelihood is well behaved in every finite dataset.

Finally, maximum likelihood is not the same as least squares in general. For independent Gaussian errors and any fixed common positive variance, maximizing over the mean parameters is equivalent to minimizing squared error. Bernoulli, Poisson, and other non-Gaussian likelihoods generally give different objectives, although their maximizing estimates can sometimes coincide with least-squares estimates. This is why the likelihood framework is more general than squared error, and why the choice of likelihood encodes assumptions about the data-generating process.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy