From STA238 Probability Statistics and Data Analysis II

Estimating a parameter

1. The question

You’re given a distribution and a set of data drawn from it, and one of the distribution’s parameters is unknown. Estimate it.

Two methods, and the question always names which one. Across all three past finals there isn’t a single case where you choose. Same input and output either way, different machinery inside, and they can give different answers on the same problem.

PaperQuestionMethod namedMarks
Apr 2023 Q1”Find the maximum likelihood estimator of θ”MLE3 + 3 + 4
Aug 2023 Q3a”Derive the maximum likelihood estimate for σ”MLE8
Aug 2023 Q3b”State the maximum likelihood estimates for α and β”MLE, support case2
Apr 2024 Q1a”Derive the maximum likelihood estimator for θ”MLE4
Apr 2024 Q3a”What is the method of moments estimator for λ?”MoM2

Two things that fall out of that table. Apr 2023 Q1 splits the four steps into separately marked parts, which confirms the marks are per step. And method of moments is worth far fewer marks than maximum likelihood, because it’s one line of algebra rather than four steps.

Aug 2023 Q3b says “state” rather than “derive,” which is the tell that it’s the support case where there’s nothing to differentiate.

2. Maximum likelihood

The idea: try every possible value of the parameter, and pick the one that makes the data you actually saw most probable.

Not the most probable parameter. The parameter under which your data was least surprising. The parameter itself is a fixed unknown, not something with a distribution.

The likelihood of a parameter is the probability of seeing all your data if that parameter were true. The observations are independent, so that’s the product of their individual densities:

L(θ)=i=1nfθ(xi)L(\theta) = \prod_{i=1}^n f_\theta(x_i)

2.1 The four steps

  1. Write the likelihood. Substitute the density and take the product over ii.
  2. Take the log. The product becomes a sum, which is what makes it differentiable.
  3. Differentiate with respect to the parameter and set to zero.
  4. Solve for the parameter.

Only the algebra inside changes with the distribution. The steps never do.

Step 2 is legal because log\log is increasing, so it doesn’t move where the maximum is. It’s necessary because differentiating a product of nn terms is unpleasant and differentiating a sum is not.

Step 3 finds the peak: the log-likelihood is a curve in θ\theta, and at its top the slope is zero.

There’s a fifth step some questions want, checking the second derivative is negative to confirm it’s a maximum. Papers often say you may assume it.

2.2 Worked: exponential

X1,,XniidExp(λ)X_1, \dots, X_n \overset{iid}{\sim} \text{Exp}(\lambda), with f(x)=λeλxf(x) = \lambda e^{-\lambda x}.

L(λ)=i=1nλeλxi=λneλixiL(\lambda) = \prod_{i=1}^n \lambda e^{-\lambda x_i} = \lambda^n e^{-\lambda \sum_i x_i}

nn copies of λ\lambda multiplied give λn\lambda^n, and multiplying exponentials adds the exponents.

(λ)=nlogλλixi\ell(\lambda) = n \log \lambda - \lambda \sum_i x_i ddλ=nλixi=0λ^=nixi=1xˉ\frac{d\ell}{d\lambda} = \frac{n}{\lambda} - \sum_i x_i = 0 \quad \Longrightarrow \quad \hat\lambda = \frac{n}{\sum_i x_i} = \frac{1}{\bar{x}}

Note this estimator is biased. Maximum likelihood promises nothing about bias.

3. When the parameter is in the support

The support is the range of values the distribution can produce. Usually the parameter only appears in the formula and the range is fixed, and then the four steps work.

Sometimes the parameter is one of the bounds. Unif(0,θ)\text{Unif}(0, \theta) has range 0xθ0 \le x \le \theta, so changing θ\theta changes which values are possible at all.

Then there’s a cliff rather than a peak. If θ\theta were below your largest observation, that observation would have been impossible, so the likelihood is exactly zero there:

L(θ)={1/θnθmaxixi0otherwiseL(\theta) = \begin{cases} 1/\theta^n & \theta \ge \max_i x_i \\ 0 & \text{otherwise}\end{cases}

Differentiating gets you nothing, because 1/θn1/\theta^n is strictly decreasing and its derivative is never zero. So reason about it instead:

  1. Write the likelihood with its case split.
  2. State which direction it moves. Smaller θ\theta gives a larger likelihood, because a narrower uniform is a taller one.
  3. Name the constraint. θ\theta cannot go below maxixi\max_i x_i.
  4. Push θ\theta to the boundary: θ^=maxixi\hat\theta = \max_i x_i.

Say on the page that the likelihood isn’t differentiable at the boundary and the maximum is at the edge of the feasible region. That’s where the marks are.

The recognition rule: if the parameter appears in the limits of the support, do not differentiate.

For Unif(α,β)\text{Unif}(\alpha, \beta) with both unknown, the same argument twice gives α^=minixi\hat\alpha = \min_i x_i and β^=maxixi\hat\beta = \max_i x_i. That’s Aug 2023 Q3b, 2 marks.

4. Method of moments

The other recipe, and the more intuitive one. Same input and output as maximum likelihood, different machinery, and in a sense the opposite direction:

  • Maximum likelihood searches. Consider every candidate parameter, score each by how probable it makes the data, take the winner.
  • Method of moments inverts. Compute a summary of the data, and read the parameter off it using a formula you already have.

The name is jargon rather than description. “Moment” is the technical term for E[Xk]\mathbb{E}[X^k], and the method matches the theoretical moments to the sample ones.

4.1 What a moment is

A moment is an expected value of a power of the random variable. The first moment is E[X]\mathbb{E}[X], which is the mean. The second is E[X2]\mathbb{E}[X^2]. The kk-th is E[Xk]\mathbb{E}[X^k]. That’s the whole definition.

Moments are not parameters. They’re a bridge between the two things you have. For any family, the moments are known formulas in the parameter, and those formulas are on the formula sheet:

FamilyE[X]\mathbb{E}[X]
Exp(λ)\text{Exp}(\lambda)1/λ1/\lambda
Unif(0,θ)\text{Unif}(0,\theta)θ/2\theta/2
Pois(λ)\text{Pois}(\lambda)λ\lambda
Binom(n,p)\text{Binom}(n,p)npnp

So a moment is something you can estimate from the sample and something with a known relationship to the parameter. That’s what makes it usable.

4.2 The method

  1. You want the parameter and can’t observe it.
  2. You can observe the sample mean, which estimates the true mean.
  3. The true mean is a known formula in the parameter.
  4. Substitute and solve backwards.

For Exp(λ)\text{Exp}(\lambda): theoretical mean is 1/λ1/\lambda, sample mean is xˉ\bar{x}, so 1/λ=xˉ1/\lambda = \bar{x} and λ^=1/xˉ\hat\lambda = 1/\bar{x}. One line.

For Pois(λ)\text{Pois}(\lambda) the mean is λ\lambda, so λ^=xˉ\hat\lambda = \bar{x} directly. That’s a coincidence of that family, not the general pattern.

4.3 More than one unknown

One unknown parameter needs one equation, so the first moment is enough. Two unknowns need two equations, so you use the first and second moments together:

E[X]=xˉandE[X2]=1nixi2\mathbb{E}[X] = \bar{x} \qquad \text{and} \qquad \mathbb{E}[X^2] = \frac{1}{n}\sum_i x_i^2

and solve the pair. Normal with both μ\mu and σ2\sigma^2 unknown is the standard case.

That’s why it’s moments plural: you use as many as you have unknowns.

4.4 It can disagree with maximum likelihood

Same problem, two legitimate estimators, different answers. Unif(0,θ)\text{Unif}(0,\theta) has mean θ/2\theta/2, so method of moments gives θ^=2xˉ\hat\theta = 2\bar{x}, while maximum likelihood gives maxixi\max_i x_i.

The MoM one is unbiased and noisy. The MLE one is biased low and much tighter. Neither dominates, which is what judging estimators is for.

Use maximum likelihood by default. Use method of moments when the question asks for it by name, or when the likelihood is intractable.

5. Invariance

If a question hands you the MLE of one thing and asks for the MLE of a function of it, apply the function. The MLE of g(θ)g(\theta) is g(θ^)g(\hat\theta), for invertible gg. Given σ^2\hat\sigma^2, the MLE of σ\sigma is σ^2\sqrt{\hat\sigma^2}.

Why it works. Square root is monotonic on positives, so it doesn’t move where the maximum is. Whatever value of σ2\sigma^2 maximizes the likelihood, its square root maximizes the same likelihood written in terms of σ\sigma. Nothing was recomputed, the axis was relabelled.

Say “by invariance” and apply the function. Free marks.

5.1 Why it needs a name

Because the same move fails for expectation, and the two get conflated.

E[T]=σ2\mathbb{E}[T] = \sigma^2 does not give E[T]=σ\mathbb{E}[\sqrt{T}] = \sigma. Concretely, suppose TT is 4 half the time and 16 half the time:

E[T]=10,E[T]3.16\mathbb{E}[T] = 10, \qquad \sqrt{\mathbb{E}[T]} \approx 3.16 4=2,16=4,E[T]=3\sqrt{4} = 2, \quad \sqrt{16} = 4, \qquad \mathbb{E}[\sqrt{T}] = 3

3 and 3.16 are different. Square root is curved: it pulls large values down harder than small ones, so shrinking first and then averaging gives less than averaging first.

For a straight line it’s fine. E[2T+5]=2E[T]+5\mathbb{E}[2T + 5] = 2\mathbb{E}[T] + 5 always, because linear functions preserve averages. The general statement is Jensen’s inequality: for a concave gg like \sqrt{\cdot}, E[g(T)]g(E[T])\mathbb{E}[g(T)] \le g(\mathbb{E}[T]), and the inequality flips for a convex gg like squaring.

So both of these are true of the same estimator at once: σ^2\sqrt{\hat\sigma^2} is the maximum likelihood estimator of σ\sigma, and it is biased for σ\sigma. Invariance is about maxima, bias is about averages, and they don’t constrain each other.

6. The algebra

The whole calculus surface for these questions.

Logs

  • log(ab)=loga+logb\log(ab) = \log a + \log b, which is what turns the product into a sum
  • log(an)=nloga\log(a^n) = n \log a
  • log(ek)=k\log(e^k) = k, which kills the exponential in every exponential-family density

Derivatives

  • ddθlogθ=1/θ\frac{d}{d\theta} \log \theta = 1/\theta
  • ddθ(cθ)=c\frac{d}{d\theta}(c\theta) = c
  • ddθθn=nθn1\frac{d}{d\theta} \theta^n = n\theta^{n-1}
  • Parameter in a denominator: rewrite first. x22σ2=x22σ2\frac{x^2}{2\sigma^2} = \frac{x^2}{2}\sigma^{-2}, then the power rule gives x2σ3-x^2\sigma^{-3}. This is the hardest move that appears.

Method marks are awarded per step, so writing the likelihood, logging it, differentiating and solving carries most of the credit even if the algebra slips.