Lecture notes · Introduction to Mathematical Statistics · Chapter 5

Chapter 5. Estimation: Lecture Notes

A probability model has parameters, and data are the only route to their values. This chapter is where the book turns from probability to statistics: two recipes for turning a sample into a number (maximum likelihood and the method of moments), intervals that say how far that number can be trusted, and the properties that separate a good estimator from a poor one: unbiasedness, small variance, the Cramér-Rao floor under that variance, sufficiency, consistency, and the Bayesian alternative in which the parameter itself has a distribution. The book states several of these results without proof or proves them only in examples; these notes add the missing arguments (when a stationary point really is the maximum, why the Wald interval works, why the Cramér-Rao bound holds and when it is attained, the factorization theorem in the continuous case, the Rao-Blackwell theorem, consistency of the maximum likelihood estimator, the Bayes estimate under the book's inventory loss), and correct three errors of the printed text.

Course home Ch. 1 Introduction Ch. 2 Probability Ch. 3 Random variables Ch. 4 Special distributions Ch. 5 Estimation Ch. 6 Hypothesis testing Ch. 7 Normal-based inference Ch. 8 Types of data Ch. 9 Two-sample inference Ch. 10 Goodness of fit Ch. 11 Regression Ch. 12 Analysis of variance Ch. 13 Randomized blocks Ch. 14 Nonparametric statistics

How to use the gap boxes and selected questions

Each Filling the gap box completes a step or a proof the book leaves out, and each selected question asks you to apply the chapter. Try it yourself first. When you are stuck, open Hint 1; the next hint unlocks one minute after you open the previous one, so take one hint at a time and think about it before moving on: the key idea first, then the tools, then the steps, with intermediate results to aim for. The full proof or solution appears after the last hint and unlocks two minutes later: use it to check your own argument. If you use a generative AI assistant, use it the same way: ask for a hint or for the next step only, then check what it says against these notes (why I teach this way). Spotted a mistake? Use the Report an error link at the end of each box: confirmed errors are corrected and listed, with thanks, in the errata.

How to read these notes

They follow the book. Sections carry the book's numbers (5.1 to 5.9) and numbered items keep theirs (Definition 5.2.1, Theorem 5.5.1, Example 5.4.6, Case Study 5.8.1). Everything is written in new words; the book is cited for each result, example and figure, and displayed equations that the book numbers keep its number, e.g. \((5.2.1)\).

Filling the gaps. Wherever the book says "it can be shown", refers to another text for a proof, leaves an exercise to the reader or works an example too fast to follow, an orange Filling the gap box gives the full argument. Where the first-year notes already prove a result in full (the Cramér-Rao bound, the normal maximum likelihood estimates, the Wald interval, Chebyshev's inequality), the box gives the statement, a short sketch and a link. Proofs and derivations start hidden: open one with its bar, or use the button below. Each gap box and each selected question offers graded hints, one at a time, before the full solution.

Figures and demonstrations. Eleven figures of the chapter (5.1.1, 5.1.2, 5.2.1, 5.2.2, 5.3.1 to 5.3.4, 5.4.1, 5.7.1 and 5.8.1) are reproduced, Figure 5.3.2 with the book's own simulated intervals of Table 5.3.1; three own figures (x5.1 to x5.3) set the fitted count models against their tables, compare two unbiased estimators with the Cramér-Rao "bound" they beat, and show a prior becoming a posterior and a parametric bootstrap. The two schematic drawings of estimator densities (Figures 5.4.2 and 5.4.3) are not redrawn. All are computed by the Python code. The ▶ Demo boxes open an interactive demonstration already set to the case being discussed.

Main reference

R. J. Larsen and M. L. Marx, An Introduction to Mathematical Statistics and Its Applications, 6th edition, Pearson (2018), Chapter 5, pages 278–342. Section, case-study, figure, equation and question numbers below refer to this book. Further reading is listed in the references.

The explanations, derivations, figures and code are my own; equations are cited by their numbers in the book.

Companion courses

Estimation is developed, at other levels and in other words, in three companion courses of this site. Where a proof there is complete, these notes give the statement and a short argument and link to it.

New here: a usable test for "the stationary point is the maximum" (Filling the gap 5.1), the zero-truncated Poisson equation (5.2), Max's chances as a posterior probability (5.8), when the Cramér-Rao bound is attained and a best estimator that is not efficient (5.13, 5.14), why Example 5.5.2 escapes the bound (5.15), the factorization theorem for densities (5.16), a corrected account of what sufficiency buys (5.19), consistency of the maximum likelihood estimator (5.20), the inventory loss of Example 5.8.5 solved (5.23) and what the bootstrap of Section 5.9 actually estimates (5.24).

The chapter at a glance

  • 5.1–5.2 The likelihood is the probability of the data seen as a function of the parameter; its maximiser is the maximum likelihood estimate (Definition 5.2.2, 5.1). The method of moments matches sample moments to model moments (Definition 5.2.3, 5.4). When the support depends on the parameter, the answer is an order statistic (Example 5.2.4).
  • 5.3 Inverting a probability statement about \(\bar Y\) gives a confidence interval; for a proportion, Theorem 5.3.1, the margin of error and the sample size of Theorem 5.3.2 (Theorems 5.3.1, 5.3.2, 5.7, 5.9).
  • 5.4–5.5 Unbiasedness and relative efficiency (Definitions 5.4.1, 5.4.2); no unbiased estimator can beat \(1/(nI(\theta))\) under regularity (Theorem 5.5.1, 5.12–5.15).
  • 5.6 A sufficient statistic keeps all the information the sample has about \(\theta\): the factorization criterion (Definition 5.6.1, Theorem 5.6.1, 5.16) and the Rao-Blackwell improvement (5.19).
  • 5.7 Consistency is convergence in probability to \(\theta\); Chebyshev's inequality gives the weak law (Definition 5.7.1, Theorem 5.7.1, 5.20).
  • 5.8–5.9 Priors, posteriors, conjugate updating and Bayes estimates under squared, absolute and asymmetric loss (Definition 5.8.1, Theorem 5.8.1, 5.23); the bootstrap estimate of a standard error (5.24).

Notation. A random sample \(Y_1,\dots,Y_n\) (or \(X_1,\dots,X_n\) when discrete) has density \(f_Y(y;\theta)\) (or probability function \(p_X(k;\theta)\)); the book calls both "pdf". \(L(\theta)\) is the likelihood, \(\ell(\theta)=\ln L(\theta)\), an estimator is \(\hat\theta=h(Y_1,\dots,Y_n)\) and its value on the data, the estimate, is \(\theta_e\). \(\bar Y\) is the sample mean, \(Y_{\min}\) and \(Y_{\max}\) the extreme order statistics, \(z_{\alpha/2}\) the upper \(\alpha/2\) point of the standard Normal, \(\Phi\) its cdf and \(\varphi\) its density.

Prerequisites. Chapter 3 (expectations, variance of sums, order statistics, conditional densities) and Chapter 4 of the book (the Poisson, Normal, geometric, negative binomial and gamma families and the central limit theorem).

Derivations start hidden: click any bar to open one.

5.1 Introduction

pp. 278–280 Every model of Chapter 4 is really a family indexed by parameters: the Poisson by its rate \(\lambda\), the binomial by \(p\), the Normal by \(\mu\) and \(\sigma\). Changing the parameter changes every probability (Figure 5.1.1), so before a model can predict anything its parameters must be estimated from a sample.

Two bar charts of Poisson probabilities. Left, lambda equal to 1: bars of height 0.368 at k equal 0 and 1, 0.184 at 2, then falling quickly to nearly zero by k equal 5. Right, lambda equal to 4: a wider hump with the tallest bars, about 0.195, at k equal 3 and 4, and visible probability up to about k equal 10.
Figure 5.1.1. The Poisson probability function \(e^{-\lambda}\lambda^k/k!\) for (a) \(\lambda=1\) and (b) \(\lambda=4\): one family, two very different predictions. Reproduces Larsen and Marx (2018), Figure 5.1.1. Code: ch05_estimation.py, fig_5_1_1.

Example 5.1.1: three tosses of a coin pp. 279–280

A coin with unknown \(p=\P(\text{heads})\) shows H, H, T. With \(X_i=1\) for heads, the three tosses are independent with \(p_X(k)=p^k(1-p)^{1-k}\), so the probability of what was seen is \(p^2(1-p)\). Its largest value over \(0\le p\le1\) is at \(p=2/3\) (Figure 5.1.2): of all coins, the one that makes HHT most probable has \(p=2/3\). For \(n\) tosses with \(s=\sum k_i\) heads the same reasoning gives \(p^s(1-p)^{n-s}\), whose derivative vanishes at \(p=s/n\) (equation (5.1.1) of the book). That this stationary point is the maximum is checked in Filling the gap 5.1.

The curve p squared times one minus p for p from 0 to 1: zero at both ends, rising to a single peak of height 4/27, about 0.148, at p equal 2/3, marked with a dashed vertical line.
Figure 5.1.2. The probability \(p^2(1-p)\) of the sequence HHT as a function of \(p\); the maximum, \(4/27\), is at \(p=2/3\). Reproduces Larsen and Marx (2018), Figure 5.1.2. Code: ch05_estimation.py, fig_5_1_2.

Vocabulary. Any function of the sample meant to approximate a parameter is a statistic or estimator, written \(\hat\theta=h(Y_1,\dots,Y_n)\); it is a random variable, with a distribution, a mean and a variance. Its numerical value on the observed data is an estimate, written \(\theta_e\). In Example 5.1.1, \(\hat p=\frac1n\sum X_i\) is the maximum likelihood estimator and \(2/3\) the maximum likelihood estimate.

See also (companion courses): Section 6.3.1 of the graduate course (point estimation); the likelihood demo (preset 1) climbs the likelihood of a proportion.

5.2 Estimating Parameters: The Method of Maximum Likelihood and the Method of Moments

The method of maximum likelihood

Definitions 5.2.1 and 5.2.2 (likelihood, maximum likelihood estimate) p. 281

For a random sample \(k_1,\dots,k_n\) from \(p_X(k;\theta)\), or \(y_1,\dots,y_n\) from \(f_Y(y;\theta)\), the likelihood is

\[ L(\theta)=\prod_{i=1}^n p_X(k_i;\theta)\qquad\text{or}\qquad L(\theta)=\prod_{i=1}^n f_Y(y_i;\theta). \]

A value \(\theta_e\) with \(L(\theta_e)\ge L(\theta)\) for every admissible \(\theta\) is a maximum likelihood estimate; the corresponding function of the sample is the maximum likelihood estimator (MLE).

The formula is the joint probability (or density) of the sample, but read in the other direction: the data are fixed and \(\theta\) varies. Because \(\ln\) is strictly increasing, \(L\) and \(\ell=\ln L\) have the same maximisers, and \(\ell\) turns the product into a sum.

Example 5.2.1: the Poisson rate p. 282

For a Poisson sample, \(\ell(\lambda)=-n\lambda+\big(\sum k_i\big)\ln\lambda-\ln\prod k_i!\) and \(\ell'(\lambda)=-n+\sum k_i/\lambda\), which vanishes at \(\lambda_e=\bar k\). This justifies the sample mean 3.87 used for the alpha particles of Case Study 4.2.2. The book notes that \(\ell''(\lambda)=-\sum k_i/\lambda^2<0\).

Example 5.2.2: a monitor with a backup pp. 282–283

The sum of two independent exponential lifetimes with mean \(\theta\) has the gamma density \(f_Y(y;\theta)=ye^{-y/\theta}/\theta^2\), \(y\ge0\). Then \(\ell(\theta)=-2n\ln\theta+\sum\ln y_i-\frac1\theta\sum y_i\) and \(\ell'(\theta)=-\frac{2n}\theta+\frac{1}{\theta^2}\sum y_i\), so

\[ \theta_e=\frac{1}{2n}\sum_{i=1}^n y_i=\frac{56.0}{10}=5.6 \]

for the five failure times 9.2, 5.6, 18.4, 12.1, 10.7.

Filling the gap 5.1: when the root of the likelihood equation is the maximum pp. 280–284

The book solves \(\ell'(\theta)=0\) and, apart from the Comment after Example 5.2.1, does not check that the root is a global maximum, nor what happens when the data sit at the edge of the parameter space. A simple sufficient condition settles all the one-parameter examples of the section.

Lemma. Let \(\ell\) be differentiable on an open interval \((a,b)\), and suppose there is \(\theta^*\in(a,b)\) with \(\ell'(\theta)>0\) for \(a<\theta<\theta^*\) and \(\ell'(\theta)<0\) for \(\theta^*<\theta<b\). Then \(\theta^*\) is the unique maximiser of \(\ell\) (hence of \(L\)) on \((a,b)\). In particular this holds if \(\ell'(\theta^*)=0\) and \(\ell''<0\) on \((a,b)\).

Hint 1 of 5: the key idea

A function that rises and then falls has its peak where it turns. How can the sign of \(\ell'\) on each side of \(\theta^*\) be turned into a comparison of \(\ell(\theta)\) with \(\ell(\theta^*)\)?

Hint 2 of 5: tools you will need
  • The mean value theorem.
  • \(\ell''<0\) makes \(\ell'\) strictly decreasing.
  • Handling boundary data (all successes or all failures) separately.
Hint 3 of 5: step 1

For \(\theta<\theta^*\) write \(\ell(\theta^*)-\ell(\theta)=\ell'(\xi)(\theta^*-\theta)\). Aim for: a product of two positive numbers; then the mirror case.

Hint 4 of 5: step 2

Bernoulli and Poisson: compute \(\ell''\). Aim for: a negative expression whenever \(0<s<n\) (or \(s>0\)).

Hint 5 of 5: step 3

Gamma: \(\ell''\) changes sign, so use the sign of \(\ell'=(\sum y_i-2n\theta)/\theta^2\) directly. Geometric: rewrite it as the Bernoulli case.

Proof

If \(a<\theta<\theta^*\), the mean value theorem gives \(\ell(\theta^*)-\ell(\theta)=\ell'(\xi)(\theta^*-\theta)\) for some \(\xi\in(\theta,\theta^*)\), and both factors are positive, so \(\ell(\theta)<\ell(\theta^*)\). If \(\theta^*<\theta<b\), the same identity has \(\ell'(\xi)<0\) and \(\theta^*-\theta<0\), so again \(\ell(\theta)<\ell(\theta^*)\). When \(\ell''<0\), \(\ell'\) is strictly decreasing, so it is positive before its zero and negative after it. ∎

The examples. (i) Bernoulli (Example 5.1.1) with \(s=\sum k_i\): \(\ell(p)=s\ln p+(n-s)\ln(1-p)\) and \(\ell''(p)=-s/p^2-(n-s)/(1-p)^2<0\) on \((0,1)\) when \(0<s<n\), so \(p_e=s/n\) is the unique maximum. If \(s=0\), \(L(p)=(1-p)^n\) decreases and its largest value on \([0,1]\) is at \(p=0=s/n\); if \(s=n\) it is at \(p=1\). The formula \(s/n\) survives, but only because the endpoints are allowed.

(ii) Poisson (Example 5.2.1): for \(s=\sum k_i>0\), \(\ell''(\lambda)=-s/\lambda^2<0\) on \((0,\infty)\) and \(\ell'(\bar k)=0\). If every count is 0, \(L(\lambda)=e^{-n\lambda}\) has no maximum on \((0,\infty)\): the supremum is approached as \(\lambda\to0\).

(iii) Gamma (Example 5.2.2): here \(\ell''(\theta)=2n/\theta^2-2\sum y_i/\theta^3\) is positive for \(\theta>\sum y_i/n\), so \(\ell\) is not concave. The lemma still applies, because \[\ell'(\theta)=\frac{\sum y_i-2n\theta}{\theta^2}\] is positive for \(\theta<\sum y_i/(2n)\) and negative after. So \(\theta_e=\bar y/2\) is the unique maximum.

(iv) Geometric (Case Study 5.2.1): \(\ell(p)=n\ln p+(\sum k_i-n)\ln(1-p)\) is case (i) with \(n\) successes and \(\sum k_i-n\) failures, so \(p_e=n/\sum k_i=1/\bar k\), equal to 1 when every \(k_i=1\). ∎

Case Study 5.2.1: does the stock market remember? pp. 283–284

If daily rises and falls of the market were independent with a fixed chance \(p\) of a rise, the number \(X\) of days until the next rise, counted from a fall, would be geometric, \(p_X(k)=(1-p)^{k-1}p\). For 128 such runs of the 2006–2007 Dow Jones closing average (Table 5.2.1), \(\sum k_i=221\), so \(p_e=128/221=0.5792\) and the expected frequencies \(128(1-p_e)^{k-1}p_e\) are 74.14, 31.20, 13.13, 5.52, 2.32 and (the remainder) 1.69, close to the observed 72, 35, 11, 6, 2, 2 (Figure x5.1a). A formal test of fit is in Chapter 10 of the book.

Example 5.2.3: the zero-truncated Poisson and the hurricane years pp. 285–286, (5.2.1)

If the value 0 cannot be observed, the Poisson probabilities of \(k\ge1\) are renormalised by \(1-e^{-\lambda}\):

\[ p_{X_T}(k)=\frac{\lambda^k}{(e^\lambda-1)\,k!},\qquad k=1,2,\dots \]

The log-likelihood is \(\ell(\lambda)=(\sum k_i)\ln\lambda-n\ln(e^\lambda-1)-\ln\prod k_i!\), and \(\ell'(\lambda)=0\) reads

\[ \frac{\lambda e^\lambda}{e^\lambda-1}=\bar k. \tag{5.2.1} \]

For the 49 years from 1950 to 2012 with at least one hurricane (Table 5.2.2), \(\bar k=91/49=1.857\), and the root is \(\lambda_e=1.398\) (the book's 1.40). With \(\lambda=1.40\) the expected numbers of years with 1, 2, 3 and 4 or more hurricanes are 22.45, 15.72, 7.33 and 3.50 (Table 5.2.3), against 27, 10, 8 and 4 observed (Figure x5.1b).

Filling the gap 5.2: the left side of (5.2.1) is the truncated mean, and the equation has exactly one root, the maximum p. 285

The book states without proof that the left side of (5.2.1) is the mean of the truncated Poisson, and solves the equation by trial and error. Here: (a) \(\E X_T=\lambda e^\lambda/(e^\lambda-1)\); (b) \(g(\lambda)=\lambda e^\lambda/(e^\lambda-1)\) increases strictly from 1 (as \(\lambda\to0\)) to \(\infty\); hence (c) (5.2.1) has a root exactly when \(\bar k>1\), the root is unique, and it is the maximum likelihood estimate.

Hint 1 of 5: the key idea

(a) is a series with a shifted index; (b) is about the sign of a derivative; (c) then follows from Filling the gap 5.1. Which function of \(\lambda\) is \(\ell'(\lambda)\) proportional to?

Hint 2 of 5: tools you will need
  • \(\sum_{j\ge0}\lambda^j/j!=e^\lambda\).
  • Writing \(g(\lambda)=\lambda/(1-e^{-\lambda})\) and differentiating.
  • A function vanishing at 0 with positive derivative is positive.
  • Filling the gap 5.1 (the sign lemma).
Hint 3 of 5: part (a)

Drop the \(k=0\) term and pull out \(\lambda/(e^\lambda-1)\). Aim for: \(\sum_{k\ge1}\lambda^{k-1}/(k-1)!\).

Hint 4 of 5: part (b)

The numerator of \(g'\) is \(h(\lambda)=1-e^{-\lambda}-\lambda e^{-\lambda}\). Aim for: \(h(0)=0\) and \(h'(\lambda)=\lambda e^{-\lambda}\). Also find \(g(0+)\) and \(g(\infty)\).

Hint 5 of 5: part (c)

Show \(\ell'(\lambda)=\frac n\lambda(\bar k-g(\lambda))\) and read off its sign on each side of the root.

Proof

(a) Drop the \(k=0\) term and shift the index:

\[ \E X_T=\sum_{k\ge1}\frac{k\lambda^k}{(e^\lambda-1)k!}=\frac{\lambda}{e^\lambda-1}\sum_{k\ge1}\frac{\lambda^{k-1}}{(k-1)!}=\frac{\lambda e^\lambda}{e^\lambda-1}. \]

(b) Write \(g(\lambda)=\lambda/(1-e^{-\lambda})\). Then

\[ g'(\lambda)=\frac{h(\lambda)}{(1-e^{-\lambda})^2},\qquad h(\lambda)=1-e^{-\lambda}-\lambda e^{-\lambda}. \]

Now \(h(0)=0\) and \(h'(\lambda)=e^{-\lambda}-e^{-\lambda}+\lambda e^{-\lambda}=\lambda e^{-\lambda}>0\) for \(\lambda>0\), so \(h>0\) and \(g\) is strictly increasing on \((0,\infty)\). As \(\lambda\to0\), \(1-e^{-\lambda}=\lambda+O(\lambda^2)\), so \(g(\lambda)\to1\); as \(\lambda\to\infty\), \(g(\lambda)\ge\lambda\to\infty\).

(c) Since \(g\) is continuous and strictly increasing from 1 to \(\infty\), \(g(\lambda)=\bar k\) has exactly one root \(\lambda^*\) when \(\bar k>1\) and none when \(\bar k=1\) (every observation equal to 1). Moreover

\[ \ell'(\lambda)=\frac{\sum k_i}{\lambda}-\frac{ne^\lambda}{e^\lambda-1}=\frac n\lambda\big(\bar k-g(\lambda)\big), \]

which is positive for \(\lambda<\lambda^*\) and negative for \(\lambda>\lambda^*\), so \(\lambda^*\) is the unique maximum by the lemma of Filling the gap 5.1. When \(\bar k=1\), \(\ell'<0\) everywhere and there is no maximum. Equation (5.2.1) says "model mean = sample mean": the maximum likelihood and moment estimates coincide here, a property of exponential families. The precise root for the hurricane data is \(\lambda_e=1.3985\); with it the expected counts are 22.47, 15.72, 7.33 and 3.48. ∎

Order statistics as maximum likelihood estimates

Example 5.2.4: an exponential with an unknown threshold pp. 286–287

For \(f_Y(y;\theta)=e^{-(y-\theta)}\), \(y\ge\theta\), the likelihood is \(e^{-\sum y_i+n\theta}\) provided every \(y_i\ge\theta\), and 0 otherwise. Its derivative in \(\theta\) is never zero; the likelihood simply increases with \(\theta\) until \(\theta\) reaches the smallest observation, where it drops to 0. So \(\theta_e=y_{\min}\) (Figure 5.2.1). Writing the support condition with an indicator, \(L(\theta)=e^{-\sum y_i+n\theta}\,\one\{\theta\le y_{\min}\}\), makes this explicit; the same device reappears in Section 5.6.

Left panel: the density e to the minus (y minus theta), zero to the left of theta and jumping to 1 at theta, then decaying; eight sample points are marked as red ticks on the axis, the smallest labelled y prime 1 equals y min. Right panel: the likelihood as a function of theta, rising exponentially up to y min and dropping to zero just after it.
Figure 5.2.1. (a) The threshold density \(e^{-(y-\theta)}\), \(y\ge\theta\), with a sample of eight observations; the threshold cannot exceed the smallest of them. (b) Added here: the likelihood \(L(\theta)\), which increases up to \(y_{\min}\) and is 0 beyond, so it is maximised at an order statistic, not at a root of \(L'(\theta)=0\). Panel (a) reproduces Larsen and Marx (2018), Figure 5.2.1. Code: ch05_estimation.py, fig_5_2_1.
▶ DemoThe uniform model: the top of the likelihood is at an edgeThe first-year likelihood demo, preset 6: the likelihood of Uniform(0, \(\theta\)) data peaks at the largest observation (Question 5.2.10).

Several parameters

Example 5.2.5: the Normal mean and variance pp. 287–288, (5.2.2), (5.2.3)

With \(\ell(\mu,\sigma^2)=-\frac n2\ln(2\pi\sigma^2)-\frac1{2\sigma^2}\sum(y_i-\mu)^2\), setting both partial derivatives to zero gives \(\sum(y_i-\mu)=0\) (5.2.2) and \(-n\sigma^2+\sum(y_i-\mu)^2=0\) (5.2.3), so

\[ \mu_e=\bar y,\qquad \sigma^2_e=\frac1n\sum_{i=1}^n(y_i-\bar y)^2. \]

Filling the gap 5.3: the Normal solution is the global maximum p. 288

The book stops at the stationary point. If \(\sum(y_i-\bar y)^2>0\), the pair \((\bar y,\sigma^2_e)\) is the unique global maximiser of \(L(\mu,\sigma^2)\) over \(\R\times(0,\infty)\); if all observations are equal there is no maximum. The first-year notes prove this in full (Theorem 2.3); here is the sketch.

Hint 1 of 4: the key idea

Maximise in two stages: first over \(\mu\) with \(\sigma^2\) fixed, then over \(\sigma^2\). Why is the best \(\mu\) the same for every \(\sigma^2\)?

Hint 2 of 4: tools you will need
  • The decomposition \(\sum(y_i-\mu)^2=\sum(y_i-\bar y)^2+n(\bar y-\mu)^2\).
  • Filling the gap 5.1 for a function of one variable.
  • Theorem 2.3 of the first-year notes.
Hint 3 of 4: step 1

Expand around \(\bar y\). Aim for: the cross term vanishes, so \(\mu=\bar y\) minimises the sum of squares.

Hint 4 of 4: step 2

With \(S=\sum(y_i-\bar y)^2\), maximise \(m(v)=-\frac n2\ln(2\pi v)-\frac S{2v}\). Aim for: \(m'(v)=(S-nv)/(2v^2)\); then treat \(S=0\).

Proof (sketch)

For every \(\mu\), \(\sum(y_i-\mu)^2=\sum(y_i-\bar y)^2+n(\bar y-\mu)^2\) (expand around \(\bar y\); the cross term is \(2(\bar y-\mu)\sum(y_i-\bar y)=0\)). So for any fixed \(\sigma^2\) the log-likelihood is largest at \(\mu=\bar y\), whatever \(\sigma^2\) is. Put \(S=\sum(y_i-\bar y)^2\) and \(v=\sigma^2\); it remains to maximise \(m(v)=-\frac n2\ln(2\pi v)-\frac{S}{2v}\). Its derivative \(m'(v)=\frac{S-nv}{2v^2}\) is positive for \(v<S/n\) and negative after, so the lemma of Filling the gap 5.1 gives the unique maximum at \(v=S/n\). If \(S=0\), \(m(v)=-\frac n2\ln(2\pi v)\to\infty\) as \(v\to0\) and there is no maximum. ∎

See also: Section 9.3 of the graduate course and Section 4.2.5 of the machine-learning course.

The method of moments

Definition 5.2.3 (method-of-moments estimates) p. 290

For a model with \(s\) unknown parameters \(\theta_1,\dots,\theta_s\), the method-of-moments estimates solve the \(s\) equations

\[ \E(Y^j)=\frac1n\sum_{i=1}^n y_i^j,\qquad j=1,\dots,s, \]

with the moments \(\E(Y^j)\) computed from the model as functions of the parameters (sums in the discrete case).

Example 5.2.6 pp. 290–291

For \(f_Y(y;\theta)=\theta y^{\theta-1}\) on \([0,1]\), \(\E Y=\theta/(\theta+1)\). Setting this equal to \(\bar y\) gives \(\theta_e=\bar y/(1-\bar y)\); for the sample 0.42, 0.10, 0.65, 0.23, \(\bar y=0.35\) and \(\theta_e=0.54\).

Example 5.2.7: the negative binomial by moments p. 291

For \(p_X(k;p,r)=\binom{k+r-1}{k}(1-p)^kp^r\), \(k=0,1,\dots\), the book uses \(\E X=r(1-p)/p\) and \(\V X=r(1-p)/p^2\) and solves \(r(1-p)/p=\bar k\), \(r(1-p)/p^2=\hat\sigma^2\), where \(\hat\sigma^2=\frac1n\sum(k_i-\bar k)^2\):

\[ p_e=\frac{\bar k}{\hat\sigma^2},\qquad r_e=\frac{\bar k^2}{\hat\sigma^2-\bar k}. \]

Case Study 5.2.2: a century of large earthquakes pp. 291–292

The yearly numbers of earthquakes of magnitude above 7 from 1900 to 1999 (Table 5.2.4) have \(\bar k=19.83\) and \(\hat\sigma^2=50.69\), so \(p_e=0.391\) and \(r_e=12.74\). The fitted probabilities of the classes 0–5, 6–10, \(\dots\) give expected numbers of years 0.5, 7.1, 21.5, 28.4, 22.4, 12.3, 5.2, 1.8, 0.7 against the observed 0, 10, 20, 23, 27, 12, 5, 2, 1 (Figure 5.2.2; the book's first two entries are discussed in the notes on the book).

Histogram of yearly earthquake counts in classes of width 5: 0 years for 0 to 5, 10 for 6 to 10, 20 for 11 to 15, 23 for 16 to 20, 27 for 21 to 25, 12 for 26 to 30, 5, 2 and 1 for the last three classes. A red curve, five times one hundred times the fitted negative binomial probabilities, rises to about 29 near 17 and follows the bars down the right tail.
Figure 5.2.2. The yearly numbers of large earthquakes in classes of width 5 (Table 5.2.4), skewed to the right. Added: the negative binomial fitted by moments (\(r_e=12.74\), \(p_e=0.391\)), scaled to the histogram. Reproduces Larsen and Marx (2018), Figure 5.2.2. Code: ch05_estimation.py, fig_5_2_2.

Filling the gap 5.4: central moments may replace raw ones; the negative binomial mean and variance; when the moment equations have a solution p. 291; Questions 5.2.27, 4.5.7

Example 5.2.7 relies on three facts the book leaves to questions: (a) solving \(\E Y=\bar y\), \(\V Y=\hat\sigma^2\) is the same as Definition 5.2.3 with \(s=2\); (b) the negative binomial has mean \(r(1-p)/p\) and variance \(r(1-p)/p^2\) for every real \(r>0\); (c) the solution is a valid parameter (\(0<p_e<1\), \(r_e>0\)) exactly when \(\hat\sigma^2>\bar k\).

Hint 1 of 5: the key idea

(a) Variance is a second moment minus a squared first moment. (b) Shift the summation index to recognise another negative binomial series. (c) Solve the two equations and ask when the answers are valid parameters.

Hint 2 of 5: tools you will need
  • \(\V Y=\E Y^2-(\E Y)^2\).
  • \(k\binom{k+r-1}{k}=r\binom{k+r-1}{k-1}\).
  • \(\sum_{j\ge0}\binom{j+m-1}{j}x^j=(1-x)^{-m}\).
Hint 3 of 5: part (a)

Subtract \((\E Y)^2=\bar y^2\) from both sides of the second raw-moment equation. Aim for: \(\V Y=\hat\sigma^2\).

Hint 4 of 5: part (b)

Compute \(\E X\) and then \(\E X(X-1)\) with the identity. Aim for: \(r(1-p)/p\) and \(r(r+1)(1-p)^2/p^2\).

Hint 5 of 5: part (c)

Divide the equations to get \(p\), then \(r\). Aim for: both valid exactly when \(\hat\sigma^2>\bar k\).

Proof

(a) Since \(\V Y=\E(Y^2)-(\E Y)^2\) and \(\hat\sigma^2=\frac1n\sum y_i^2-\bar y^2\), the pair of equations \(\E Y=\bar y\), \(\E(Y^2)=\frac1n\sum y_i^2\) and the pair \(\E Y=\bar y\), \(\V Y=\hat\sigma^2\) differ by subtracting the equal quantities \((\E Y)^2\) and \(\bar y^2\) from the second equation; each pair implies the other.

(b) Use \(k\binom{k+r-1}{k}=r\binom{k+r-1}{k-1}\) (both equal \((k+r-1)\cdots(r+1)\,r/(k-1)!\)) and the negative binomial series \(\sum_{j\ge0}\binom{j+m-1}{j}x^j=(1-x)^{-m}\) for \(|x|<1\), \(m>0\). With \(q=1-p\),

\[ \E X=\sum_{k\ge1}r\binom{k+r-1}{k-1}q^kp^r=rq\,p^r\sum_{j\ge0}\binom{j+r}{j}q^j=rq\,p^r\,p^{-(r+1)}=\frac{r(1-p)}{p}. \]

Applying the identity twice, \(k(k-1)\binom{k+r-1}{k}=r(r+1)\binom{k+r-1}{k-2}\), and the same series with \(m=r+2\) give \(\E X(X-1)=r(r+1)q^2/p^2\). Hence

\[ \V X=\frac{r(r+1)q^2}{p^2}+\frac{rq}{p}-\frac{r^2q^2}{p^2}=\frac{rq^2}{p^2}+\frac{rq}{p}=\frac{rq}{p^2}(q+p)=\frac{r(1-p)}{p^2}. \]

(c) Dividing the two equations gives \(p=\bar k/\hat\sigma^2\), and then \(r=\bar kp/(1-p)=\bar k^2/(\hat\sigma^2-\bar k)\). Both are valid parameters iff \(\bar k/\hat\sigma^2<1\), that is \(\hat\sigma^2>\bar k\). The model itself always has variance larger than its mean (\(\V X=\E X/p\)), so the method can only fit overdispersed data; Poisson-like data with \(\hat\sigma^2\le\bar k\) give no solution. The earthquakes pass (50.69 against 19.83). ∎

Three panels of observed against fitted counts. (a) Days down before a rise, 1 to 6 or more: observed 72, 35, 11, 6, 2, 2 against geometric expected 74.1, 31.2, 13.1, 5.5, 2.3, 1.7. (b) Hurricanes per year, 1 to 4 or more: observed 27, 10, 8, 4 against truncated Poisson expected 22.5, 15.7, 7.3, 3.5. (c) Errors on a coordination test, 0 to 30: decreasing observed bars from 82, with the book's printed predictions as black dots lying on a red curve for p equal 0.0955 and above a dashed green curve for p equal 0.106 at the first few counts.
Figure x5.1 (own figure). Count models fitted in the chapter. (a) Case Study 5.2.1: the geometric model with \(p_e=0.579\). (b) Example 5.2.3: the zero-truncated Poisson with \(\lambda_e=1.398\). (c) Case Study 5.8.2: the negative binomial with \(s=0.8\); the book's printed predictions (dots) are close to the maximum likelihood fit \(p=0.0955\) (red) and not to the stated \(p=0.106\) (dashed green); see the notes on the book. Data: Tables 5.2.1, 5.2.2 and 5.8.2 of Larsen and Marx (2018). Code: ch05_estimation.py, fig_x5_1.

See also: Section 9.2 of the graduate course (moment estimators and their asymptotic normality) and Section 4.4.1 of the machine-learning course.

5.3 Interval Estimation

pp. 293–294 A point estimate says nothing about its own precision: \(\lambda_e=6.8\) from six Poisson counts could be off by 0.1 or by 5. A confidence interval attaches that precision, using the sampling distribution of the estimator.

Example 5.3.1: inverting a probability statement pp. 294–295, (5.3.1)

Four observations 6.5, 9.2, 9.9, 12.4 come from \(\N(\mu,0.8^2)\). Since \((\bar Y-\mu)/(0.8/\sqrt4)\) is standard Normal whatever \(\mu\) is,

\[ 0.95=\P\Big(-1.96\le\frac{\bar Y-\mu}{0.8/\sqrt4}\le1.96\Big)=\P\Big(\bar Y-1.96\tfrac{0.8}{\sqrt4}\le\mu\le\bar Y+1.96\tfrac{0.8}{\sqrt4}\Big). \]

The random interval \(\bar Y\pm1.96(0.8)/\sqrt4\) contains \(\mu\) with probability 0.95; on these data, \(\bar y=9.50\) and the 95% confidence interval is \((8.72,\ 10.28)\). In general \(\bar y\pm z_{\alpha/2}\sigma/\sqrt n\) is a \(100(1-\alpha)\%\) interval.

The standard Normal density with the region between minus 1.96 and 1.96 shaded and labelled area equals 0.95.
Figure 5.3.1. The pivot \((\bar Y-\mu)/(0.8/\sqrt4)\) is standard Normal; 95% of its distribution lies between \(-1.96\) and \(1.96\). Reproduces Larsen and Marx (2018), Figure 5.3.1. Code: ch05_estimation.py, fig_5_3_1.

pp. 295–297 The "95%" belongs to the procedure, not to one interval. The book shows fifty intervals computed from samples of size 4 with \(\mu=10\) (Table 5.3.1): 47 contain 10, samples 8 and 33 lie wholly above it and sample 42 wholly below (Figure 5.3.2).

Fifty vertical segments, the 95 percent intervals of Table 5.3.1, each of length 1.568, plotted against sample number 1 to 50 with a dashed horizontal line at 10. Forty-seven blue segments cross the line; three red segments, samples 8 and 33 above and sample 42 below, miss it.
Figure 5.3.2. Possible 95% confidence intervals for \(\mu\): the fifty simulated intervals \(\bar y\pm1.96(0.8)/\sqrt4\) of Table 5.3.1, with \(\mu=10\). The book's figure is a sketch of eight such intervals; this version uses the book's own fifty. Reproduces Larsen and Marx (2018), Figure 5.3.2 (data: Table 5.3.1). Code: ch05_estimation.py, fig_5_3_2.

Filling the gap 5.5: how many of fifty 95% intervals should miss? pp. 295–297

The book says that "in the long run" 95% of the intervals contain \(\mu\), and that 47 of 50 (94%) did. The precise statement: if \(m\) independent studies each compute an exact \(100(1-\alpha)\%\) interval, the number \(M\) of intervals that miss is \(\Bin(m,\alpha)\), and \(M/m\to\alpha\) in probability. For \(m=50\), \(\alpha=0.05\): \(\E M=2.5\), \(\P(M=3)=0.220\) and \(\P(M\le3)=0.760\), so three misses is entirely typical. The first-year notes prove the general statement (Theorem 3.2).

Hint 1 of 4: the key idea

Each interval either catches the truth or not, independently, with the same probability. What distribution counts the misses?

Hint 2 of 4: tools you will need
  • Independent Bernoulli indicators and the binomial law (Theorem 3.2.1).
  • The exact coverage of the pivot interval (Example 5.3.1).
  • Theorem 3.2 of the first-year notes.
Hint 3 of 4: step 1

Define \(I_j=1\) if interval \(j\) misses. Aim for: \(\P(I_j=1)=0.05\) exactly, whatever \(\mu\) is.

Hint 4 of 4: step 2

Sum the indicators and evaluate. Aim for: \(M\sim\Bin(50,0.05)\), \(\E M=2.5\), and \(\P(M=3)\) from the binomial formula.

Proof

Let \(I_j=1\) if interval \(j\) misses \(\mu\). By the pivot argument of Example 5.3.1, \(\P(I_j=1)=\alpha\) exactly, for every \(\mu\). Different studies use independent samples, so \(I_1,\dots,I_m\) are independent Bernoulli(\(\alpha\)) and \(M=\sum I_j\sim\Bin(m,\alpha)\) by Theorem 3.2.1. Then \(\E M=m\alpha=2.5\), \[\P(M=3)=\binom{50}3(0.05)^3(0.95)^{47}=0.220,\] and summing \(k=0,\dots,3\) gives 0.760. The weak law (Example 5.7.2 below) gives \(M/m\to\alpha\). Each miss is on the high side or the low side with probability 0.025 each, so the book's split of two above and one below is also unremarkable. ∎

▶ DemoDoes the method catch the truth?The first-year confidence interval demo, preset 1: draw interval after interval and watch the running coverage settle near 95%.

Case Study 5.3.1: Etruscan skulls pp. 297–298

The 84 maximum head breadths of Table 5.3.2 have \(\bar y=143.8\) mm. Taking \(\sigma=6.0\) mm from modern Italian males, the 95% interval is \(143.8\pm1.96(6.0)/\sqrt{84}=(142.5,\ 145.1)\) mm, far above the modern mean 132.4 mm: the data are hard to reconcile with Etruscans and modern Italians sharing one skull-size distribution. (The interval assumes the Etruscan standard deviation is also 6.0.)

Filling the gap 5.6: the equal-tailed z interval is the shortest p. 298; Questions 5.3.6, 5.3.8

Any split of \(\alpha\) into a lower tail \(a\) and an upper tail \(\alpha-a\) gives a valid interval \(\big(\bar y-z_{\alpha-a}\sigma/\sqrt n,\ \bar y+z_{a}\sigma/\sqrt n\big)\) (Question 5.3.6 asks for the confidence of such intervals). Among them, for \(0<\alpha\le1/2\), the equal split \(a=\alpha/2\) gives the unique shortest one; this is the property Question 5.3.8 asks for.

Hint 1 of 5: the key idea

The width is proportional to \(z_a+z_{\alpha-a}\). Is this function of \(a\) convex, and where is its derivative zero?

Hint 2 of 5: tools you will need
  • Implicit differentiation of \(\Phi(z_c)=1-c\).
  • \(\varphi\) is symmetric and decreasing on \([0,\infty)\).
  • A function with increasing derivative has at most one minimum.
Hint 3 of 5: step 1

Show \(\frac{\d z_c}{\d c}=-1/\varphi(z_c)\). Aim for: \(w'(a)=-1/\varphi(z_a)+1/\varphi(z_{\alpha-a})\).

Hint 4 of 5: step 2

Argue that each term of \(w'\) increases with \(a\). Aim for: \(w\) strictly convex.

Hint 5 of 5: step 3

Solve \(w'(a)=0\) using that \(\varphi\) is one-to-one on \([0,\infty)\).

Proof

The width is \(\frac{\sigma}{\sqrt n}w(a)\) with \(w(a)=z_a+z_{\alpha-a}\), \(0<a<\alpha\), where \(z_c=\Phi^{-1}(1-c)\). Because \(a\) and \(\alpha-a\) are below \(1/2\), both \(z\)'s are positive. Differentiating \(\Phi(z_c)=1-c\) gives \(\frac{\d z_c}{\d c}=-\frac{1}{\varphi(z_c)}\), so

\[ w'(a)=-\frac1{\varphi(z_a)}+\frac1{\varphi(z_{\alpha-a})}. \]

As \(a\) increases, \(z_a\) decreases towards 0, so \(\varphi(z_a)\) increases and \(-1/\varphi(z_a)\) increases; at the same time \(z_{\alpha-a}\) increases, \(\varphi(z_{\alpha-a})\) decreases and \(1/\varphi(z_{\alpha-a})\) increases. Hence \(w'\) is strictly increasing: \(w\) is strictly convex, with a single critical point where \(\varphi(z_a)=\varphi(z_{\alpha-a})\). Since \(\varphi\) is strictly decreasing on \([0,\infty)\), this means \(z_a=z_{\alpha-a}\), i.e. \(a=\alpha/2\), and this is the global minimum. The argument uses only that \(\varphi\) is symmetric and decreasing away from 0, so it holds for any symmetric unimodal pivot (for example Student's \(t\)). ∎

Confidence intervals for a binomial parameter

Theorem 5.3.1 (large-sample interval for \(p\)) p. 299, (5.3.2)

If \(k\) successes are seen in \(n\) independent trials and \(n\) is large, an approximate \(100(1-\alpha)\%\) confidence interval for \(p\) is

\[ \frac kn\pm z_{\alpha/2}\sqrt{\frac{(k/n)(1-k/n)}{n}}. \]

Filling the gap 5.7: why Theorem 5.3.1 has approximately the stated coverage p. 298

The book says it "is also true" that \((X/n-p)/\sqrt{(X/n)(1-X/n)/n}\) is approximately standard Normal. The reason is Slutsky's theorem: if \(p\) is fixed in \((0,1)\), the coverage probability of Theorem 5.3.1 tends to \(1-\alpha\) as \(n\to\infty\). The first-year notes give the complete proof (Theorem 3.9); Slutsky's theorem itself is Theorem 5.5 of the graduate course.

Hint 1 of 4: the key idea

Split the studentised ratio into the ratio with the true standard error, times a correction factor. What does each factor converge to?

Hint 2 of 4: tools you will need
  • The De Moivre-Laplace theorem (Theorem 4.3.1 of the book).
  • The weak law: \(\hat p\convp p\).
  • Slutsky's theorem: Theorem 5.5 of the graduate course.
  • Theorem 3.9 of the first-year notes.
Hint 3 of 4: step 1

Write the ratio as \(\frac{\hat p-p}{\sqrt{p(1-p)/n}}\cdot\sqrt{\frac{p(1-p)}{\hat p(1-\hat p)}}\). Aim for: limits \(\N(0,1)\) and 1.

Hint 4 of 4: step 2

Apply Slutsky, then rewrite the event \(|\text{ratio}|\le z_{\alpha/2}\) as an interval for \(p\).

Proof (sketch)

With \(\hat p=X/n\), split the studentised ratio into two factors:

\[ \frac{\hat p-p}{\sqrt{\hat p(1-\hat p)/n}}=\underbrace{\frac{\hat p-p}{\sqrt{p(1-p)/n}}}_{\convd\ \N(0,1)}\ \cdot\ \underbrace{\sqrt{\frac{p(1-p)}{\hat p(1-\hat p)}}}_{\convp\ 1}. \]

The first factor tends in distribution to \(\N(0,1)\) by the De Moivre-Laplace theorem (Theorem 4.3.1 of the book). By the weak law, \(\hat p\convp p\), and \(x\mapsto\sqrt{p(1-p)/(x(1-x))}\) is continuous at \(x=p\), so the second factor tends to 1 in probability. Slutsky's theorem says the product tends in distribution to \(\N(0,1)\), so \(\P(-z_{\alpha/2}\le\text{ratio}\le z_{\alpha/2})\to1-\alpha\). Since the denominator does not involve \(p\), the event inside is exactly \(\{\hat p-z_{\alpha/2}\sqrt{\hat p(1-\hat p)/n}\le p\le\hat p+z_{\alpha/2}\sqrt{\hat p(1-\hat p)/n}\}\). The convergence is pointwise in \(p\): for any fixed \(n\) there are values of \(p\) near 0 or 1 where the coverage is far below \(1-\alpha\). ∎

▶ DemoCoverage of intervals for a proportionThe graduate course's coverage demo: the Wald interval of Theorem 5.3.1 against the Wilson and Hoeffding intervals, as a function of \(p\). The first-year proportions demo (preset 4) shows the coverage dip near 0 and 1 for \(n=20\).

Case Study 5.3.2 and Example 5.3.2: phones and a median test pp. 299–300

Of 2002 people surveyed, 1281 used smartphones: \(\hat p=0.640\) and the 95% interval is \((0.619,\ 0.661)\). The "95%" again describes the method; \(p\) itself is fixed and either is or is not in the interval.

Example 5.3.2. Of 60 values meant to come from \(f_Y(y)=e^{-y}\) (Table 5.3.3), \(k=26\) fall below the median \(\ln2=0.69315\). The interval for the probability of falling below the median is \[\frac{26}{60}\pm1.96\sqrt{\frac{(26/60)(34/60)}{60}}=(0.308,\ 0.559),\] which contains 0.5: the sample passes this median test.

Definition 5.3.1 (margin of error) p. 301

The width of the interval in Theorem 5.3.1 is \(2z_{\alpha/2}\sqrt{(k/n)(1-k/n)/n}\), largest when \(k/n=1/2\). The margin of error is half that largest width, \(d=z_{\alpha/2}/(2\sqrt n)\); for 95%, \(d=1.96/(2\sqrt n)\), often quoted as \(100d\%\).

Example 5.3.3: what a 48% poll says about the election pp. 301–303

A poll of 1000 voters gives 48% to Max: \(d=1.96/(2\sqrt{1000})=0.031\). The book places a Normal curve with mean 0.48 and standard deviation \(\sigma_p=d/1.96=0.0158\) over the possible values of the true proportion \(p\) (Figure 5.3.3) and finds \(\P(p>0.5)=\P(Z>1.27)=0.1020\): about a 10% chance of winning, nothing like the "statistical dead heat" of press reports. Pooling five such polls (2400 of 5000) shrinks \(d\) to 0.014 and the chance to 0.0024 (Figure 5.3.4).

A dashed Normal curve centred at 0.48 with peak height 25.23; tails below 0.449 and above 0.511 shaded light blue, the part above 0.5 shaded red. Title: n equals 1000, d equals 0.031, probability p greater than 0.5 equals 0.1030.
Figure 5.3.3. The Normal curve for the true proportion \(p\) implied by the poll of 1000 with 48% for Max: mean 0.48, standard deviation \(1/(2\sqrt{1000})=0.0158\), peak \(1/(\sqrt{2\pi}\sigma_p)=25.23\). The area beyond 0.5 (red) is Max's chance, 0.103 (0.1020 in the book after rounding \(z\) to 1.27). Reproduces Larsen and Marx (2018), Figure 5.3.3. Code: ch05_estimation.py, fig_5_3_3.
The same construction for 5000 voters: a narrow dashed Normal curve centred at 0.48 with peak 56.42, interval from 0.466 to 0.494, and almost no area beyond 0.5; title gives probability 0.0023.
Figure 5.3.4. The same for the pooled poll, 2400 of 5000: the interval \((0.466,0.494)\) excludes 0.5 and Max's chance is 0.0023. The book's figure is labelled "\(n=3{,}000\)"; the text and the numbers are for \(n=5000\) (see the notes on the book). Reproduces Larsen and Marx (2018), Figure 5.3.4. Code: ch05_estimation.py, fig_5_3_4.

Filling the gap 5.8: in what sense is "\(\P(p>0.5)\)" a probability? pp. 301–303

In the frequentist framework of Section 5.3, \(p\) is a constant and "the chance that \(p>0.5\)" is either 0 or 1, as the book itself stresses after Case Study 5.3.2. The calculation of Example 5.3.3 makes sense in the Bayesian framework of Section 5.8: with a flat prior on \(p\), the posterior after \(k\) votes in \(n\) is \(\Beta(k+1,n-k+1)\), which for large \(n\) is close to \(\N\big(\hat p,\hat p(1-\hat p)/n\big)\), essentially the book's curve. For the 1000-voter poll the exact posterior probability is \(\P(p>0.5)=0.1031\); for 5000 voters, 0.00234.

Hint 1 of 5: the key idea

A fixed \(p\) has no probability distribution, but a posterior does. Which prior makes the posterior close to the book's Normal curve?

Hint 2 of 5: tools you will need
Hint 3 of 5: step 1

Use the prior \(\Beta(1,1)\) and the data 480 of 1000. Aim for: \(\Beta(481,521)\).

Hint 4 of 5: step 2

Compute its mean and standard deviation. Aim for: about 0.48 and 0.0158, the book's values.

Hint 5 of 5: step 3

Evaluate \(\P(p>0.5)\) under this posterior, exactly or with the Normal approximation, and compare with 0.1020.

Proof

A flat prior is \(\Beta(1,1)\). By Example 5.8.2 (conjugacy), \(k\) successes in \(n\) trials turn it into \(\Beta(k+1,n-k+1)\); for \(k=480\), \(n=1000\) this is \(\Beta(481,521)\). Its mean is \(481/1002=0.4800\) and, by Filling the gap 5.21, its variance is \(ab/((a+b)^2(a+b+1))\) with \(a=481\), \(b=521\), so its standard deviation is 0.01578, the same as \(\sqrt{0.48\cdot0.52/1000}=0.01580\) and as the book's \(1/(2\sqrt{1000})=0.01581\) to three figures (because \(0.48\cdot0.52=0.2496\) is so close to \(1/4\)). A Beta law with both parameters large is approximately Normal (it is the law of a ratio of gamma sums, to which the central limit theorem applies), so the book's Normal curve is a very good approximation to this posterior. The exact tail is \(\P(p>0.5)=1-I_{0.5}(481,521)=0.1031\), with \(I\) the regularised incomplete beta function; the Normal value with the unrounded \(z=0.02/0.01581=1.265\) is 0.1030.

Two caveats. The answer depends on the prior: with the informative prior \(\Beta(135,135)\) of Question 5.8.3, which says the race is close, the posterior is \(\Beta(615,655)\) and \(\P(p>0.5)=0.131\). And, as the book says, a posterior from one poll describes sampling variation only, not later changes of opinion. ∎

▶ DemoMax's poll, with a prior that expects a close racePreset 4 of this chapter's Bayesian demo: the prior \(\Beta(135,135)\), 480 of 1000 votes, and the posterior chance that Max wins.

Theorem 5.3.2 (choosing the sample size) p. 304, (5.3.3), (5.3.4)

For \(X/n\) to lie within \(d\) of \(p\) with probability at least \(1-\alpha\) (Normal approximation), whatever \(p\) is, it suffices that

\[ n\ \ge\ \frac{z_{\alpha/2}^2}{4d^2}. \]

Example 5.3.4: a smoking survey p. 305

A 95% margin of error of 1% needs \(n\ge1.96^2/(4\cdot0.01^2)=9604\). If it is known that \(p\le0.22\), \(p(1-p)\le0.22\cdot0.78\) and \(n\ge1.96^2(0.22)(0.78)/0.01^2=6592.2\), so 6593 suffice, 31% fewer.

Filling the gap 5.9: why \(n=z^2/(4d^2)\) works for every \(p\), and the finite population correction pp. 304–306; Questions 5.3.18, 5.3.21

(a) \(p(1-p)\le1/4\) on \([0,1]\), with equality only at \(p=1/2\), and \(p(1-p)\) increases on \([0,1/2]\). (b) The approximate probability \(\P(|X/n-p|\le d)\) is smallest at \(p=1/2\), so the sample size that works there works for every \(p\); with a known bound \(p\le p_0\le1/2\), \(n=z^2p_0(1-p_0)/d^2\) suffices. (c) If the \(n\) people are drawn without replacement from a population of \(N\), the margin of error becomes \(d=\frac{z_{\alpha/2}}{2\sqrt n}\sqrt{\frac{N-n}{N-1}}\), and the sample size for a target \(d\) is \(n=n_0N/(N-1+n_0)\) with \(n_0=z^2/(4d^2)\).

Hint 1 of 5: the key idea

The approximate probability \(2\Phi(d\sqrt n/\sqrt{p(1-p)})-1\) is smallest when \(p(1-p)\) is largest. Where is that, and what does it give?

Hint 2 of 5: tools you will need
  • Completing the square: \(p(1-p)=\frac14-(p-\frac12)^2\).
  • Monotonicity of \(\Phi\).
  • The hypergeometric variance factor, Filling the gap 3.20.
Hint 3 of 5: part (a)

Complete the square. Aim for: the maximum \(1/4\) at \(p=\frac12\) only.

Hint 4 of 5: part (b)

Set the worst-case probability equal to \(1-\alpha\). Aim for: \(2d\sqrt n=z_{\alpha/2}\).

Hint 5 of 5: part (c)

Multiply the variance by \((N-n)/(N-1)\), redo Definition 5.3.1 and solve \(d^2=\frac{z^2}{4n}\frac{N-n}{N-1}\) for \(n\).

Proof

(a) \(p(1-p)=\frac14-\big(p-\frac12\big)^2\), so the maximum \(1/4\) is attained only at \(1/2\), and the function increases on \([0,1/2]\) (its derivative \(1-2p\) is positive there). Question 5.3.18 asks for the same with derivatives: \(g'(p)=1-2p\), \(g''=-2<0\).

(b) By the Normal approximation, \(\P(|X/n-p|\le d)\approx2\Phi\big(d\sqrt n/\sqrt{p(1-p)}\big)-1\), which decreases as \(p(1-p)\) increases. By (a) its smallest value over \(p\) is \(2\Phi(2d\sqrt n)-1\), and this equals \(1-\alpha\) exactly when \(2d\sqrt n=z_{\alpha/2}\), i.e. \(n=z^2_{\alpha/2}/(4d^2)\). Larger \(n\) only increases it. If \(p\le p_0\le\frac12\), then \(p(1-p)\le p_0(1-p_0)\) by monotonicity, and the same argument gives \(n=z^2p_0(1-p_0)/d^2\) (Example 5.3.4). If only \(p\le p_0\) with \(p_0>1/2\) is known, nothing is gained, since \(p=1/2\) is still possible.

(c) Without replacement \(X\) is hypergeometric and \(\V(X/n)=\frac{p(1-p)}n\cdot\frac{N-n}{N-1}\) (Example 3.9.10; Filling the gap 3.20 of Chapter 3). Repeating Definition 5.3.1 with this variance multiplies \(d\) by \(\sqrt{(N-n)/(N-1)}\) (Question 5.3.21). Solving \(d^2=\frac{z^2}{4n}\frac{N-n}{N-1}\) for \(n\): \(4d^2n(N-1)=z^2(N-n)\), so \(n\big(4d^2(N-1)+z^2\big)=z^2N\), and dividing by \(4d^2\) gives \(n=n_0N/(N-1+n_0)\). For an audit of \(N=1586\) files with 85% confidence and \(d=0.03\) (Question 5.3.28), \(n_0=1.44^2/(4\cdot0.03^2)=576\) and the correction gives \(n=423\). ∎

See also: Section 3 of the first-year advanced notes (intervals by pivots), Section 6.3.2 of the graduate course (confidence sets) and its Theorem 4.5 (a Hoeffding interval valid for every \(n\)).

5.4 Properties of Estimators

pp. 308–310 The two methods of Section 5.2 can disagree: for \(f_Y(y;\theta)=2y/\theta^2\) on \([0,\theta]\), maximum likelihood gives \(Y_{\max}\) and moments give \(\frac32\bar Y\) (Questions 5.2.12, 5.2.17). To choose, one studies each estimator as a random variable: its distribution, mean and variance.

Example 5.4.1: precision grows with \(n\) p. 309

With \(p=0.6\), the estimator \(X/10\) lies within 0.10 of \(p\) when \(5\le X\le7\), with probability \(\sum_{k=5}^7\binom{10}k0.6^k0.4^{10-k}=0.6665\). For \(n=100\), the Normal approximation gives \[\P(|X/100-0.6|\le0.1)=\P(|Z|\le2.04)=0.9586\] (0.9588 without rounding) (Figure 5.4.1).

Bars at 0, 0.1, up to 1 for the probabilities of X over 10 times 10, the bars at 0.5, 0.6 and 0.7 in red; a tall narrow Normal curve centred at 0.6 for X over 100 with the region from 0.5 to 0.7 shaded. Text: area 0.6665 for n equal 10, area 0.9588 for n equal 100.
Figure 5.4.1. The law of \(X/10\) (bars, probabilities times 10 so that they share a scale with a density) and the Normal approximation to the law of \(X/100\), for \(p=0.6\). The chance of landing within 0.10 of \(p\) rises from 0.67 to 0.96. Reproduces Larsen and Marx (2018), Figure 5.4.1. Code: ch05_estimation.py, fig_5_4_1.

Unbiasedness

Definition 5.4.1 (unbiased) p. 310

An estimator \(\hat\theta=h(Y_1,\dots,Y_n)\) is unbiased for \(\theta\) if \(\E(\hat\theta)=\theta\) for every value of \(\theta\). It is asymptotically unbiased if \(\E(\hat\theta_n)\to\theta\) (Question 5.4.15).

Example 5.4.2: moments against the maximum pp. 310–311

For \(f_Y(y;\theta)=2y/\theta^2\), \(\E Y=\frac23\theta\), so \(\frac32\bar Y\) is unbiased. By Theorem 3.10.1, \(Y_{\max}\) has density \(nF_Y(y)^{n-1}f_Y(y)=2ny^{2n-1}/\theta^{2n}\) and \(\E Y_{\max}=\frac{2n}{2n+1}\theta\): biased low (0.89\(\theta\) for \(n=4\)) but asymptotically unbiased, and \(\frac{2n+1}{2n}Y_{\max}\) is unbiased.

Example 5.4.3: unbiased linear combinations p. 311

If \(\E X_i=\theta\), then \(\E\sum a_iX_i=\theta\sum a_i\), so \(\sum a_iX_i\) is unbiased exactly when \(\sum a_i=1\).

Filling the gap 5.10: which unbiased combination is best? pp. 311, 314; Question 5.4.22

(a) If \(X_1,\dots,X_n\) are uncorrelated with common mean \(\theta\) and variance \(\sigma^2\), then among all unbiased \(\sum a_iX_i\) the sample mean has the smallest variance, \(\sigma^2/n\) (it is the "best linear unbiased" estimator). (b) For independent unbiased \(W_1,W_2\) with variances \(\sigma_1^2,\sigma_2^2\), the variance of \(cW_1+(1-c)W_2\) is smallest at \(c=\sigma_2^2/(\sigma_1^2+\sigma_2^2)\), where it equals \(\sigma_1^2\sigma_2^2/(\sigma_1^2+\sigma_2^2)\), smaller than either variance.

Hint 1 of 4: the key idea

The variance of \(\sum a_iX_i\) is \(\sigma^2\sum a_i^2\), with the constraint \(\sum a_i=1\). Which inequality links \(\sum a_i\) and \(\sum a_i^2\)?

Hint 2 of 4: tools you will need
  • Theorem 3.9.5 (variance of a combination).
  • The Cauchy-Schwarz inequality and its equality case.
  • Minimising a quadratic in one variable.
Hint 3 of 4: part (a)

Apply Cauchy-Schwarz to \((a_i)\) and \((1,\dots,1)\). Aim for: \(\sum a_i^2\ge1/n\), equality iff all \(a_i=1/n\).

Hint 4 of 4: part (b)

Differentiate \(v(c)=c^2\sigma_1^2+(1-c)^2\sigma_2^2\). Aim for: \(c^*=\sigma_2^2/(\sigma_1^2+\sigma_2^2)\), then substitute.

Proof

(a) \(\V\sum a_iX_i=\sigma^2\sum a_i^2\) (Theorem 3.9.5; the covariances vanish). By the Cauchy-Schwarz inequality, \(1=\big(\sum a_i\cdot1\big)^2\le\big(\sum a_i^2\big)\big(\sum1^2\big)=n\sum a_i^2\), so \(\sum a_i^2\ge1/n\), with equality iff \((a_i)\) is proportional to \((1,\dots,1)\), i.e. every \(a_i=1/n\). Example 5.4.5 is the case \(n=3\): the weights \((\frac14,\frac12,\frac14)\) give \(\frac38\sigma^2\) against \(\frac13\sigma^2\).

(b) \(v(c)=c^2\sigma_1^2+(1-c)^2\sigma_2^2\) is a parabola with \(v'(c)=2c\sigma_1^2-2(1-c)\sigma_2^2\), zero at \(c^*=\sigma_2^2/(\sigma_1^2+\sigma_2^2)\), and \(v''=2(\sigma_1^2+\sigma_2^2)>0\). Substituting, \(v(c^*)=\frac{\sigma_2^4\sigma_1^2+\sigma_1^4\sigma_2^2}{(\sigma_1^2+\sigma_2^2)^2}=\frac{\sigma_1^2\sigma_2^2}{\sigma_1^2+\sigma_2^2}\), and this is below \(\min(\sigma_1^2,\sigma_2^2)\) because \(\sigma_2^2/(\sigma_1^2+\sigma_2^2)<1\). Each estimate is weighted by the inverse of its variance, the rule behind pooling polls in Example 5.3.3. ∎

Example 5.4.4: the sample variance pp. 311–312

For any sample with mean \(\mu\) and variance \(\sigma^2\), \(\E\frac1n\sum(Y_i-\bar Y)^2=\frac{n-1}n\sigma^2\): the maximum likelihood estimator of a Normal variance is biased low. Multiplying by \(n/(n-1)\) gives the unbiased sample variance \(S^2=\frac1{n-1}\sum(Y_i-\bar Y)^2\). The first-year notes prove this and explain the \(n-1\) geometrically (Theorem 1.3, why \(n-1\)?).

Filling the gap 5.11: \(S\) is biased for \(\sigma\) p. 312

The book remarks that \(\E(S)\ne\sigma\) although \(\E(S^2)=\sigma^2\). In fact \(\E(S)<\sigma\) for any distribution with \(\sigma>0\) (as long as \(S\) is not constant), and for Normal data \(\E(S)=c_4\sigma\) with

\[ c_4=\sqrt{\frac2{n-1}}\ \frac{\Gamma(n/2)}{\Gamma((n-1)/2)}, \]

for example \(c_4=0.798\) for \(n=2\) and \(0.940\) for \(n=5\).

Hint 1 of 4: the key idea

A variance is never negative. What does \(\V(S)\ge0\) say about \((\E S)^2\) and \(\E S^2\)?

Hint 2 of 4: tools you will need
  • \(\V(S)=\E S^2-(\E S)^2\).
  • The \(\chi^2_{n-1}\) law of \((n-1)S^2/\sigma^2\): Theorem 0.9 of the first-year notes.
  • \(\int_0^\infty u^{a-1}e^{-u/2}\d u=2^a\Gamma(a)\).
Hint 3 of 4: step 1

Deduce \(\E S\le\sigma\) and say when equality could hold.

Hint 4 of 4: step 2

For Normal data compute \(\E\sqrt U\) for \(U\sim\chi^2_k\). Aim for: \(\sqrt2\,\Gamma(\frac{k+1}2)/\Gamma(\frac k2)\); then rescale by \(\sigma/\sqrt{n-1}\).

Proof

Since \(\V(S)=\E(S^2)-(\E S)^2\ge0\), \((\E S)^2\le\E S^2=\sigma^2\), so \(\E S\le\sigma\), with equality only if \(\V(S)=0\), i.e. \(S\) is almost surely constant. For a continuous distribution and \(n\ge2\), \(S\) takes a continuum of values, so the inequality is strict.

For Normal data, \(U=(n-1)S^2/\sigma^2\) has the \(\chi^2_{k}\) density \(u^{k/2-1}e^{-u/2}/(2^{k/2}\Gamma(k/2))\), \(k=n-1\) (the normal-sample theorem, Theorem 0.9 of the first-year notes). Then

\[ \E\sqrt U=\int_0^\infty\frac{u^{(k+1)/2-1}e^{-u/2}}{2^{k/2}\Gamma(k/2)}\,\d u=\frac{2^{(k+1)/2}\Gamma((k+1)/2)}{2^{k/2}\Gamma(k/2)}=\sqrt2\,\frac{\Gamma((k+1)/2)}{\Gamma(k/2)}, \]

using \(\int_0^\infty u^{a-1}e^{-u/2}\d u=2^a\Gamma(a)\). As \(S=\sigma\sqrt{U/(n-1)}\), \(\E S=\frac{\sigma}{\sqrt{n-1}}\sqrt2\,\frac{\Gamma(n/2)}{\Gamma((n-1)/2)}=c_4\sigma\). For \(n=2\): \(\sqrt2\,\Gamma(1)/\Gamma(1/2)=\sqrt{2/\pi}=0.798\). ∎

▶ DemoDivide by \(n\) or by \(n-1\)?The first-year estimators demo, preset 3: with \(n=5\) the divisor \(n\) is 20% too small on average. The graduate course's sample variance demo compares the two divisors in mean squared error.

Efficiency

Definition 5.4.2 (relative efficiency) p. 314

If \(\hat\theta_1\) and \(\hat\theta_2\) are both unbiased and \(\V\hat\theta_1<\V\hat\theta_2\), \(\hat\theta_1\) is more efficient; the relative efficiency of \(\hat\theta_1\) with respect to \(\hat\theta_2\) is \(\V(\hat\theta_2)/\V(\hat\theta_1)\).

Examples 5.4.5 and 5.4.6 pp. 314–315

For three Normal observations, \(\V(\frac14Y_1+\frac12Y_2+\frac14Y_3)=\frac38\sigma^2\) and \(\V\bar Y=\frac13\sigma^2\): relative efficiency 1.125 in favour of \(\bar Y\).

Example 5.4.6. For \(2y/\theta^2\), \(\V(\frac32\bar Y)=\frac{\theta^2}{8n}\), while \(\V Y_{\max}=\frac{n}{(n+1)(2n+1)^2}\theta^2\) gives

\[ \V\Big(\frac{2n+1}{2n}Y_{\max}\Big)=\frac{\theta^2}{4n(n+1)}, \]

so for \(n>1\) the maximum-based estimator wins, with relative efficiency \((n+1)/2\), which grows without bound (Figure x5.2).

Left: overlapping histograms of two unbiased estimates of theta equal 1 with n equal 5: three halves of y-bar in orange, wide, variance 0.0249; the scaled maximum in blue, narrow and piled up just below 1 with a long left tail, variance 0.0083. Right, log scale against n from 1 to 40: variance theta squared over 8n in orange, variance theta squared over 4n(n+1) in blue falling much faster, and the dashed red formal bound theta squared over 4n lying above both.
Figure x5.2 (own figure). (a) Simulated sampling distributions (40 000 samples of size 5, \(\theta=1\)) of the two unbiased estimators of Examples 5.4.2 and 5.4.6. (b) Their exact variances against \(n\), with the "Cramér-Rao bound" \(\theta^2/(4n)\) of Example 5.5.2: both estimators beat it, because its conditions fail (Filling the gap 5.15). Code: ch05_estimation.py, fig_x5_2.
▶ DemoWhich unbiased estimator? Example 5.4.6Simulate the two estimators for any \(n\) and \(\theta\), with their exact variances and relative efficiency; other presets cover the uniform, exponential and Normal comparisons of the questions.

See also: Section 1 of the first-year advanced notes (bias, standard error and mean squared error, Theorem 1.1) and Theorem 6.9 of the graduate course.

5.5 Minimum-Variance Estimators: The Cramér-Rao Lower Bound

Theorem 5.5.1 (Cramér-Rao inequality) p. 316

Let \(f_Y(y;\theta)\) have continuous first and second derivatives in \(\theta\), and suppose the set where \(f_Y(y;\theta)\ne0\) does not depend on \(\theta\). If \(\hat\theta=h(Y_1,\dots,Y_n)\) is unbiased for \(\theta\), then

\[ \V(\hat\theta)\ \ge\ \Big\{n\,\E\Big[\Big(\frac{\partial\ln f_Y(Y;\theta)}{\partial\theta}\Big)^2\Big]\Big\}^{-1} \] \[ =\Big\{-n\,\E\Big[\frac{\partial^2\ln f_Y(Y;\theta)}{\partial\theta^2}\Big]\Big\}^{-1}. \]

The same holds for a probability function \(p_X(k;\theta)\). The quantity \(I(\theta)=\E[(\partial_\theta\ln f_Y(Y;\theta))^2]\) is the Fisher information in one observation; the bound is \(1/(nI(\theta))\).

Filling the gap 5.12: the Cramér-Rao bound and the equality of its two forms pp. 316–317; Question 5.5.7

The book's proof is "see (101)". The bound holds under these conditions: (R1) the support \(A=\{y:f_Y(y;\theta)>0\}\) is the same for all \(\theta\) in an open interval; (R2) \(f_Y\) is differentiable in \(\theta\) on \(A\); (R3) differentiation in \(\theta\) may be taken inside the integrals \(\int f_Y\,\d y\) and \(\int h(\bm y)\prod f_Y(y_i;\theta)\,\d\bm y\); (R4) \(0<I(\theta)<\infty\). The second form needs, in addition, that \(\int f_Y\,\d y\) can be differentiated twice under the integral sign. The first-year notes prove the bound in full (Theorem 2.4); here is the sketch, and a full proof that the two forms agree.

Hint 1 of 5: the key idea

The score has mean 0 and covariance 1 with every unbiased estimator. What does Cauchy-Schwarz then say? For the second part, differentiate \(\ln f\) twice.

Hint 2 of 5: tools you will need
  • \(\partial_\theta\ln f=\partial_\theta f/f\).
  • Differentiation under the integral sign (condition R3).
  • The Cauchy-Schwarz inequality for covariances.
  • Theorem 2.4 of the first-year notes.
Hint 3 of 5: step 1

Differentiate \(\int f\,\d y=1\) and \(\int h\prod f\,\d\bm y=\theta\). Aim for: \(\E U=0\) and \(\Cov(\hat\theta,U)=1\).

Hint 4 of 5: step 2

Combine with \(\V U=nI(\theta)\) in Cauchy-Schwarz.

Hint 5 of 5: step 3

For the two forms: expand \(\partial^2_\theta\ln f=f''/f-(f'/f)^2\), integrate against \(f\), and use \(\int f''\,\d y=0\).

Proof

The bound (sketch). Let \(U=\sum_{i=1}^n\partial_\theta\ln f_Y(Y_i;\theta)\), the score. Differentiating \(\int_Af_Y\,\d y=1\) under the integral (R3) gives \(\int_A\partial_\theta f_Y\,\d y=0\), that is \(\E[\partial_\theta\ln f_Y(Y;\theta)]=0\) (because \(\partial_\theta\ln f=\partial_\theta f/f\)). So \(\E U=0\) and, the terms being independent, \(\V U=nI(\theta)\). Differentiating \(\theta=\E\hat\theta=\int h\prod f_Y\,\d\bm y\) under the integral gives \(1=\int h\,U\prod f_Y\,\d\bm y=\E(\hat\theta U)=\Cov(\hat\theta,U)\). The Cauchy-Schwarz inequality \(\Cov(\hat\theta,U)^2\le\V(\hat\theta)\V(U)\) then reads \(1\le\V(\hat\theta)\,nI(\theta)\).

The two forms agree. Write \(f=f_Y(y;\theta)\) and \(f',f''\) for its \(\theta\)-derivatives. Then

\[ \frac{\partial^2\ln f}{\partial\theta^2}=\frac{\partial}{\partial\theta}\Big(\frac{f'}{f}\Big)=\frac{f''}{f}-\Big(\frac{f'}{f}\Big)^2. \]

Multiply by \(f\) and integrate over \(A\): \(\E[\partial^2_\theta\ln f]=\int_Af''\,\d y-\E[(\partial_\theta\ln f)^2]\). Differentiating \(\int_Af\,\d y=1\) twice under the integral gives \(\int_Af''\,\d y=0\). Hence \(-\E[\partial_\theta^2\ln f(Y;\theta)]=I(\theta)\), and the two expressions in Theorem 5.5.1 are equal. In the discrete case replace the integrals by sums over the support. ∎

Example 5.5.1: the binomial proportion attains the bound p. 317

For Bernoulli trials, \[\partial^2_p\ln p_X(X;p)=-\frac{X}{p^2}-\frac{1-X}{(1-p)^2},\] whose mean is \(-1/(p(1-p))\). The bound is \(p(1-p)/n\), exactly \(\V(X/n)\): no unbiased estimator of \(p\) is more precise than the sample proportion.

Definitions 5.5.1 and 5.5.2 (best, efficient, efficiency) pp. 317–318

An unbiased \(\hat\theta^*\) is best (minimum-variance unbiased) if \(\V\hat\theta^*\le\V\hat\theta\) for every unbiased \(\hat\theta\). An unbiased \(\hat\theta\) is efficient if its variance equals the Cramér-Rao bound, and its efficiency is the bound divided by \(\V\hat\theta\). Efficient implies best; the converse fails (Filling the gap 5.14).

Filling the gap 5.13: when is the bound attained? p. 318

The book says that sometimes no unbiased estimator attains the bound, without saying which. Under the conditions of Filling the gap 5.12, an unbiased \(\hat\theta\) is efficient if and only if the score is a linear function of it:

\[ \frac{\partial}{\partial\theta}\ln L(\theta)=nI(\theta)\,(\hat\theta-\theta)\qquad\text{for all }\theta\text{ (with probability 1)}. \]

So the Bernoulli proportion, the Poisson and Normal means and the exponential mean \(\bar Y\) are efficient, but no unbiased estimator of an exponential rate \(\lambda\) is.

Hint 1 of 5: the key idea

The bound came from Cauchy-Schwarz. When is Cauchy-Schwarz an equality?

Hint 2 of 5: tools you will need
  • Equality in Cauchy-Schwarz: one variable is a linear function of the other.
  • \(\Cov(\hat\theta,U)=1\) and \(\V U=nI(\theta)\) from Filling the gap 5.12.
  • Comparing two affine functions of the same variable.
Hint 3 of 5: step 1

Write \(\hat\theta-\theta=cU\) and take the covariance with \(U\). Aim for: \(c=1/(nI(\theta))\).

Hint 4 of 5: step 2

Compute the score for Bernoulli, Poisson and the exponential mean. Aim for: each is \(nI(\theta)(\text{estimator}-\theta)\).

Hint 5 of 5: step 3

Exponential rate: suppose \(n/\lambda-s=a(\lambda)(T-\lambda)\) for all \(\lambda\) and compare two values of \(\lambda\) as functions of \(s\).

Proof

In the proof of the bound, equality holds iff equality holds in Cauchy-Schwarz, \(\Cov(\hat\theta,U)^2=\V(\hat\theta)\V(U)\). Since \(\V U=nI>0\), this happens iff \(\hat\theta-\E\hat\theta=c\,(U-\E U)\) with probability 1 for some constant \(c\) (which may depend on \(\theta\)), i.e. \(\hat\theta-\theta=cU\). Taking the covariance of both sides with \(U\) gives \(1=c\,nI(\theta)\), so \(U=nI(\theta)(\hat\theta-\theta)\).

Examples. Bernoulli: \(U=\sum\big(\frac{X_i}p-\frac{1-X_i}{1-p}\big)=\frac{n}{p(1-p)}(\hat p-p)\). Poisson: \(U=\sum\big(\frac{X_i}\lambda-1\big)=\frac n\lambda(\bar X-\lambda)\). Exponential with mean \(\theta\), \(f=e^{-y/\theta}/\theta\): \(U=\sum\big(-\frac1\theta+\frac{Y_i}{\theta^2}\big)=\frac n{\theta^2}(\bar Y-\theta)\). Each has the required form with \(nI\) in front.

Exponential with rate \(\lambda\), \(f=\lambda e^{-\lambda y}\): \(U=\frac n\lambda-s\) with \(s=\sum y_i\). If some statistic \(T\) had \(U=a(\lambda)(T-\lambda)\) for all \(\lambda\), then \(T=\lambda+\big(\frac n\lambda-s\big)/a(\lambda)\) for every \(\lambda\). Comparing two values \(\lambda_1\ne\lambda_2\) as functions of \(s\), the coefficients of \(s\) force \(a(\lambda_1)=a(\lambda_2)=a\), a constant, and then the constant terms force \(\lambda_1+\frac n{a\lambda_1}=\lambda_2+\frac n{a\lambda_2}\) for all pairs, which is false since \(\lambda+n/(a\lambda)\) is not constant. So no unbiased estimator of \(\lambda\) attains \(\lambda^2/n\). ∎

Filling the gap 5.14: a best estimator that is not efficient p. 318

For an exponential sample with rate \(\lambda\) and \(n\ge3\), \(T=(n-1)/\sum Y_i\) is unbiased with

\[ \V(T)=\frac{\lambda^2}{n-2}\ >\ \frac{\lambda^2}n=\text{Cram\'er-Rao bound}, \]

so its efficiency is \((n-2)/n<1\). Yet \(T\) is the best unbiased estimator of \(\lambda\) (a consequence of the Rao-Blackwell theorem of Filling the gap 5.19 and the completeness of \(\sum Y_i\), a notion beyond the book). By Filling the gap 5.13 nothing attains the bound, so "best" is the most one can ask for.

Hint 1 of 5: the key idea

The sum \(S\) is gamma, so the moments \(\E S^{-1}\) and \(\E S^{-2}\) are gamma integrals. Compare the resulting variance with \(\lambda^2/n\).

Hint 2 of 5: tools you will need
  • The gamma density of a sum of exponentials (Theorem 4.6.4 of the book).
  • \(\int_0^\infty s^{a-1}e^{-\lambda s}\d s=\Gamma(a)/\lambda^a\).
  • Filling the gap 5.13: nothing attains the bound here.
Hint 3 of 5: step 1

Compute \(\E(S^{-m})\) for \(m<n\). Aim for: \(\lambda^m\Gamma(n-m)/\Gamma(n)\).

Hint 4 of 5: step 2

Use \(m=1,2\) to get \(\E T\) and \(\V T\). Aim for: \(\lambda\) and \(\lambda^2/(n-2)\).

Hint 5 of 5: step 3

Compute \(I(\lambda)\) from \(\ln f=\ln\lambda-\lambda y\) and compare.

Proof

\(S=\sum Y_i\) has the gamma density \(\lambda^ns^{n-1}e^{-\lambda s}/\Gamma(n)\) (Theorem 4.6.4 of the book). For \(m<n\),

\[ \E(S^{-m})=\frac{\lambda^n}{\Gamma(n)}\int_0^\infty s^{n-m-1}e^{-\lambda s}\d s=\frac{\lambda^n\,\Gamma(n-m)}{\Gamma(n)\,\lambda^{n-m}}=\lambda^m\frac{\Gamma(n-m)}{\Gamma(n)}. \]

With \(m=1\): \(\E(1/S)=\lambda/(n-1)\), so \(\E T=\lambda\). With \(m=2\) (needs \(n\ge3\)): \(\E(1/S^2)=\lambda^2/((n-1)(n-2))\), so \(\E T^2=(n-1)\lambda^2/(n-2)\) and \(\V T=\lambda^2\big(\frac{n-1}{n-2}-1\big)=\frac{\lambda^2}{n-2}\). The information is \(I(\lambda)=-\E\,\partial^2_\lambda(\ln\lambda-\lambda Y)=1/\lambda^2\), so the bound is \(\lambda^2/n\). Note that the maximum likelihood estimator \(1/\bar Y=n/S\) is biased: \(\E(n/S)=\frac{n}{n-1}\lambda\). ∎

Example 5.5.2: an estimator below the "bound" p. 318

For \(f_Y(y;\theta)=2y/\theta^2\) on \([0,\theta]\), \(\partial_\theta\ln f=-2/\theta\), so \(\E[(\partial_\theta\ln f)^2]=4/\theta^2\) and the formula gives \(\theta^2/(4n)\). But \(\V(\frac32\bar Y)=\theta^2/(8n)\) is smaller. There is no contradiction: the support \([0,\theta]\) depends on \(\theta\), violating the hypotheses of Theorem 5.5.1.

Filling the gap 5.15: exactly where the proof breaks in Example 5.5.2 p. 318

The book attributes the failure to the moving support. The precise point: the score has mean \(-2/\theta\), not 0, because differentiating \(\int_0^\theta f_Y\,\d y=1\) produces a boundary term. The score is even a constant, so it carries no information about where \(\hat\theta\) falls, and the Cauchy-Schwarz step yields nothing. Estimators based on \(Y_{\max}\) then reach variances of order \(1/n^2\), far below any \(c/n\).

Hint 1 of 5: the key idea

The identity \(\E(\text{score})=0\) came from differentiating \(\int f=1\) under the integral. What extra term appears when the upper limit of the integral is \(\theta\) itself?

Hint 2 of 5: tools you will need
  • Leibniz's rule for an integral with a variable limit.
  • The step \(\Cov(\hat\theta,U)=1\) in Filling the gap 5.12.
  • The variances of Example 5.4.6.
Hint 3 of 5: step 1

Differentiate \(\int_0^\theta 2y/\theta^2\,\d y\). Aim for: the boundary term \(f(\theta;\theta)=2/\theta\) plus \(\int\partial_\theta f=-2/\theta\).

Hint 4 of 5: step 2

Note that the total score \(-2n/\theta\) is a constant. Aim for: its covariance with any \(\hat\theta\) is 0, not 1.

Hint 5 of 5: step 3

Compare \(\theta^2/(4n(n+1))\) with \(\theta^2/(4n)\) as \(n\) grows.

Proof

By Leibniz's rule for an integral with a variable upper limit,

\[ 0=\frac{\d}{\d\theta}\int_0^\theta\frac{2y}{\theta^2}\d y=\underbrace{f_Y(\theta;\theta)}_{=2/\theta}+\int_0^\theta\frac{\partial}{\partial\theta}\frac{2y}{\theta^2}\d y=\frac2\theta+\int_0^\theta\Big(-\frac{4y}{\theta^3}\Big)\d y=\frac2\theta-\frac2\theta. \]

So \(\int\partial_\theta f\,\d y=-2/\theta\ne0\): the interchange (R3) fails because the density does not vanish at the moving end point. Accordingly \(\E[\partial_\theta\ln f(Y;\theta)]=-2/\theta\). The total score \(U=-2n/\theta\) is non-random, so \(\Cov(\hat\theta,U)=0\) for every \(\hat\theta\) and the identity \(\Cov(\hat\theta,U)=1\) of the proof is false. By Example 5.4.6, \(\V\big(\frac{2n+1}{2n}Y_{\max}\big)=\theta^2/(4n(n+1))\), which is of order \(1/n^2\); the "bound" \(\theta^2/(4n)\) is beaten by a factor \(n+1\) (Figure x5.2b). Question 5.5.4 shows the same for Uniform(0, \(\theta\)). ∎

▶ DemoBeating a bound that does not applyPreset 2: Example 5.5.2 with \(n=20\). Presets 4 and 5 show estimators that do attain the bound (exponential mean, Normal mean). The graduate course's efficiency demo (preset 5) shows the same \(1/n\) collapse for the uniform end point.

See also: Section 2.3 of the first-year advanced notes, and Theorem 9.17 and Theorem 9.23 of the graduate course (information identities, asymptotic efficiency of the MLE).

5.6 Sufficient Estimators

pp. 319–320, (5.6.1) A statistic is sufficient if, once its value is known, the rest of the data carry no further information about \(\theta\): the conditional distribution of the sample given the statistic does not involve \(\theta\). For Bernoulli trials and \(\hat p=\frac1n\sum X_i\), every sequence with \(\sum k_i=t\) has probability \(p^t(1-p)^{n-t}\) and there are \(\binom nt\) of them, so

\[ \P\Big(X_1=k_1,\dots,X_n=k_n\ \Big|\ \sum X_i=t\Big)=\frac{p^t(1-p)^{n-t}}{\binom nt p^t(1-p)^{n-t}}=\binom nt^{-1}, \tag{5.6.1} \]

free of \(p\): given the number of successes, every arrangement is equally likely whatever \(p\) is. With \(\hat p^*=X_1\) instead, the conditional probability is \(p^{\sum_{i\ge2}k_i}(1-p)^{n-1-\sum_{i\ge2}k_i}\), which still depends on \(p\): \(X_1\) is not sufficient.

pp. 320–321 Two illustrations from the book. Dice: told only that a sum of two dice is at most 7, the chance that it is even is \(9/21\); told that it is odd, the question is settled. And for \(2y/\theta^2\), the samples \((3,4,5)\) and \((1,3,8)\) both give \(\frac32\bar y=6\), but only the first allows \(\theta=4\): the moment estimator forgets the largest observation, which matters. It is not sufficient.

Definition 5.6.1 (sufficient statistic) p. 322, (5.6.2)

\(\hat\theta=h(X_1,\dots,X_n)\) is sufficient for \(\theta\) if the likelihood factors as

\[ L(\theta)=\prod_{i=1}^np_X(k_i;\theta)=p_{\hat\theta}(\theta_e;\theta)\,b(k_1,\dots,k_n), \]

where \(p_{\hat\theta}\) is the probability function of \(\hat\theta\), \(\theta_e=h(k_1,\dots,k_n)\), and \(b\) does not involve \(\theta\). This is equation (5.6.2) cross-multiplied: \(b\) is the conditional probability of the sample given \(\hat\theta=\theta_e\). Any one-to-one function of a sufficient statistic is sufficient (Question 5.6.3).

Example 5.6.1: the Poisson sum pp. 322–323, (5.6.3)

\(\hat\lambda=\sum X_i\) is Poisson with mean \(n\lambda\), and

\[ L(\lambda)=\frac{e^{-n\lambda}\lambda^{t}}{\prod k_i!}=\underbrace{\frac{e^{-n\lambda}(n\lambda)^t}{t!}}_{p_{\hat\lambda}(t;\lambda)}\cdot\underbrace{\frac{t!}{n^t\prod k_i!}}_{b(k_1,\dots,k_n)},\qquad t=\sum k_i, \]

so the sum is sufficient; so is the unbiased \(\bar X=\hat\lambda/n\). The factor \(b\) is the multinomial probability of splitting \(t\) among \(n\) equally likely cells: given the total, the counts are \(\mathrm{Multinomial}(t;\frac1n,\dots,\frac1n)\), whatever \(\lambda\) is.

Theorem 5.6.1 (factorization criterion) p. 324, (5.6.4)

\(\hat\theta=h(X_1,\dots,X_n)\) is sufficient for \(\theta\) if and only if there are functions \(g\) and \(b\), with \(b\) free of \(\theta\), such that

\[ L(\theta)=g\big[h(k_1,\dots,k_n);\theta\big]\cdot b(k_1,\dots,k_n). \]

The book proves the discrete case (summing the factorization over the set \(h^{-1}(c)\) shows that \(g(c;\theta)\) is the probability function of \(\hat\theta\) up to a factor free of \(\theta\)) and states that a similar statement holds for densities.

Filling the gap 5.16: the factorization theorem for densities p. 324

For continuous data, "the conditional distribution given \(\hat\theta\)" needs care, because \(\{\hat\theta=t\}\) has probability 0. A clean version at the level of the book: suppose there are functions \(u(\bm y)\) (with values in \(\R^{n-1}\)) such that \(\bm y\mapsto(t,\bm u)=(h(\bm y),u(\bm y))\) is one-to-one and differentiable with non-zero Jacobian \(J(\bm y)\), free of \(\theta\). Then the conditional density of \(\bm U\) given \(T=t\) is free of \(\theta\) if and only if \(L(\theta)=g(h(\bm y);\theta)\,b(\bm y)\).

Hint 1 of 5: the key idea

Complete \(T\) by auxiliary variables \(\bm u\) and change variables. A joint density that factors as \(g(t;\theta)\times\)(something free of \(\theta\)) has a conditional density free of \(\theta\).

Hint 2 of 5: tools you will need
  • The change-of-variables formula for joint densities (with a Jacobian).
  • Marginal and conditional densities (Section 3.11 of the book).
  • Theorem 9.40 of the graduate course.
Hint 3 of 5: step 1

Write \(f_{T,\bm U}=L(\theta;\bm y)/|J(\bm y)|\).

Hint 4 of 5: step 2

(\(\Leftarrow\)) Insert \(L=g\,b\), integrate out \(\bm u\). Aim for: \(f_T=g(t;\theta)B(t)\) and a conditional density \(\beta/B\).

Hint 5 of 5: step 3

(\(\Rightarrow\)) Write \(f_{T,\bm U}=f_T\cdot c(\bm u\mid t)\) and multiply back by \(|J|\).

Proof

By the change-of-variables formula for joint densities, \(f_{T,\bm U}(t,\bm u;\theta)=L(\theta;\bm y)/|J(\bm y)|\) evaluated at the \(\bm y\) with \(h(\bm y)=t\), \(u(\bm y)=\bm u\).

(\(\Leftarrow\)) If \(L=g(t;\theta)b(\bm y)\), then \(f_{T,\bm U}=g(t;\theta)\,\beta(t,\bm u)\) with \(\beta=b/|J|\) free of \(\theta\). Integrating out \(\bm u\): \(f_T(t;\theta)=g(t;\theta)B(t)\) with \(B(t)=\int\beta(t,\bm u)\d\bm u\). Where \(f_T>0\), the conditional density \(f_{\bm U\mid T}(\bm u\mid t)=f_{T,\bm U}/f_T=\beta(t,\bm u)/B(t)\) does not involve \(\theta\).

(\(\Rightarrow\)) If \(f_{\bm U\mid T}(\bm u\mid t)=c(\bm u\mid t)\) is free of \(\theta\), then \(L(\theta;\bm y)=|J(\bm y)|\,f_T(h(\bm y);\theta)\,c(u(\bm y)\mid h(\bm y))\), which is the factorization with \(g=f_T\) (so it is even the form of Definition 5.6.1) and \(b=|J|\,c\). For a general proof without the auxiliary \(\bm u\) one needs measure-theoretic conditional probability; see the references. ∎

Example: for \(n\) exponential observations with mean \(\theta\), \(L=\theta^{-n}e^{-\sum y_i/\theta}\), so \(T=\sum Y_i\) is sufficient; with \(u_i=y_i/\sum y_j\) (\(i<n\)) the conditional law of the proportions given the total is uniform on the simplex for every \(\theta\).

Example 5.6.2: \(Y_{\max}\) is sufficient for \(2y/\theta^2\) pp. 324–325

With the indicator \(I_{[0,\theta]}(y)\) the density is \(\frac{2y}{\theta^2}I_{[0,\theta]}(y)\) for all \(y\), and \(\prod_iI_{[0,\theta]}(y_i)=I_{[0,\theta]}(y_{\max})\) for non-negative data. So

\[ L(\theta)=\frac{I_{[0,\theta]}(y_{\max})}{\theta^{2n}}\cdot\prod_{i=1}^n2y_i, \]

which is of the form of Theorem 5.6.1: \(Y_{\max}\) is sufficient. The book asks why the argument fails for \(Y_{\min}\).

Filling the gap 5.17: proving that a statistic is not sufficient (\(Y_{\min}\) here, \(X_1+2X_2+3X_3\) in Question 5.6.2) p. 325; Question 5.6.2

A practical test: if \(T\) is sufficient and two samples \(\bm y,\bm y'\) have \(T(\bm y)=T(\bm y')\), then \(L(\theta;\bm y)\) and \(L(\theta;\bm y')\) are proportional as functions of \(\theta\) (their ratio is \(b(\bm y)/b(\bm y')\), free of \(\theta\)). Two samples with the same \(T\) but non-proportional likelihoods prove that \(T\) is not sufficient.

Hint 1 of 5: the key idea

If \(T\) were sufficient, two samples with the same \(T\) would have proportional likelihoods. Can you find two samples with the same \(T\) whose likelihoods are not proportional?

Hint 2 of 5: tools you will need
  • Theorem 5.6.1 (factorization).
  • The indicator form of the likelihood (Example 5.6.2).
  • A ratio that changes with \(\theta\) breaks proportionality.
Hint 3 of 5: step 1

For \(Y_{\min}\): take two samples with the same minimum but different maxima. Aim for: a \(\theta\) where one likelihood is 0 and the other is not.

Hint 4 of 5: step 2

Turn that into a contradiction with \(L=g(y_{\min};\theta)b(\bm y)\).

Hint 5 of 5: step 3

For \(X_1+2X_2+3X_3\): find two samples with \(T=3\) and compute the ratio of their likelihoods.

Proof

\(Y_{\min}\) for \(2y/\theta^2\). Take \(n=2\), \(\bm y=(1,2)\) and \(\bm y'=(1,3)\), both with \(y_{\min}=1\). Then \(L(\theta;\bm y)=\frac{8}{\theta^4}\one\{\theta\ge2\}\) and \(L(\theta;\bm y')=\frac{12}{\theta^4}\one\{\theta\ge3\}\). Suppose \(L=g(y_{\min};\theta)b(\bm y)\). Since \(L(4;\bm y')>0\), \(b(\bm y')>0\); since \(L(2.5;\bm y')=0\), \(g(1;2.5)=0\); but then \(L(2.5;\bm y)=g(1;2.5)b(\bm y)=0\), whereas in fact \(L(2.5;\bm y)=8/2.5^4>0\). Contradiction. The smallest observation cannot tell whether \(\theta\) is at least as large as the others.

\(X_1+2X_2+3X_3\) for Bernoulli trials. The samples \((1,1,0)\) and \((0,0,1)\) both give \(T=3\). Their likelihoods are \(p^2(1-p)\) and \(p(1-p)^2\), with ratio \(p/(1-p)\), which varies with \(p\). Equivalently, \(\P\big((1,1,0)\mid T=3\big)=\frac{p^2(1-p)}{p^2(1-p)+p(1-p)^2}=p\): the conditional law still contains \(p\). ∎

▶ DemoWhat does a statistic remember?Preset 3: the conditional law of three Bernoulli trials given \(X_1+2X_2+3X_3\), under two values of \(p\) side by side; presets 1, 2 and 4 show the sum (sufficient), \(X_1\) alone (not) and the Poisson sum of Example 5.6.1.

Sufficiency and the other properties

p. 325 The book draws two consequences: maximum likelihood estimators are functions of sufficient statistics, and the search for efficient estimators may be restricted to functions of sufficient statistics. The first needs a qualification, the second a correction.

Filling the gap 5.18: maximum likelihood estimates depend on the data only through a sufficient statistic p. 325

If \(T\) is sufficient and the maximum likelihood estimate is unique, it is a function of \(T\). If the maximiser is not unique, it is always possible to choose one that is a function of \(T\), but not every choice is.

Hint 1 of 4: the key idea

The factor \(b(\bm y)\) does not involve \(\theta\), so it does not move the maximiser. On what does the maximiser of \(g(T(\bm y);\theta)\) depend?

Hint 2 of 4: tools you will need
  • Theorem 5.6.1 (factorization).
  • Positive constants do not change where a function of \(\theta\) is largest.
  • A model whose likelihood is flat on an interval: Uniform\((\theta-\frac12,\theta+\frac12)\).
Hint 3 of 4: step 1

Show the set of maximisers of \(L(\cdot;\bm y)\) equals that of \(g(T(\bm y);\cdot)\). Aim for: a set depending on \(\bm y\) only through \(T\).

Hint 4 of 4: step 2

For a non-unique maximum, give one choice that is a function of \(T\) and one that is not.

Proof

By Theorem 5.6.1, \(L(\theta;\bm y)=g(T(\bm y);\theta)b(\bm y)\). For a sample with \(b(\bm y)>0\) (otherwise \(L\equiv0\)), the maximisers of \(L(\cdot;\bm y)\) are exactly the maximisers of \(\theta\mapsto g(T(\bm y);\theta)\), a set \(M(T(\bm y))\) that depends on \(\bm y\) only through \(T\). If it is a single point, \(\theta_e=\phi(T(\bm y))\). If not, choosing (say) the smallest element of \(M(t)\) gives a maximiser that is a function of \(T\).

Non-uniqueness happens: for Uniform\((\theta-\frac12,\theta+\frac12)\), \(L(\theta)=\one\{y_{\max}-\frac12\le\theta\le y_{\min}+\frac12\}\), so every point of that interval is a maximum likelihood estimate and \(T=(Y_{\min},Y_{\max})\) is sufficient. The choice "\(\bar y\) moved into the interval if it lies outside" is a maximum likelihood estimate that depends on all of the data, not only on \(T\). The moment estimator \(\frac32\bar Y\) of the \(2y/\theta^2\) model, by contrast, is not a function of the sufficient \(Y_{\max}\), which is the book's argument for preferring maximum likelihood. ∎

Filling the gap 5.19: the Rao-Blackwell theorem, and what sufficiency really guarantees p. 325

The book states that every unbiased estimator based on a sufficient statistic has smaller variance than every unbiased estimator that is not. Taken literally this cannot be right (the whole sample is always sufficient, so every estimator is "based on a sufficient statistic"), and it is false even for a minimal sufficient statistic (counterexample below). The correct statement is the Rao-Blackwell theorem: if \(T\) is sufficient and \(\hat\theta\) is unbiased with finite variance, then \(\theta^*=\E(\hat\theta\mid T)\) is a statistic, is unbiased, and \(\V\theta^*\le\V\hat\theta\), with equality only if \(\hat\theta\) is already a function of \(T\). Conditioning on a sufficient statistic can only help. The graduate course proves it as Theorem 9.42.

Hint 1 of 5: the key idea

Averaging \(\hat\theta\) over the samples that share the value of \(T\) keeps the mean and removes the within-group spread. Why is the result still a statistic?

Hint 2 of 5: tools you will need
  • Sufficiency: the conditional law given \(T\) is free of \(\theta\).
  • Iterated expectation: Filling the gap 3.23.
  • The total-variance formula \(\V X=\E\V(X\mid T)+\V\E(X\mid T)\).
  • Theorem 9.42 of the graduate course.
Hint 3 of 5: step 1

Prove \(\theta^*=\E(\hat\theta\mid T)\) is unbiased and has variance at most \(\V\hat\theta\).

Hint 4 of 5: step 2

Bernoulli example: compute \(\E(X_1\mid\sum X_i=t)\) from (5.6.1). Aim for: \(t/n\).

Hint 5 of 5: step 3

Counterexample: for Uniform\((\theta,\theta+1)\), \(n=3\), compare the variances of \(Y_{\min}-\frac14\) and \(\bar Y-\frac12\). Aim for: \(3/80\) against \(1/36\).

Proof

(i) \(\theta^*\) is a statistic: the conditional distribution of the sample given \(T\) does not involve \(\theta\) (sufficiency), so neither does the conditional mean of \(\hat\theta=h(\text{sample})\). (ii) Unbiased: by iterated expectation (Filling the gap 3.23), \(\E\theta^*=\E[\E(\hat\theta\mid T)]=\E\hat\theta=\theta\). (iii) By the total-variance formula,

\[ \V\hat\theta=\E\big[\V(\hat\theta\mid T)\big]+\V\big[\E(\hat\theta\mid T)\big]\ \ge\ \V\theta^*, \]

with equality iff \(\V(\hat\theta\mid T)=0\) with probability 1, i.e. \(\hat\theta\) is a function of \(T\). (The formula follows from \(\E(\hat\theta-\theta)^2=\E\big[(\hat\theta-\theta^*)+(\theta^*-\theta)\big]^2\), where the cross term \(\E[(\hat\theta-\theta^*)(\theta^*-\theta)]\) vanishes after conditioning on \(T\).)

Example. For Bernoulli trials, \(\hat p=X_1\) is unbiased with variance \(p(1-p)\). Given \(\sum X_i=t\), all arrangements are equally likely (5.6.1), so \(\E(X_1\mid\sum X_i=t)=t/n\): Rao-Blackwellising \(X_1\) gives \(\bar X\), with variance \(p(1-p)/n\).

Counterexample to the book's claim. Let \(Y_1,Y_2,Y_3\) be Uniform\((\theta,\theta+1)\). The pair \(T=(Y_{\min},Y_{\max})\) is sufficient (the likelihood is \(\one\{y_{\max}-1\le\theta\le y_{\min}\}\)). Since \(Y_{\min}-\theta\) is the minimum of three Uniform(0,1) variables, a \(\Beta(1,3)\) variable with mean \(\frac14\) and variance \(\frac{3}{80}\), the estimator \(Y_{\min}-\frac14\) is an unbiased function of \(T\) with variance \(3/80=0.0375\). The estimator \(\bar Y-\frac12\) is unbiased with variance \(1/36=0.0278\) and is not a function of \(T\) (two samples with the same extremes can have different middle values). So a function of the sufficient statistic loses. Rao-Blackwellising \(\bar Y-\frac12\) instead gives the midrange \(\frac12(Y_{\min}+Y_{\max})-\frac12\), with variance \(1/40=0.025\): better than both. What makes the book's conclusion true in its examples is completeness of \(T\), under which there is only one unbiased function of \(T\), and it is the best unbiased estimator (the Lehmann-Scheffé theorem; see the references). ∎

See also: Section 9.13.2 of the graduate course (sufficiency, the factorization theorem as Theorem 9.40, minimal sufficiency) and Section 9.13.3 (exponential families, Question 5.6.9).

5.7 Consistency

p. 326 Unbiasedness and sufficiency concern a fixed \(n\). Consistency concerns the sequence \(\hat\theta_n\) as \(n\) grows: the distribution of \(\hat\theta_n\) should pile up at \(\theta\).

Definition 5.7.1 (consistent) p. 327

\(\hat\theta_n\) is consistent for \(\theta\) if it converges in probability to \(\theta\): for every \(\varepsilon>0\), \(\lim_{n\to\infty}\P(|\hat\theta_n-\theta|<\varepsilon)=1\). Equivalently, for all \(\varepsilon,\delta>0\) there is \(n(\varepsilon,\delta)\) with \(\P(|\hat\theta_n-\theta|<\varepsilon)>1-\delta\) for \(n>n(\varepsilon,\delta)\).

Example 5.7.1: the uniform maximum pp. 327–328

For Uniform(0, \(\theta\)), \(\P(|Y_{\max}-\theta|<\varepsilon)=1-\big(\frac{\theta-\varepsilon}\theta\big)^n\to1\): \(Y_{\max}\) is biased but consistent. For \(\theta=4\), \(\varepsilon=0.1\), \(\delta=0.2\): \(0.975^n\le0.2\) needs \(n\ge\ln0.2/\ln0.975=63.6\), so \(n(\varepsilon,\delta)=64\) (Figure 5.7.1).

Left: densities n y to the n minus 1 over theta to the n on 0 to 4 for n equal 1, 2, 3, 10 and 64; flat for n equal 1, then increasingly concentrated against the right end, with a red band from 3.9 to 4. Right: the probability that Ymax is within 0.1 of 4, rising from 0.025 at n equal 1 towards 1, crossing the dashed line at 0.8 at n equal 64.
Figure 5.7.1. (a) The density of \(Y_{\max}\) for Uniform(0, 4) samples of size \(n=1,2,3,10,64\): its mass moves into the \(\varepsilon\)-band below \(\theta\) (red). (b) \(\P(|Y_{\max}-\theta|<0.1)=1-0.975^n\) and the sample size \(n(\varepsilon,\delta)=64\) at which it passes \(1-\delta=0.8\). The book's figure is a sketch; this one is computed. Reproduces Larsen and Marx (2018), Figure 5.7.1. Code: ch05_estimation.py, fig_5_7_1.

Theorem 5.7.1 (Chebyshev's inequality) and Example 5.7.2 (the weak law) pp. 328–329

For any \(W\) with mean \(\mu\) and variance \(\sigma^2\), and any \(\varepsilon>0\), \(\P(|W-\mu|\ge\varepsilon)\le\sigma^2/\varepsilon^2\). The book proves it by dropping the middle part of the variance integral; the first-year notes derive it from Markov's inequality (Theorem 0.4).

Applied to \(\bar X_n\), with variance \(\sigma^2/n\): \(\P(|\bar X_n-\mu|<\varepsilon)\ge1-\sigma^2/(n\varepsilon^2)\to1\). The sample mean is consistent for the mean of any distribution with finite variance: the weak law of large numbers (Theorem 0.5 of the first-year notes). More generally, an estimator whose bias and variance both tend to 0 is consistent (Question 5.7.4; Theorem 1.2 of the first-year notes).

Filling the gap 5.20: maximum likelihood estimators are consistent (the case of a concave log-likelihood) p. 329

The book cites (101) for "under very general conditions maximum likelihood estimators are consistent". Here is a complete proof in a common special case. Let \(Y_1,Y_2,\dots\) be independent with density (or probability function) \(f(y;\theta_0)\), and let \(\psi(y;\theta)=\partial_\theta\ln f(y;\theta)\) be strictly decreasing in \(\theta\) for every \(y\) (strictly concave log-likelihood; true for the Bernoulli, Poisson, Normal-mean and exponential-rate models). Assume \(m(\theta)=\E_{\theta_0}\psi(Y;\theta)\) and \(\V_{\theta_0}\psi(Y;\theta)\) are finite and \(m(\theta_0)=0\) (the score has mean 0, Filling the gap 5.12). If, for each \(n\), the likelihood equation has a root \(\hat\theta_n\), then \(\hat\theta_n\convp\theta_0\).

Hint 1 of 5: the key idea

The score is decreasing in \(\theta\). If the score is positive at \(\theta_0-\varepsilon\) and negative at \(\theta_0+\varepsilon\), where must its root be?

Hint 2 of 5: tools you will need
  • The weak law applied to \(\psi(Y_i;\theta_0\pm\varepsilon)\).
  • \(m(\theta_0)=0\): the score has mean 0 (Filling the gap 5.12).
  • \(\P(A\cap B)\ge1-\P(A^c)-\P(B^c)\).
Hint 3 of 5: step 1

Show \(m(\theta_0-\varepsilon)>0>m(\theta_0+\varepsilon)\) from monotonicity of \(\psi\).

Hint 4 of 5: step 2

Use the weak law to show the event \(E_n\) (score signs as in step 1) has probability tending to 1.

Hint 5 of 5: step 3

On \(E_n\), locate the root using monotonicity of \(\ell_n'\). Aim for: \(|\hat\theta_n-\theta_0|<\varepsilon\).

Proof

Fix \(\varepsilon>0\). Because \(\psi\) is strictly decreasing in \(\theta\), so is \(m\), hence \(m(\theta_0-\varepsilon)>0>m(\theta_0+\varepsilon)\). Write \(\ell_n'(\theta)=\sum_{i=1}^n\psi(Y_i;\theta)\). By the weak law (Example 5.7.2), \(\frac1n\ell_n'(\theta_0-\varepsilon)\convp m(\theta_0-\varepsilon)\) and \(\frac1n\ell_n'(\theta_0+\varepsilon)\convp m(\theta_0+\varepsilon)\). So the event

\[ E_n=\big\{\ell_n'(\theta_0-\varepsilon)>0\big\}\cap\big\{\ell_n'(\theta_0+\varepsilon)<0\big\} \]

has \(\P(E_n)\to1\) (each of the two events has probability tending to 1, and \(\P(A\cap B)\ge1-\P(A^c)-\P(B^c)\)). On \(E_n\), since \(\ell'_n\) is strictly decreasing, \(\ell_n'>0\) on \((-\infty,\theta_0-\varepsilon]\) and \(\ell_n'<0\) on \([\theta_0+\varepsilon,\infty)\) within the parameter interval, so the root \(\hat\theta_n\) lies in \((\theta_0-\varepsilon,\theta_0+\varepsilon)\). Hence \(\P(|\hat\theta_n-\theta_0|<\varepsilon)\ge\P(E_n)\to1\). By the lemma of Filling the gap 5.1 this root is the maximum likelihood estimate.

Example: exponential rate, \(\psi(y;\lambda)=1/\lambda-y\), decreasing in \(\lambda\), \(m(\lambda)=1/\lambda-1/\lambda_0\); the estimator \(1/\bar Y\) is consistent although biased. The general theorem, without concavity, is Theorem 9.13 of the graduate course. ∎

▶ DemoConsistency as the sample growsThe graduate course's consistency demo, preset 3: the maximum of Uniform(0, 1) data, \(\P(\max<1-\varepsilon)=(1-\varepsilon)^n\), as in Example 5.7.1; preset 2 shows a biased but consistent variance estimator.

5.8 Bayesian Estimation

pp. 329–330 In a Bayesian analysis the parameter is a random variable \(\Theta\) with a prior distribution, and Bayes' theorem (Section 2.4 of the book) turns the prior and the data into a posterior distribution. The search for the submarine Scorpion in 1968 is the book's example: the search area was divided into cells with prior probabilities from expert opinion, and after each unsuccessful search of a cell \(k\) its probability was lowered by Bayes' theorem,

\[ P^*(A_k)=\frac{\P(B_k^c\mid A_k)\P(A_k)}{\P(B_k^c\mid A_k)\P(A_k)+\P(A_k^c)}, \]

(where \(B_k\) is "found when cell \(k\) is searched"; \(\P(B_k^c\mid A_k^c)=1\)), the other cells were renormalised, and the most probable cell was searched next.

Example 5.8.1: a two-point prior for a call rate p. 331

A Poisson call rate is 8 with prior probability 0.25 and 10 with probability 0.75. One five-minute count gives \(X=7\). Then

\[ \P(\Lambda=10\mid X=7)=\frac{e^{-10}\frac{10^7}{7!}(0.75)}{e^{-8}\frac{8^7}{7!}(0.25)+e^{-10}\frac{10^7}{7!}(0.75)}=\frac{0.0901(0.75)}{0.1396(0.25)+0.0901(0.75)}=0.659, \]

and \(\P(\Lambda=8\mid X=7)=0.341\): the observation, more typical of rate 8, moved weight towards 8.

Definition 5.8.1 (posterior distribution) pp. 331–332

If a statistic \(W\) has probability function \(p_W(w\mid\theta)\) (or density \(f_W(w\mid\theta)\)) and \(\Theta\) has prior density \(f_\Theta(\theta)\), the posterior density of \(\Theta\) given \(W=w\) is

\[ g_\Theta(\theta\mid W=w)=\frac{p_W(w\mid\theta)f_\Theta(\theta)}{\int p_W(w\mid\theta)f_\Theta(\theta)\,\d\theta}, \]

with sums for a discrete prior. A uniform prior, used when nothing is known, is called noninformative.

Example 5.8.2: a beta prior for a proportion pp. 332–333, (5.8.1)

With \(X\sim\Bin(n,\theta)\) and the beta prior \(f_\Theta(\theta)=\frac{\Gamma(r+s)}{\Gamma(r)\Gamma(s)}\theta^{r-1}(1-\theta)^{s-1}\) (Figure 5.8.1 shows \(r=2\), \(s=4\)), the numerator of the posterior is a constant times \(\theta^{k+r-1}(1-\theta)^{n-k+s-1}\), so the posterior is \(\Beta(k+r,\,n-k+s)\). A prior centred near 0.035 with almost all its mass below 0.07 is obtained with \(r=4\), \(s=102\), giving the posterior \(\Beta(k+4,\,n-k+102)\).

The Beta(2, 4) density on 0 to 1: zero at 0, rising to a peak of about 2.1 at theta equal 0.25 and decreasing to 0 at 1, skewed to the right.
Figure 5.8.1. The \(\Beta(2,4)\) density \(20\theta(1-\theta)^3\), mean \(1/3\), mode \(1/4\). Reproduces Larsen and Marx (2018), Figure 5.8.1. Code: ch05_estimation.py, fig_5_8_1.

Filling the gap 5.21: recognising a density from its kernel; the mean and variance of a beta law; choosing the prior of Example 5.8.2 p. 333

The book argues that "there can be only one" beta density with given powers of \(\theta\) and \((1-\theta)\), and cites (100) for \(\E\Theta=r/(r+s)\). (a) If a density is proportional to a non-negative function \(h\) with \(0<\int h<\infty\), it equals \(h/\int h\). (b) For \(\Theta\sim\Beta(r,s)\), \(\E\Theta=\frac r{r+s}\) and \(\V\Theta=\frac{rs}{(r+s)^2(r+s+1)}\). (c) A prior mean 0.035 forces \(s=27.6r\); the book's \(r=4\), \(s=102\) has mean 0.0377, median 0.0349 and \(\P(\Theta<0.07)=0.941\).

Hint 1 of 5: the key idea

A density is pinned down by its shape: the constant is whatever makes the integral 1. For the moments, write \(\theta\cdot\)(beta density) as a ratio of beta functions.

Hint 2 of 5: tools you will need
  • \(\int_0^1\theta^{a-1}(1-\theta)^{b-1}\d\theta=\Gamma(a)\Gamma(b)/\Gamma(a+b)\).
  • \(\Gamma(x+1)=x\Gamma(x)\).
  • \(\Gamma(m)=(m-1)!\) for integers.
Hint 3 of 5: part (a)

If \(f=ch\) integrates to 1, solve for \(c\).

Hint 4 of 5: part (b)

Compute \(B(r+1,s)/B(r,s)\) and \(B(r+2,s)/B(r,s)\). Aim for: \(r/(r+s)\) and \(r(r+1)/((r+s)(r+s+1))\).

Hint 5 of 5: part (c)

Solve \(r/(r+s)=0.035\) for \(s\), then check the mean and the cdf at 0.07 for \(r=4\), \(s=102\).

Proof

(a) If \(f=ch\) is a density, \(1=\int f=c\int h\), so \(c=1/\int h\) is determined. Hence the posterior, being proportional to \(\theta^{k+r-1}(1-\theta)^{n-k+s-1}\), must be the \(\Beta(k+r,n-k+s)\) density, which has that kernel. The same argument identifies the gamma posterior of Example 5.8.3.

(b) The normalising constant gives \(\int_0^1\theta^{a-1}(1-\theta)^{b-1}\d\theta=B(a,b)=\frac{\Gamma(a)\Gamma(b)}{\Gamma(a+b)}\) for all \(a,b>0\). So \(\E\Theta=\frac{B(r+1,s)}{B(r,s)}=\frac{\Gamma(r+1)\Gamma(r+s)}{\Gamma(r)\Gamma(r+s+1)}=\frac r{r+s}\), using \(\Gamma(x+1)=x\Gamma(x)\). Similarly \(\E\Theta^2=\frac{B(r+2,s)}{B(r,s)}=\frac{r(r+1)}{(r+s)(r+s+1)}\), and

\[ \V\Theta=\frac{r(r+1)}{(r+s)(r+s+1)}-\frac{r^2}{(r+s)^2}=\frac{r(r+1)(r+s)-r^2(r+s+1)}{(r+s)^2(r+s+1)}=\frac{rs}{(r+s)^2(r+s+1)}. \]

(c) \(r/(r+s)=0.035\) gives \(s=r(1/0.035-1)=27.57\,r\). With \(r=4\), \(s=102\) the mean is \(4/106=0.0377\) (the median, 0.0349, is the quantity close to 0.035), and the cdf at 0.07 is 0.941: "almost all" of the mass, 94%, is below 0.07. Writing \(\Gamma(m)=(m-1)!\) gives the book's form \(\frac{(n+105)!}{(k+3)!(n-k+101)!}\theta^{k+3}(1-\theta)^{n-k+101}\) of the posterior. ∎

Example 5.8.3: a gamma prior for a Poisson rate p. 334

If \(W=\sum X_i\) for a Poisson sample of size \(n\), so \(W\sim\Pois(n\theta)\), and the prior is \(\Gam(s,\mu)\), \(f_\Theta(\theta)=\frac{\mu^s}{\Gamma(s)}\theta^{s-1}e^{-\mu\theta}\), the posterior is proportional to \(\theta^{w+s-1}e^{-(\mu+n)\theta}\), hence

\[ g(\theta\mid W=w)=\frac{(\mu+n)^{w+s}}{\Gamma(w+s)}\theta^{w+s-1}e^{-(\mu+n)\theta}, \]

the \(\Gam(w+s,\mu+n)\) density: the shape adds the total count, the rate adds the number of periods.

Case Study 5.8.1: hurricanes reaching the mainland pp. 334–335

The 88 hurricanes of 1851–1900, the least reliable period, set the prior: mean \(s/\mu=88/50\), so \(\Gam(88,50)\). The later 100 years had \(w=92+72=164\), so the posterior is \(\Gam(252,150)\), with mean 1.68 hurricanes per year and 95% of its mass between 1.48 and 1.89 (Figure x5.3a).

Example 5.8.4 and Case Study 5.8.2: Poisson counts with gamma-distributed rates pp. 335–337

If each person's error rate \(\Theta\) is \(\Gam(s,\mu)\) and, given \(\Theta=\theta\), the count \(W\) is Poisson(\(\theta\)), integrating \(\theta\) out gives

\[ p_W(w)=\frac{\Gamma(w+s)}{w!\,\Gamma(s)}\Big(\frac\mu{\mu+1}\Big)^s\Big(\frac1{\mu+1}\Big)^w=\binom{w+s-1}{w}p^s(1-p)^w,\qquad p=\frac{\mu}{\mu+1}: \]

a negative binomial. Case Study 5.8.2 fits this to the errors of 504 subjects on a coordination test (Table 5.8.2) with \(s=0.8\), and the fit is very good (Figure x5.1c). The formula the book gives for \(p\) is not the maximum likelihood estimate; see the notes on the book.

Bayes estimates

Definitions 5.8.2 and 5.8.3 (loss, risk) pp. 337–338

A loss function \(L(\hat\theta,\theta)\ge0\), with \(L(\theta,\theta)=0\), measures the cost of estimating \(\theta\) by \(\hat\theta\). The risk of an estimate is its expected loss under the posterior, \(\int L(\hat\theta,\theta)g(\theta\mid W=w)\d\theta\), and a Bayes estimate minimises the risk. Common choices are \(|\hat\theta-\theta|\) and \((\hat\theta-\theta)^2\).

Example 5.8.5: an inventory loss p. 338

Max stocks \(n\hat\theta\) copies when a proportion \(\theta\) of his \(n\) customers will buy. Each lost sale costs \(c\) and each unsold copy costs \(d\):

\[ L(\hat\theta,\theta)=\begin{cases}cn(\theta-\hat\theta),&\hat\theta<\theta,\\ dn(\hat\theta-\theta),&\hat\theta>\theta.\end{cases} \]

The book does not compute the Bayes estimate for this loss; Filling the gap 5.23 does.

Theorem 5.8.1 (Bayes estimates for absolute and squared loss) pp. 338–340, (5.8.2)

(a) Under \(L=|\hat\theta-\theta|\) the Bayes estimate is the posterior median. (b) Under \(L=(\hat\theta-\theta)^2\) it is the posterior mean, because \(\E(W-b)^2=\V W+(\E W-b)^2\) is smallest at \(b=\E W\).

Filling the gap 5.22: a direct proof that a median minimises \(\E|W-b|\) p. 339

The book's proof of part (a) goes through the special case \(E|W-m|\le E|W|\) for \(m\ge0\), leaves \(m<0\) as "similar", and assumes a continuous \(W\) whose median splits the mass exactly in half. Here is a short proof that works for any \(W\) with \(\E|W|<\infty\), discrete or continuous, and any median \(m\) (a number with \(\P(W\le m)\ge\frac12\) and \(\P(W\ge m)\ge\frac12\)): \(\E|W-b|\ge\E|W-m|\) for every \(b\).

Hint 1 of 4: the key idea

Compare \(|w-b|\) with \(|w-m|\) pointwise. The difference is at least \(b-m\) times \(\pm1\), with the sign decided by which side of \(m\) the point \(w\) lies.

Hint 2 of 4: tools you will need
  • Case analysis on three ranges of \(w\).
  • The definition of a median: \(\P(W\le m)\ge\frac12\), \(\P(W\ge m)\ge\frac12\).
  • Linearity and monotonicity of expectation.
Hint 3 of 4: step 1

For \(b>m\), compute \(|w-b|-|w-m|\) for \(w\le m\), \(m<w<b\), \(w\ge b\). Aim for: a lower bound \((b-m)[\one\{w\le m\}-\one\{w>m\}]\).

Hint 4 of 4: step 2

Take expectations and use \(\P(W\le m)\ge\frac12\). Then treat \(b<m\) by symmetry.

Proof

Take \(b>m\). Compare \(|w-b|\) and \(|w-m|\) in three ranges: for \(w\le m\), \(|w-b|-|w-m|=b-m\); for \(m<w<b\), it is \((b-w)-(w-m)=b+m-2w\), which lies between \(-(b-m)\) and \(b-m\); for \(w\ge b\), it is \(-(b-m)\). In every case

\[ |w-b|-|w-m|\ \ge\ (b-m)\big[\one\{w\le m\}-\one\{w>m\}\big]. \]

Taking expectations, \(\E|W-b|-\E|W-m|\ge(b-m)\big[\P(W\le m)-\P(W>m)\big]=(b-m)\big[2\P(W\le m)-1\big]\ge0\), since \(\P(W\le m)\ge\frac12\). For \(b<m\) the mirror-image argument uses \(\P(W\ge m)\ge\frac12\). ∎

Example 5.8.6: the Bayes estimate as a compromise p. 340

Under squared loss, the gamma-Poisson Bayes estimate is the posterior mean

\[ \frac{w+s}{\mu+n}=\frac{n}{\mu+n}\Big(\frac wn\Big)+\frac{\mu}{\mu+n}\Big(\frac s\mu\Big), \]

a weighted average of the maximum likelihood estimate \(w/n\) and the prior mean \(s/\mu\), the weight on the data tending to 1 as \(n\to\infty\). In Case Study 5.8.1: \(\frac{100}{150}(1.64)+\frac{50}{150}(1.76)=1.68\). The beta-binomial analogue (Question 5.8.2) is \(\frac{k+r}{n+r+s}=\frac{n}{n+r+s}\frac kn+\frac{r+s}{n+r+s}\frac r{r+s}\).

Filling the gap 5.23: the Bayes estimate for Max's inventory is a posterior quantile p. 338

For the loss of Example 5.8.5 and a continuous posterior with cdf \(G\), the risk is minimised where \(G(\hat\theta)=\frac{c}{c+d}\): the Bayes estimate is the \(c/(c+d)\) quantile of the posterior. With \(c=d\) this is the median (Theorem 5.8.1a). If a lost sale costs three times a storage cost, stock to the 75% point of the posterior: for the prior \(\Beta(4,102)\) and 7 buyers among 100 potential customers, the posterior is \(\Beta(11,195)\), with mean 0.0534, median 0.0520 and 75% quantile 0.0630.

Hint 1 of 5: the key idea

Differentiate the expected loss in the estimate \(t\). What do the derivatives of \(\E(\Theta-t)^+\) and \(\E(t-\Theta)^+\) turn out to be?

Hint 2 of 5: tools you will need
  • Leibniz's rule for an integral with a variable limit.
  • The posterior cdf \(G\) is non-decreasing.
  • A function with non-decreasing derivative is convex.
Hint 3 of 5: step 1

Show \(\frac{\d}{\d t}\E(\Theta-t)^+=-(1-G(t))\) and \(\frac{\d}{\d t}\E(t-\Theta)^+=G(t)\).

Hint 4 of 5: step 2

Combine. Aim for: \(R'(t)=n[(c+d)G(t)-c]\).

Hint 5 of 5: step 3

Set \(R'(t)=0\) and evaluate for \(\Beta(11,195)\) with \(c=3\), \(d=1\).

Proof

Write \(x^+=\max(x,0)\). The risk of \(t=\hat\theta\) is \(R(t)=n\big[c\,\E(\Theta-t)^++d\,\E(t-\Theta)^+\big]\) under the posterior. Now \(\E(\Theta-t)^+=\int_t^\infty(\theta-t)g(\theta)\d\theta\), and by Leibniz's rule its derivative is \(-(t-t)g(t)-\int_t^\infty g(\theta)\d\theta=-(1-G(t))\). Likewise \(\frac{\d}{\d t}\E(t-\Theta)^+=G(t)\). Hence

\[ R'(t)=n\big[-c(1-G(t))+dG(t)\big]=n\big[(c+d)G(t)-c\big]. \]

Since \(G\) is non-decreasing, \(R'\) is non-decreasing, so \(R\) is convex, and \(R'(t)\) changes sign where \(G(t)=c/(c+d)\). That point minimises the risk. For \(\Beta(11,195)\) (the posterior \(\Beta(k+4,n-k+102)\) with \(k=7\), \(n=100\)), \(G^{-1}(0.75)=0.0630\): Max should stock about 6.3% of his customer count, more than the posterior mean, because running short costs more than overstocking. ∎

▶ DemoPrior plus data, and the inventory lossPreset 3: Max's posterior \(\Beta(11,195)\) with lost sales three times as costly as storage; move the cost ratio and watch the Bayes estimate slide along the posterior quantiles. Preset 1 is Case Study 5.8.1. The graduate course's loss demo compares squared, absolute and zero-one loss.

See also: Section 11.2 (the Bayesian method) and Section 12.3 (Bayes estimators) of the graduate course; Section 4.6.2 of the machine-learning course (the beta-binomial model, posterior mean as a compromise); the graduate course's credible interval demo.

5.9 Taking a Second Look at Statistics (Beyond Classical Estimation)

pp. 341–342 The book closes with the bootstrap, a computer-intensive way to estimate a standard error, the standard deviation \(\sqrt{\V\hat\theta}\) of an estimator, when no formula is available. Its test case does have a formula: for \(f_Y(y;\theta)=ye^{-y/\theta}/\theta^2\) the maximum likelihood estimator \(\frac12\bar Y\) (Example 5.2.2) has variance \(\frac14\cdot\frac{2\theta^2}n=\frac{\theta^2}{2n}\), so its standard error is \(\theta/\sqrt{2n}\). The parametric bootstrap goes as follows: (1) from the sample of Table 5.9.1 (\(n=15\), sum 285.955) compute \(\theta_e=9.5318\); (2) draw 200 samples of size 15 from \(f_Y(y;9.5318)\); (3) re-estimate \(\theta\) on each; (4) report the standard deviation of the 200 re-estimates. The book obtains 1.835, against the true standard error \(10/\sqrt{30}=1.826\) (the sample was drawn with \(\theta=10\)).

Left: a wide dashed grey prior density centred at 1.76 and a narrower blue posterior density centred at 1.68 for the hurricane rate, with a dotted red line at the MLE 1.64 and a blue line at the posterior mean. Right: a histogram of 200 bootstrap estimates of theta, roughly bell-shaped around 9.5, with the exact gamma law of the estimator at theta e drawn in red; caption gives bootstrap standard error 1.75 against target 1.74.
Figure x5.3 (own figure). (a) Case Study 5.8.1: the prior \(\Gam(88,50)\) from 1851–1900 and the posterior \(\Gam(252,150)\) after 164 hurricanes in 100 years; the posterior mean 1.68 lies between the prior mean 1.76 and the maximum likelihood estimate 1.64. (b) Section 5.9: 200 parametric bootstrap estimates from the sample of Table 5.9.1 (a new random draw, not the book's Table 5.9.2), with the exact law of \(\frac12\bar Y\) at \(\theta_e=9.53\); the bootstrap standard error 1.75 estimates \(\theta_e/\sqrt{30}=1.74\). Data: Tables 5.8.1 and 5.9.1 of Larsen and Marx (2018). Code: ch05_estimation.py, fig_x5_3.

Filling the gap 5.24: what the parametric bootstrap estimates, and how close 1.835 should be p. 342

The bootstrap does not estimate the standard error at the true \(\theta\); it estimates it at \(\theta_e\). As the number \(B\) of bootstrap samples grows, the bootstrap standard error tends to \(\theta_e/\sqrt{2n}=9.5318/\sqrt{30}=1.740\), not to 1.826. With \(B=200\) it carries a Monte Carlo error of about 0.09, so the book's 1.835 is about one Monte Carlo standard deviation above its target: its closeness to the true 1.826 is partly luck.

Hint 1 of 4: the key idea

Each bootstrap sample comes from \(f(y;\theta_e)\), not from \(f(y;\theta)\). What, then, is the exact standard deviation of a bootstrap re-estimate?

Hint 2 of 4: tools you will need
  • \(\V(\frac12\bar Y)=\theta^2/(2n)\) for this gamma model.
  • The weak law for the sample variance of the re-estimates.
  • The approximate standard deviation \(\sigma/\sqrt{2(B-1)}\) of a sample standard deviation.
Hint 3 of 4: step 1

Find the limit of the bootstrap standard error as \(B\to\infty\). Aim for: \(\theta_e/\sqrt{2n}=1.740\).

Hint 4 of 4: step 2

Estimate the Monte Carlo error for \(B=200\) and compare 1.835 with the target.

Proof

Each bootstrap sample is drawn from \(f_Y(y;\theta_e)\), so each re-estimate \(\theta^*_b=\frac12\bar Y^*_b\) has exactly the distribution of \(\hat\theta\) when the parameter is \(\theta_e\): variance \(\theta_e^2/(2n)\). The \(B\) re-estimates are independent, so by the weak law applied to \(\theta^*_b\) and \((\theta^*_b)^2\), their sample variance tends in probability to \(\theta_e^2/(2n)\), and their sample standard deviation to \(\theta_e/\sqrt{2n}=1.740\). The bootstrap standard error therefore inherits the error of \(\theta_e\) itself (9.53 against 10, a relative error of 4.7%, carried over exactly) plus a Monte Carlo error. For approximately Normal re-estimates, the sample standard deviation of \(B\) values has standard deviation about \(\sigma/\sqrt{2(B-1)}=1.74/\sqrt{398}=0.087\); repeating the whole bootstrap many times gives about 0.09. In applications the plug-in error matters more than the Monte Carlo error, which can always be reduced by increasing \(B\). Here \(\frac12\bar Y\) has an exact gamma law at \(\theta_e\) (shape \(2n\), scale \(\theta_e/(2n)\)), drawn in Figure x5.3b. ∎

See also: Section 8.2 (bootstrap variance estimation) and the supplement on the parametric bootstrap of the graduate course, and its demo on the number of bootstrap replications.

Notes on the book

Case Study 5.8.2: the estimate of \(p\) p. 337

The book states that the maximum likelihood estimate of \(p\) in the negative binomial \(\binom{w+s-1}{w}p^s(1-p)^w\) with \(s\) known is \(ns/\sum w_i\), and uses \(p=(504)(0.8)/3821=0.106\). The log-likelihood is \(ns\ln p+(\sum w_i)\ln(1-p)+\text{const}\), whose derivative \(ns/p-\sum w_i/(1-p)\) vanishes at

\[ p_e=\frac{ns}{ns+\sum w_i}=\frac{403.2}{403.2+3821}=0.0955. \]

(Equivalently, the model mean \(s(1-p)/p\) equals \(\bar w\).) Moreover the printed column of predicted frequencies does not come from \(p=0.106\): that value gives 83.7, 59.9, 48.2 for \(w=0,1,2\) instead of the printed 79.2, 57.1, 46.3. The printed column agrees, within 0.06 in every one of its 32 cells, with \(p=0.0989\), close to the correct estimate (Figure x5.1c). The conclusion that the negative binomial fits well stands.

The claim about unbiased functions of sufficient statistics p. 325

The book says the variance of every unbiased estimator based on a sufficient statistic is less than that of every unbiased estimator that is not. This is false: with \(Y_1,Y_2,Y_3\) from Uniform\((\theta,\theta+1)\), \(Y_{\min}-\frac14\) is an unbiased function of the sufficient \((Y_{\min},Y_{\max})\) with variance \(3/80\), and \(\bar Y-\frac12\), not a function of it, has the smaller variance \(1/36\). What is true is the Rao-Blackwell theorem; see Filling the gap 5.19.

Figure 5.3.4: the sample size in the label p. 302

The figure is labelled "\(n=3{,}000\)", but the text, the margin \(d=0.014\) and the interval \((0.466,0.494)\) are for the pooled poll of \(n=5000\) (for \(n=3000\), \(d\) would be 0.018). Its peak height 56.98 corresponds to \(\sigma_p=0.0070\); with the unrounded \(\sigma_p=1/(2\sqrt{5000})=0.00707\) the peak is 56.42.

Smaller slips pp. 292, 299–300, 305, 324; answers p. 710

(1) Case Study 5.3.2 announces the believable values "from 0.618 to 0.662" and then computes \((0.619,0.661)\); the latter is right. (2) In Example 5.3.2 the upper limit is \(0.4333+0.1254=0.5587\), which rounds to 0.559, not 0.558. (3) In Table 5.2.4 the expected frequency 7.7 for the class 6–10 is \(100F_X(10)\), which includes the class 0–5; the class probabilities give 0.5 for 0–5 and 7.1 for 6–10 (the table prints 0 and 7.7). (4) The Comment after Theorem 5.3.2 refers to "Section 3.3" for the hypergeometric law, which is in Section 3.2. (5) In the proof of Theorem 5.6.1, "\(g[b(k_1,\dots,k_n);\theta]\)" should read \(g[h(k_1,\dots,k_n);\theta]\). (6) The book's answer to Question 5.4.19(c) gives the relative efficiency of \(\hat\theta_2=\bar Y\) to \(\hat\theta_3=nY_{\min}\) as \(\V(\hat\theta_3)/\V(\hat\theta_2)=(\theta^2/n)/\theta^2=1/n\); the ratio is \(\theta^2/(\theta^2/n)=n\) (see the solution).

Selected questions

Twelve of the book's questions, restated in my own words and covering every main section, with complete solutions (hidden). Numbers were cross-checked with the book's answers to the odd-numbered questions; the one disagreement is explained in the solution.

  1. Question 5.2.9 (no-hitters per season). In the 59 Major League seasons 1950–2008 the numbers of seasons with 0, 1, 2, 3 and 4 or more no-hit games were 6, 19, 12, 13 and 9. (a) Fit a Poisson model by maximum likelihood (count "4 or more" as 4) and compare observed and expected frequencies. (b) Is the agreement surprising?

    Hint 1 of 5: the key idea

    The Poisson maximum likelihood estimate is the sample mean; expected frequencies are 59 times the Poisson probabilities, with the last class taking the remainder.

    Hint 2 of 5: tools you will need
    • Example 5.2.1.
    • \(p(k)=e^{-\lambda}\lambda^k/k!\).
    • Why a constant rate over many seasons is an assumption.
    Hint 3 of 5: part (a)

    Compute \(\bar k\) with 4+ counted as 4. Aim for: 118/59.

    Hint 4 of 5: part (a): the frequencies

    Compute \(59p(k)\) for \(k=0,\dots,3\) and the remainder for 4+. Aim for: 7.99, 15.97, 15.97, 10.65 and 8.43.

    Hint 5 of 5: part (b)

    Look at the largest discrepancies and think about what could make the rate vary between seasons.

    Solution

    (a) By Example 5.2.1, \(\lambda_e=\bar k=\frac{0(6)+1(19)+2(12)+3(13)+4(9)}{59}=\frac{118}{59}=2.00\). Expected frequencies \(59e^{-2}2^k/k!\): 7.99, 15.97, 15.97, 10.65 for \(k=0,\dots,3\), and the remainder 8.43 for "4 or more". Observed: 6, 19, 12, 13, 9.

    (b) The agreement is fair: the largest discrepancies are \(-4\) at \(k=2\) and \(+3\) at \(k=1\), modest for counts of this size (a formal test is in Chapter 10). Some misfit is to be expected, because the rate is unlikely to be constant over 59 seasons (rule changes such as the height of the pitcher's mound alter it), and a mixture of Poisson rates is more spread out than one Poisson. Note also that counting "4 or more" as 4 understates \(\bar k\): maximising the likelihood with that class treated as \(\P(X\ge4)\) gives \(\lambda=2.08\).

  2. Question 5.2.13 (Pareto's law of incomes). Incomes follow \(f_Y(y;\theta)=\theta k^\theta y^{-(\theta+1)}\), \(y\ge k\), \(\theta\ge1\), with \(k\) known. Find the maximum likelihood estimator of \(\theta\) from a random sample of 25 incomes.

    Hint 1 of 5: the key idea

    Take logs: the likelihood becomes linear in \(\theta\) apart from \(n\ln\theta\). Set the derivative to zero and check it is a maximum.

    Hint 2 of 5: tools you will need
    • The log-likelihood of a random sample.
    • Filling the gap 5.1 (the sign lemma).
    • The constraint \(\theta\ge1\).
    Hint 3 of 5: step 1

    Write \(\ell(\theta)=n\ln\theta+n\theta\ln k-(\theta+1)\sum\ln y_i\).

    Hint 4 of 5: step 2

    Solve \(\ell'(\theta)=0\). Aim for: \(\hat\theta=n/\sum\ln(y_i/k)\).

    Hint 5 of 5: step 3

    Check \(\ell''<0\) and decide what happens if the formula gives a value below 1.

    Solution

    For a sample of size \(n\), \(L(\theta)=\theta^nk^{n\theta}\prod y_i^{-(\theta+1)}\) (all \(y_i\ge k\), so no indicator depends on \(\theta\)), and

    \[ \ell(\theta)=n\ln\theta+n\theta\ln k-(\theta+1)\sum\ln y_i,\qquad \ell'(\theta)=\frac n\theta-\sum_{i=1}^n\ln\frac{y_i}k. \]

    Since \(\ell'\) is strictly decreasing (\(\ell''=-n/\theta^2\)), the lemma of Filling the gap 5.1 gives the unique maximiser over \(\theta>0\):

    \[ \hat\theta=\frac{n}{\sum_{i=1}^n\ln(Y_i/k)}=\frac{25}{\sum_{i=1}^{25}\ln Y_i-25\ln k}. \]

    This agrees with the book's answer. One refinement: the model requires \(\theta\ge1\). If the formula gives a value below 1, then \(\ell'<0\) on \([1,\infty)\) and the maximum over the allowed range is \(\theta_e=1\).

  3. Question 5.2.17 (moments against likelihood). For \(f_Y(y;\theta)=2y/\theta^2\), \(0\le y\le\theta\), find the method-of-moments estimator of \(\theta\). Compare it with the maximum likelihood estimate for the sample 17, 92, 46, 39, 56.

    Hint 1 of 5: the key idea

    Match \(\E Y\) to \(\bar y\) for the moment estimate. For the likelihood, ask on which \(\theta\) it is non-zero.

    Hint 2 of 5: tools you will need
    • \(\E Y=\int_0^\theta y\,f(y;\theta)\,\d y\).
    • The indicator form of the likelihood (Example 5.6.2).
    • A decreasing function is largest at the left end of its domain.
    Hint 3 of 5: step 1

    Compute \(\E Y\) and solve \(\E Y=\bar y\). Aim for: \(\frac32\bar y\).

    Hint 4 of 5: step 2

    Write \(L(\theta)\) with \(\one\{\theta\ge y_{\max}\}\) and find its maximiser.

    Hint 5 of 5: step 3

    Evaluate both on the data and ask whether the moment estimate is a possible value of the parameter.

    Solution

    \(\E Y=\int_0^\theta y\cdot2y/\theta^2\,\d y=\frac23\theta\). Setting \(\frac23\theta=\bar y\) gives \(\theta_e=\frac32\bar y\); here \(\bar y=250/5=50\), so \(\theta_e=75\).

    The likelihood is \(L(\theta)=\frac{2^n\prod y_i}{\theta^{2n}}\one\{\theta\ge y_{\max}\}\), which is 0 for \(\theta<y_{\max}\) and decreasing for \(\theta\ge y_{\max}\) (Question 5.2.12), so the maximum likelihood estimate is \(y_{\max}=92\).

    The moment estimate 75 is impossible: an observation of 92 cannot come from a density that vanishes beyond 75. The moment equation uses only \(\bar y\) and ignores the constraint \(\theta\ge y_{\max}\); the maximum likelihood estimate respects it (and \(Y_{\max}\) is sufficient, Example 5.6.2). Both answers agree with the book.

  4. Question 5.3.7 (lopsided intervals). Five independent samples of size \(n\) from a Normal law with known \(\sigma\) each give the interval \(\big(\bar y-0.96\frac\sigma{\sqrt n},\ \bar y+1.06\frac\sigma{\sqrt n}\big)\). What is the probability that at least four of the five intervals contain \(\mu\)?

    Hint 1 of 4: the key idea

    Translate 'the interval contains mu' into an event for a standard Normal variable, then count successes over five independent intervals.

    Hint 2 of 4: tools you will need
    • Standardising the sample mean (Example 5.3.1).
    • Normal tables or software.
    • The binomial law (Theorem 3.2.1).
    Hint 3 of 4: step 1

    Show the interval covers \(\mu\) iff \(-1.06<Z<0.96\). Aim for: \(p\approx0.687\).

    Hint 4 of 4: step 2

    The number of covering intervals is \(\Bin(5,p)\): add the probabilities of 4 and 5.

    Solution

    The interval contains \(\mu\) iff \(\bar y-0.96\sigma/\sqrt n<\mu<\bar y+1.06\sigma/\sqrt n\), i.e. iff \(-1.06<Z<0.96\) with \(Z=(\bar Y-\mu)/(\sigma/\sqrt n)\) standard Normal. So each interval covers with probability

    \[ p=\Phi(0.96)-\Phi(-1.06)=\Phi(1.06)-\Phi(-0.96)=0.8554-0.1685=0.6869. \]

    The number of covering intervals is \(\Bin(5,p)\), so

    \[ \P(\text{at least 4})=5p^4(1-p)+p^5=0.3485+0.1529=0.501, \]

    as in the book's answer: a coin toss, although each interval has confidence 69%.

  5. Question 5.3.16 (the absentee ballots). With 99% of precincts counted, Foley trailed Nethercutt by 2174 votes and about 14 000 absentee ballots remained. Let \(p\) be the probability that an absentee voter prefers Foley. How small could \(p\) have been while still giving Foley a 20% chance of winning?

    Hint 1 of 5: the key idea

    Foley wins if his absentee share \(X\) beats his opponent's by more than 2174. Turn that into \(X\ge\) some number and require probability 0.20.

    Hint 2 of 5: tools you will need
    • The binomial model for the absentee votes.
    • The Normal approximation with a continuity correction.
    • \(z_{0.20}=0.8416\).
    Hint 3 of 5: step 1

    From \(2X-14000>2174\), find the smallest winning \(X\). Aim for: 8088.

    Hint 4 of 5: step 2

    Write \(\P(X\ge8088)\approx\P(Z>(8087.5-mp)/\sqrt{mp(1-p)})\) and set the cut-off equal to 0.8416.

    Hint 5 of 5: step 3

    Solve for \(p\) by iteration, starting from \(p=8087.5/14000\).

    Solution

    Let \(X\) be Foley's share of the \(m=14000\) absentee votes (assume each goes to one of the two candidates, independently, \(X\sim\Bin(m,p)\)). Foley gains \(X-(m-X)=2X-m\) on the margin, so he wins if \(2X-14000>2174\), i.e. \(X>8087\), \(X\ge8088\).

    With the Normal approximation and a continuity correction, \(\P(X\ge8088)\approx\P\big(Z>\frac{8087.5-mp}{\sqrt{mp(1-p)}}\big)\). This equals 0.20 when the standardised value is \(z_{0.20}=0.8416\):

    \[ 14000p=8087.5-0.8416\sqrt{14000\,p(1-p)}. \]

    Solving (one or two iterations starting from \(p=8087.5/14000=0.5777\), where \(\sqrt{mp(1-p)}=58.4\)) gives \(p=0.574\). The exact binomial gives the same, 0.5742. Since the chance of winning increases with \(p\), any \(p\) below about 0.574 gives Foley less than a 20% chance: he needed to win more than 57% of the absentee vote just to have a one-in-five chance. (The book gives no answer for this even-numbered question.)

  6. Question 5.4.19 (three unbiased estimators of an exponential mean). For a sample from \(f_Y(y;\theta)=\frac1\theta e^{-y/\theta}\), \(y>0\): (a) show that \(\hat\theta_1=Y_1\), \(\hat\theta_2=\bar Y\) and \(\hat\theta_3=nY_{\min}\) are unbiased; (b) find their variances; (c) find the relative efficiencies of \(\hat\theta_1\) to \(\hat\theta_3\) and of \(\hat\theta_2\) to \(\hat\theta_3\).

    Hint 1 of 5: the key idea

    The minimum of independent exponentials is again exponential. What does that make \(nY_{\min}\)?

    Hint 2 of 5: tools you will need
    • \(\P(Y_{\min}>y)=\prod\P(Y_i>y)\) (Theorem 3.10.1).
    • Mean \(\theta\) and variance \(\theta^2\) of an exponential.
    • Definition 5.4.2 (which variance goes on top).
    Hint 3 of 5: part (a)

    Find the law of \(Y_{\min}\). Aim for: exponential with mean \(\theta/n\).

    Hint 4 of 5: part (b)

    Write down the three variances. Aim for: \(\theta^2\), \(\theta^2/n\), \(\theta^2\).

    Hint 5 of 5: part (c)

    Form the ratios with the variance of the comparison estimator on top. Aim for: 1 for \(\hat\theta_1\) to \(\hat\theta_3\), and a ratio that grows with \(n\) for \(\hat\theta_2\) to \(\hat\theta_3\).

    Solution

    (a) \(\E Y_1=\theta\) and \(\E\bar Y=\theta\). For the minimum, \(\P(Y_{\min}>y)=\prod\P(Y_i>y)=e^{-ny/\theta}\), so \(Y_{\min}\) is exponential with mean \(\theta/n\) (Theorem 3.10.1), and \(nY_{\min}\) is exponential with mean \(\theta\): it has exactly the law of one observation. All three are unbiased.

    (b) An exponential with mean \(\theta\) has variance \(\theta^2\), so \(\V\hat\theta_1=\V\hat\theta_3=\theta^2\), and \(\V\hat\theta_2=\theta^2/n\).

    (c) By Definition 5.4.2 the relative efficiency of \(\hat\theta_a\) with respect to \(\hat\theta_b\) is \(\V\hat\theta_b/\V\hat\theta_a\). So \(\hat\theta_1\) to \(\hat\theta_3\): \(\theta^2/\theta^2=1\) (the two are equally good, or equally bad); \(\hat\theta_2\) to \(\hat\theta_3\): \(\V\hat\theta_3/\V\hat\theta_2=\theta^2/(\theta^2/n)=n\). The book's answer prints \(\V(\hat\theta_3)/\V(\hat\theta_2)=(\theta^2/n)/\theta^2=1/n\), which is the reciprocal (the efficiency of \(\hat\theta_3\) with respect to \(\hat\theta_2\)); with the definition the answer is \(n\): \(\bar Y\) is \(n\) times as efficient as \(nY_{\min}\). By Question 5.5.1, \(\bar Y\) attains the Cramér-Rao bound \(\theta^2/n\).

  7. Question 5.5.5 (a geometric model). Let \(p_X(k;\theta)=(\theta-1)^{k-1}/\theta^k\), \(k=1,2,\dots\), \(\theta>1\) (geometric with \(p=1/\theta\)), for which \(\E X=\theta\) and \(\V X=\theta(\theta-1)\). Is \(\bar X\) an efficient estimator of \(\theta\)?

    Hint 1 of 5: the key idea

    Compute the Fisher information from the score, then compare \(1/(nI)\) with \(\V\bar X\).

    Hint 2 of 5: tools you will need
    • Theorem 5.5.1.
    • \(\E(X-\theta)^2=\V X=\theta(\theta-1)\).
    • The support does not depend on the parameter.
    Hint 3 of 5: step 1

    Differentiate \(\ln p_X=(k-1)\ln(\theta-1)-k\ln\theta\). Aim for: \((k-\theta)/(\theta(\theta-1))\).

    Hint 4 of 5: step 2

    Square and take expectations. Aim for: \(I(\theta)=1/(\theta(\theta-1))\).

    Hint 5 of 5: step 3

    Compare the bound with \(\V\bar X\).

    Solution

    The support \(\{1,2,\dots\}\) does not depend on \(\theta\). From \(\ln p_X=(k-1)\ln(\theta-1)-k\ln\theta\),

    \[ \frac{\partial\ln p_X}{\partial\theta}=\frac{k-1}{\theta-1}-\frac k\theta=\frac{(k-1)\theta-k(\theta-1)}{\theta(\theta-1)}=\frac{k-\theta}{\theta(\theta-1)}. \]

    So \(I(\theta)=\E\big[(X-\theta)^2\big]/\big(\theta(\theta-1)\big)^2=\V X/(\theta^2(\theta-1)^2)=1/(\theta(\theta-1))\), and the Cramér-Rao bound is \(\theta(\theta-1)/n\). Since \(\bar X\) is unbiased with \(\V\bar X=\V X/n=\theta(\theta-1)/n\), it attains the bound: \(\bar X\) is efficient, as in the book's answer. Consistent with Filling the gap 5.13, the score of the sample is \(\sum\frac{X_i-\theta}{\theta(\theta-1)}=\frac{n}{\theta(\theta-1)}(\bar X-\theta)=nI(\theta)(\bar X-\theta)\).

  8. Question 5.6.7 (the threshold model). For \(f_Y(y;\theta)=e^{-(y-\theta)}\), \(y\ge\theta\): (a) show that \(Y_{\min}\) is sufficient for \(\theta\); (b) show that \(Y_{\max}\) is not.

    Hint 1 of 4: the key idea

    (a) Write the support condition as an indicator and see which order statistic it involves. (b) Use the proportional-likelihood test of Filling the gap 5.17.

    Hint 2 of 4: tools you will need
    • Theorem 5.6.1 (factorization).
    • \(\prod\one\{y_i\ge\theta\}=\one\{y_{\min}\ge\theta\}\).
    • Filling the gap 5.17.
    Hint 3 of 4: part (a)

    Factor \(L(\theta)=e^{-\sum y_i}\cdot e^{n\theta}\one\{y_{\min}\ge\theta\}\).

    Hint 4 of 4: part (b)

    Find two samples with the same maximum, and a \(\theta\) at which exactly one of the likelihoods is 0. Derive a contradiction.

    Solution

    (a) With the indicator \(\one\{y\ge\theta\}\), \(L(\theta)=\prod e^{-(y_i-\theta)}\one\{y_i\ge\theta\}=e^{-\sum y_i}\cdot e^{n\theta}\one\{y_{\min}\ge\theta\}\), because all \(y_i\ge\theta\) iff the smallest is. This is \(g(y_{\min};\theta)b(\bm y)\) with \(g(t;\theta)=e^{n\theta}\one\{t\ge\theta\}\) and \(b=e^{-\sum y_i}\), so \(Y_{\min}\) is sufficient by Theorem 5.6.1.

    (b) Use the test of Filling the gap 5.17. Take \(n=3\), \(\bm y=(1,2,5)\) and \(\bm y'=(3,4,5)\), both with \(y_{\max}=5\). If \(L=g(y_{\max};\theta)b(\bm y)\), then: \(L(0.5;\bm y)>0\) forces \(b(\bm y)>0\); \(L(2;\bm y)=0\) (the observation 1 is below 2) forces \(g(5;2)=0\); hence \(L(2;\bm y')=g(5;2)b(\bm y')=0\). But \(L(2;\bm y')=e^{-12+6}>0\) since all of 3, 4, 5 exceed 2. Contradiction, so \(Y_{\max}\) is not sufficient: it cannot tell how close to \(\theta\) the smallest observation came.

  9. Question 5.6.9 (exponential form). A density is in exponential form if \(g_W(w;\theta)=e^{K(w)p(\theta)+S(w)+q(\theta)}\), with a range of \(w\) that does not depend on \(\theta\). Show that \(\sum_{i=1}^nK(W_i)\) is sufficient for \(\theta\), and apply this to \(\lambda e^{-\lambda y}\) and to the Pareto density \(\theta/(1+y)^{\theta+1}\), \(y\ge0\) (Questions 5.6.10, 5.6.11).

    Hint 1 of 4: the key idea

    The product of exponentials is the exponential of a sum. Which part of that sum involves both the data and the parameter?

    Hint 2 of 4: tools you will need
    • Theorem 5.6.1 (factorization).
    • Why the range must not depend on the parameter.
    • Rewriting a density as exp(log of it).
    Hint 3 of 4: step 1

    Multiply the \(n\) densities. Aim for: \(\exp(p(\theta)\sum K(w_i)+nq(\theta))\exp(\sum S(w_i))\).

    Hint 4 of 4: step 2

    Read off \(K\) for \(\lambda e^{-\lambda y}\) and for \(\theta/(1+y)^{\theta+1}\).

    Solution

    For a sample \(w_1,\dots,w_n\) in the (fixed) range,

    \[ L(\theta)=\prod_{i=1}^ne^{K(w_i)p(\theta)+S(w_i)+q(\theta)}=\underbrace{\exp\Big(p(\theta)\sum K(w_i)+nq(\theta)\Big)}_{g(\sum K(w_i);\,\theta)}\cdot\underbrace{\exp\Big(\sum S(w_i)\Big)}_{b(w_1,\dots,w_n)}, \]

    so \(\sum K(W_i)\) is sufficient by Theorem 5.6.1. The fixed range matters: otherwise an indicator depending on \(\theta\) and on individual \(w_i\) would appear (as in Question 5.6.7).

    Exponential: \(\lambda e^{-\lambda y}=e^{y(-\lambda)+\ln\lambda}\), with \(K(y)=y\), \(p=-\lambda\), \(S=0\), \(q=\ln\lambda\): \(\sum Y_i\) is sufficient. Pareto: \(\theta(1+y)^{-(\theta+1)}=e^{\ln(1+y)\,(-\theta-1)+\ln\theta}\), with \(K(y)=\ln(1+y)\): \(\sum\ln(1+Y_i)\) is sufficient, as in the book's answer to Question 5.6.11.

  10. Question 5.7.3 (two inconsistent estimators). For a sample from \(f_Y(y;\lambda)=\lambda e^{-\lambda y}\), \(y>0\), show that neither \(\hat\lambda_n=Y_1\) nor \(\hat\lambda_n=\sum_{i=1}^nY_i\) is consistent for \(\lambda\).

    Hint 1 of 4: the key idea

    (a) The law of Y1 does not change with n. (b) The sum grows like n/lambda, far from lambda.

    Hint 2 of 4: tools you will need
    • Definition 5.7.1.
    • The exponential cdf.
    • Chebyshev's inequality (Theorem 5.7.1).
    Hint 3 of 4: part (a)

    Compute \(\P(|Y_1-\lambda|<\lambda/2)\). Aim for: a constant below 1.

    Hint 4 of 4: part (b)

    Bound \(\P(|S_n-\lambda|<\varepsilon)\) by \(\P(|S_n-n/\lambda|>n/\lambda-\lambda-\varepsilon)\) and apply Chebyshev.

    Solution

    (a) \(Y_1\) has the same law for every \(n\). Take \(\varepsilon=\lambda/2\):

    \[ \P(|Y_1-\lambda|<\lambda/2)=\P(\lambda/2<Y_1<3\lambda/2)=e^{-\lambda^2/2}-e^{-3\lambda^2/2}, \]

    a fixed number strictly less than 1 (indeed less than \(e^{-\lambda^2/2}\le1\)). It does not tend to 1, so \(Y_1\) is not consistent.

    (b) \(S_n=\sum Y_i\) has mean \(n/\lambda\) and variance \(n/\lambda^2\). For \(n\) so large that \(n/\lambda>\lambda+\varepsilon\), the event \(|S_n-\lambda|<\varepsilon\) forces \(S_n<\lambda+\varepsilon\), hence \(|S_n-n/\lambda|>n/\lambda-\lambda-\varepsilon\), and Chebyshev's inequality gives

    \[ \P(|S_n-\lambda|<\varepsilon)\le\frac{n/\lambda^2}{(n/\lambda-\lambda-\varepsilon)^2}\ \longrightarrow\ 0. \]

    So the probability tends to 0, not 1: \(S_n\) runs off to infinity. (The book's answer bounds the probability below 1 by comparing with \(Y_1\), which also suffices.) The consistent choice is the maximum likelihood estimator \(n/S_n=1/\bar Y\) (Filling the gap 5.20).

  11. Question 5.8.3 (a pollster's prior). In a binomial poll, the pollster believes the election is close and uses the prior \(\Beta(135,135)\), for which \(\P(0.45<\theta<0.55)\approx0.90\). (a) Find the posterior after \(k\) of \(n\) votes for the candidate. (b) Find the squared-loss Bayes estimate as a weighted average of the maximum likelihood estimate and the prior mean. Evaluate for 480 of 1000.

    Hint 1 of 5: the key idea

    Beta prior, binomial data: the posterior adds successes and failures to the two parameters. The squared-loss estimate is the posterior mean.

    Hint 2 of 5: tools you will need
    Hint 3 of 5: part (a)

    Add \(k\) and \(n-k\) to 135 and 135.

    Hint 4 of 5: part (b)

    Write \((k+135)/(n+270)\) as a weighted average of \(k/n\) and \(\frac12\). Aim for: weights \(n/(n+270)\) and \(270/(n+270)\).

    Hint 5 of 5: part (b): the numbers

    Evaluate for 480 of 1000.

    Solution

    First the claim about the prior: by Filling the gap 5.21 it has mean \(1/2\) and standard deviation \(\sqrt{135^2/(270^2\cdot271)}=0.0304\), and its exact probability of \((0.45,0.55)\) is 0.900.

    (a) By Example 5.8.2 with \(r=s=135\), the posterior is \(\Beta(k+135,\,n-k+135)\).

    (b) By Theorem 5.8.1(b) the Bayes estimate is the posterior mean,

    \[ \frac{k+135}{n+270}=\frac{n}{n+270}\cdot\frac kn+\frac{270}{n+270}\cdot\frac12, \]

    as in the book's answer: the prior counts as 270 extra voters split evenly. For \(k=480\), \(n=1000\): \(\Beta(615,655)\), estimate \(615/1270=0.4843\), with weight \(1000/1270=0.787\) on \(k/n=0.48\). The posterior probability that the candidate's true share exceeds \(1/2\) is 0.131, larger than the 0.103 of a flat prior (Filling the gap 5.8), because the prior pulls towards a tie.

  12. Question 5.8.9 (the beta-binomial law). If \(X\mid\theta\sim\Bin(n,\theta)\) and \(\Theta\sim\Beta(r,s)\) with integer \(r,s\), show that the marginal probability function of \(X\) is

    \[ p_X(k)=\frac{\binom{k+r-1}{k}\binom{n-k+s-1}{n-k}}{\binom{n+r+s-1}{n}},\qquad k=0,1,\dots,n. \]
    Hint 1 of 4: the key idea

    Integrate the joint law over theta: the integral is a beta function. Then convert the gamma functions to factorials and regroup.

    Hint 2 of 4: tools you will need
    • \(\int_0^1\theta^{a-1}(1-\theta)^{b-1}\d\theta=\Gamma(a)\Gamma(b)/\Gamma(a+b)\).
    • \(\Gamma(m)=(m-1)!\).
    • Binomial coefficients as ratios of factorials.
    Hint 3 of 4: step 1

    Write \(p_X(k)=\int_0^1\binom nk\theta^k(1-\theta)^{n-k}f_\Theta(\theta)\d\theta\). Aim for: a product of gamma functions.

    Hint 4 of 4: step 2

    Replace each gamma function by a factorial and group the factors into three binomial coefficients.

    Solution

    Integrate the joint law over \(\theta\), using \(\int_0^1\theta^{a-1}(1-\theta)^{b-1}\d\theta=\frac{\Gamma(a)\Gamma(b)}{\Gamma(a+b)}\):

    \[ p_X(k)=\binom nk\frac{\Gamma(r+s)}{\Gamma(r)\Gamma(s)}\int_0^1\theta^{k+r-1}(1-\theta)^{n-k+s-1}\d\theta=\binom nk\frac{\Gamma(r+s)}{\Gamma(r)\Gamma(s)}\cdot\frac{\Gamma(k+r)\Gamma(n-k+s)}{\Gamma(n+r+s)}. \]

    With integer arguments, \(\Gamma(m)=(m-1)!\), and regrouping the factorials,

    \[ p_X(k)=\frac{n!}{k!(n-k)!}\cdot\frac{(r+s-1)!}{(r-1)!(s-1)!}\cdot\frac{(k+r-1)!(n-k+s-1)!}{(n+r+s-1)!}=\frac{(k+r-1)!}{k!(r-1)!}\cdot\frac{(n-k+s-1)!}{(n-k)!(s-1)!}\cdot\frac{n!(r+s-1)!}{(n+r+s-1)!}, \]

    which is the stated formula since \(\frac{n!(r+s-1)!}{(n+r+s-1)!}=1\big/\binom{n+r+s-1}{n}\). A check: with \(r=s=1\) (flat prior) every \(k\) has probability \(\binom{n+1}{n}^{-1}=\frac1{n+1}\), Bayes' own uniform result. The probabilities sum to 1 automatically, since they form the marginal law of \(X\).

Demonstrations for this chapter

Each demonstration runs in the browser and links back to these notes. The ▶ Demo boxes above open them already set to the case under discussion.

DemonstrationWhat you can seeSections and results
Which unbiased estimator?Simulated sampling distributions of competing unbiased estimators, their exact and simulated variances, relative efficiencies and the Cramér-Rao bound (or why it does not apply). Presets: 1 Example 5.4.6; 2 Example 5.5.2, \(n=20\); 3 uniform, Questions 5.4.18 and 5.4.21; 4 exponential, Question 5.4.19; 5 Example 5.4.5.Sections 5.4, 5.5; 5.10, 5.13, 5.15; Question 5.4.19
What does a statistic remember?The conditional law of a Bernoulli or Poisson sample given a statistic, under two values of the parameter side by side, and the largest gap between them (zero exactly for a sufficient statistic). Presets: 1 the sum, (5.6.1); 2 \(X_1\) alone; 3 \(X_1+2X_2+3X_3\), Question 5.6.2; 4 Poisson sum, Example 5.6.1; 5 the maximum.Section 5.6; 5.17, 5.19
Prior plus dataConjugate updating (beta-binomial and gamma-Poisson), the posterior mean as a weighted average, the posterior median and the cost-ratio quantile of Max's inventory loss, a 95% credible interval. Presets: 1 Case Study 5.8.1; 2 Example 5.8.2; 3 Example 5.8.5; 4 Question 5.8.3 and Max's poll; 5 a flat prior, Question 5.8.4.Section 5.8; 5.8, 5.21–5.23; Question 5.8.3

Related demonstrations elsewhere: the first-year likelihood demo (Section 5.2), confidence interval demo and proportions demo (Section 5.3), estimators demo (Section 5.4); in the graduate course, the interval coverage, efficiency, consistency, Bayes loss and bootstrap replications demos.

References

  1. Casella, G. and Berger, R. L. (2002). Statistical Inference, 2nd edition. Duxbury, Pacific Grove. (Sufficiency, completeness, the Rao-Blackwell and Lehmann-Scheffé theorems, the Cramér-Rao bound.)
  2. Cramér, H. (1946). Mathematical Methods of Statistics. Princeton University Press, Princeton.
  3. Efron, B. and Tibshirani, R. J. (1993). An Introduction to the Bootstrap. Chapman and Hall, New York.
  4. Fisher, R. A. (1922). On the mathematical foundations of theoretical statistics. Philosophical Transactions of the Royal Society of London, Series A, 222, 309–368.
  5. Larsen, R. J. and Marx, M. L. (2018). An Introduction to Mathematical Statistics and Its Applications, 6th edition. Pearson, Boston. Chapter 5, pp. 278–342.
  6. Lehmann, E. L. and Casella, G. (1998). Theory of Point Estimation, 2nd edition. Springer, New York.
  7. Rao, C. R. (1945). Information and the accuracy attainable in the estimation of statistical parameters. Bulletin of the Calcutta Mathematical Society, 37, 81–91.
  8. Wasserman, L. (2004). All of Statistics. Springer, New York. (Chapters 6, 8, 9, 11 and 12; the graduate companion course.)