Estimation answers "how large is the parameter?"; a test answers "is it, or is it not, this value?". This chapter builds the logic of a decision rule from the courtroom analogy: fix the chance of wrongly rejecting the status quo, find the cut-off that delivers it, and then ask how often the rule catches a real effect. It covers the Z test and the P-value, the binomial test (large-sample and exact), the two kinds of error and the power curve that summarises them, the generalized likelihood ratio as a recipe for building tests, and the warning that a statistically significant difference need not matter. The book works these ideas through numbers; these notes add the missing arguments (why the two tails are equal, why a P-value is uniform, how a randomized test reaches an exact level, why decision rules can be built on a sufficient statistic, what the likelihood ratio looks like for the uniform parameter) and correct a few rounding slips 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
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.
They follow the book. Sections carry the book's numbers (6.1 to 6.6) and numbered items keep theirs (Definition 6.2.4, Theorem 6.3.1, Example 6.4.2, Case Study 6.3.2). 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. \((6.2.1)\).
Filling the gaps. Wherever the book says "it can be shown", leaves an exercise to the reader, defers to a later chapter or works an example too fast to follow, an orange Filling the gap box gives the full argument. 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. Seventeen figures of the chapter (6.2.2 to 6.2.6, 6.3.1, 6.4.2 to 6.4.4, 6.4.6 to 6.4.10, 6.5.1, 6.6.1 and 6.6.2) are reproduced; three own figures (x6.1 to x6.3) show the true size of the large-sample binomial test, the exact distribution behind Case Study 6.4.1 and the power of the likelihood ratio test of Section 6.5. The schematic drawings and the two-by-two table of the book are not redrawn. All are computed by the Python code. The ▶ Demo boxes open an interactive demonstration already set to the case being discussed.
R. J. Larsen and M. L. Marx, An Introduction to Mathematical Statistics and Its Applications, 6th edition, Pearson (2018), Chapter 6, pages 343–379. 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.
The logic of tests is also developed, at other levels and in other words, in the companion courses of this site. Where a proof there is complete, these notes give the statement and a short argument and link to it rather than repeating it.
New here: why the two-sided region has equal tails (Filling the gap 6.1), the P-value as a uniform variable and the smallest level of rejection (6.2), nested tests and the duality with confidence intervals (6.3), the closed form of inequality (6.3.1) and the accuracy of the normal approximation (6.4), exact binomial P-values (6.5), a randomized test of exact size (6.6), the power function (6.7), the sample-size formula and the rounding in Example 6.4.1 (6.8), tests built on a sufficient statistic (6.9), Poisson sums (6.10), the exact law of the number of runs (6.11), the likelihood ratio and its invariance (6.12), the uniform GLRT in full (6.13), the GLRT for a normal mean (6.14), the Neyman–Pearson lemma (6.15) and consistency and the sample size for a trivial effect (6.16).
Notation. \(\P\), \(\E\), \(\V\) are probability, mean and variance, and \(\P_\theta\) means "when the parameter is \(\theta\)". \(Z\sim\N(0,1)\), \(\Phi\) is its cdf, \(\varphi\) its density and \(z_\alpha\) the number with \(\P(Z\ge z_\alpha)=\alpha\) (so \(z_{.05}=1.645\)). A test rejects \(H_0\) when the data fall in the critical region \(C\); its power function is \(\pi(\theta)=\P_\theta(\text{reject }H_0)\), its size is \(\sup_{\theta\in H_0}\pi(\theta)\) and it has level \(\alpha\) if \(\pi(\theta)\le\alpha\) throughout \(H_0\) (the book's "level of significance" is the size). \(\beta(\theta)=1-\pi(\theta)\) is the probability of a Type II error. Observations are \(y_1,\dots,y_n\) with mean \(\bar y\).
Prerequisites. Chapter 4 of the book for the normal law, Chapter 5 for the likelihood and sufficiency, Chapter 3 for order statistics (see the notes of Chapter 3).
p. 343 A confidence interval (Chapter 5) answers "how large is the parameter?". Often the real question is a choice between two rival statements: the accused is sane or not, the vaccine works or not, the offspring follow Mendel's ratios or not. Splitting the possible conclusions into two and using probability to choose between them is hypothesis testing. The rivals are the null hypothesis \(H_0\) and the alternative \(H_1\). The book compares the procedure with a jury trial: \(H_0\) plays the defendant, presumed innocent unless the evidence is overwhelming, and the "evidence" is a set of measurements whose behaviour is described by a random variable.
Every test of this chapter has the same skeleton. A statistic \(T(y_1,\dots,y_n)\) is computed from the data; a critical region \(C\) is fixed in advance; \(H_0\) is rejected if \(T\in C\). What distinguishes one test from another is the choice of \(T\) and \(C\). The rest of the chapter answers three questions: how \(C\) is chosen so that a true \(H_0\) is rarely rejected (Sections 6.2 and 6.3), how often a false \(H_0\) escapes (Section 6.4), and whether there is a principled way to choose \(T\) at all (Section 6.5).
See also (companion courses): first-year course, the logic of a test; Section 4 of the advanced notes for the definitions of power function, size and level used below; A hypothesis test on trial (preset 1: the null hypothesis is true and the test still raises false alarms at rate \(\alpha\)).
pp. 344–347 An automobile company tests a fuel additive. Thirty cars drive from Boston to Los Angeles; without the additive the same cars average 25.0 mpg, and past experience puts the standard deviation of the mileages at \(\sigma=2.4\) mpg. With the additive the sample mean is \(\bar y=26.3\). Model the mileages as independent \(\N(\mu,2.4^2)\) and test \[ H_0\colon\mu=25.0\quad\text{(no effect)}\qquad\text{against}\qquad H_1\colon\mu>25.0\quad\text{(the additive helps)}. \] Small and moderate values of \(\bar y\) give no reason to reject (the null gets the benefit of the doubt), and very large values do, so the rule has the form "reject \(H_0\) if \(\bar y\ge y^*\)". The question is where to put \(y^*\).
The book decides by asking how often the rule would reject a true null hypothesis. Under \(H_0\), \(\bar Y\sim\N(25,\,2.4^2/30)\), with standard deviation \(2.4/\sqrt{30}=0.438\). A cut-off of \(y^*=25.25\) is far too low: \[\P(\bar Y\ge25.25\mid\mu=25)=\P(Z\ge0.57)=0.2843\] (Figure 6.2.2), a false alarm in more than a quarter of experiments. A cut-off of \(y^*=26.50\) is far too high: the same probability is \(\P(Z\ge3.42)=0.0003\) (Figure 6.2.3), as if a jury demanded a signed confession and a body in the trunk. Researchers have settled on a false-alarm probability near 0.05 as a working compromise ("beyond reasonable doubt" in the jury analogy), so \(y^*\) is the number with \(\P(\bar Y\ge y^*\mid\mu=25)=0.05\).
fig_6_2_2.fig_6_2_3.pp. 346–347 Standardising, \(\P(Z\ge(y^*-25)/(2.4/\sqrt{30}))=0.05\) and \(z_{.05}=1.64\) (Figure 6.2.4), so \[ \frac{y^*-25.0}{2.4/\sqrt{30}}=1.64\qquad\Longrightarrow\qquad y^*=25.0+1.64\cdot\frac{2.4}{\sqrt{30}}=25.718.\tag{6.2.1} \] The company rejects \(H_0\) when \(\bar y\ge25.718\); since the observed mean is 26.3, it rejects and concludes that the additive appears to raise mileage. (With the more precise \(z_{.05}=1.6449\) the cut-off is 25.721; the book works with the two-decimal table value.) Rejecting does not prove that \(H_0\) is false: it says that if \(\mu\) were 25.0, a sample mean this large would occur in only 5% of experiments, which is a good reason to doubt \(\mu=25.0\).
fig_6_2_4.p. 347 Table 6.2.1 is a simulation of this rule: 75 samples of size 30 from \(\N(25,2.4^2)\), five of whose means exceed 25.718, against \(75\times0.05=3.75\) expected. The number of false alarms is binomial with \(n=75\), \(p=0.05\), and \(\P(X\ge5)=0.32\), so five is entirely ordinary. (The table is a random draw and is not reproduced; the demonstration A hypothesis test on trial repeats the experiment with fresh samples.)
If \(H_0\colon\mu=\mu_0\) is rejected by a 0.05 rule, the difference between \(\bar y\) and \(\mu_0\) is called statistically significant.
A test statistic is any function of the data whose value decides between acceptance and rejection of \(H_0\). The set of its values that lead to rejection is the critical region \(C\), and the point that separates it from the acceptance region is the critical value. For the additive, both \(\bar y\) (critical value 25.718) and \(z=(\bar y-25.0)/(2.4/\sqrt{30})\) (critical value 1.64) are test statistics; the rules "\(\bar y\ge25.718\)" and "\(z\ge1.64\)" are the same rule.
The probability that the test statistic falls in the critical region when \(H_0\) is true is the level of significance \(\alpha\). In principle \(\alpha\) should reflect the cost of a wrong rejection; in practice it is set to 0.05, sometimes 0.01 or 0.10.
p. 349 The null hypothesis is usually a single value, \(H_0\colon\mu=\mu_0\), the status quo. The alternative covers a range. If it is known beforehand that \(\mu\) can only move one way, \(H_1\) is one-sided (\(\mu>\mu_0\) or \(\mu<\mu_0\)); otherwise it is two-sided, \(H_1\colon\mu\ne\mu_0\), and the false-alarm probability is split between both ends of the critical region, \(\alpha/2\) each. The shape of \(C\) follows the alternative: it contains the values of the statistic that point towards \(H_1\).
Let \(y_1,\dots,y_n\) be a sample from \(\N(\mu,\sigma^2)\) with \(\sigma\) known, and \(z=(\bar y-\mu_0)/(\sigma/\sqrt n)\). At level \(\alpha\):
The book states this without proof; the proof is one line. When \(\mu=\mu_0\), \(Z=(\bar Y-\mu_0)/(\sigma/\sqrt n)\sim\N(0,1)\), so \(\P(Z\ge z_\alpha)=\alpha\), \(\P(Z\le-z_\alpha)=\alpha\) by symmetry, and \(\P(|Z|\ge z_{\alpha/2})=2\cdot\alpha/2=\alpha\): each rule has probability exactly \(\alpha\) of rejecting a true \(H_0\). \(\square\)
See also (companion courses): Theorem 5.1 of the first-year advanced notes proves the same size statement for the \(t\)-test (\(\sigma\) unknown), and the graduate notes show why the size of a one-sided test of a composite null is attained at the boundary value.
The book says the two-sided 0.05 region puts 0.025 in each tail and calls this "moreover", without saying why. Any region \(\{z\le a\}\cup\{z\ge b\}\) with \(\P(a<Z<b)=1-\alpha\) has size \(\alpha\), so something other than the size must pick \(a=-b\). It is unbiasedness: the test should reject a false \(H_0\) at least as often as a true one, \(\pi(\mu)\ge\alpha\) for every \(\mu\). Only the symmetric region has this property.
Size alone does not fix the cut-offs \(a<b\) of a two-sided region. What natural requirement says that the test should reject a false \(H_0\) at least as often as a true one, and what does it force on the power function at \(\delta=0\)?
Write \(\pi(\delta)\) for the rule \(z\le a\) or \(z\ge b\) and differentiate. Aim for: \(\pi'(\delta)=\varphi(b-\delta)-\varphi(a-\delta)\).
Unbiasedness means \(\pi(\delta)\ge\alpha=\pi(0)\) for all \(\delta\). Use \(\pi'(0)=0\) to compare \(\varphi(a)\) and \(\varphi(b)\). Aim for: \(a=-b\), then \(b=z_{\alpha/2}\).
For the converse take \(a=-b\), show \(\pi\) is even and that \(\pi'>0\) for \(\delta>0\) (compare \(|b-\delta|\) with \(b+\delta\)). Then say why no two-sided test is best against both sides.
Write \(\delta=\sqrt n(\mu-\mu_0)/\sigma\). Then \(Z=\sqrt n(\bar Y-\mu_0)/\sigma\sim\N(\delta,1)\) when the mean is \(\mu\), and the acceptance region \(a<Z<b\) has probability \(\Phi(b-\delta)-\Phi(a-\delta)\). The power function is \[ \pi(\delta)=1-\Phi(b-\delta)+\Phi(a-\delta),\qquad \pi'(\delta)=\varphi(b-\delta)-\varphi(a-\delta). \] At \(\delta=0\), \(\pi(0)=\alpha\). If the test is unbiased then \(\pi(\delta)\ge\alpha=\pi(0)\) for all \(\delta\), so \(\delta=0\) is a minimum of a differentiable function and \(\pi'(0)=0\): \(\varphi(b)=\varphi(a)\). The density \(\varphi\) is even and strictly decreasing on \((0,\infty)\), so \(\varphi(a)=\varphi(b)\) with \(a<b\) forces \(|a|=|b|\), that is \(a=-b\), and then \(\P(|Z|<b)=1-\alpha\) gives \(b=z_{\alpha/2}\).
Conversely, for \(a=-b\) the power function is \(\pi(\delta)=\Phi(\delta-b)+\Phi(-\delta-b)\), which is even in \(\delta\), with \(\pi'(\delta)=\varphi(b-\delta)-\varphi(b+\delta)\). For \(\delta>0\) we have \(|b-\delta|<b+\delta\), so \(\varphi(b-\delta)>\varphi(b+\delta)\) and \(\pi'>0\). So \(\pi\) increases in \(|\delta|\) from its minimum \(\alpha\) at \(\delta=0\): the equal-tailed test is unbiased. ∎
There is no better one-sided shortcut either: no two-sided test is most powerful against every \(\mu\). Against \(\mu>\mu_0\) the right-sided test of Theorem 6.2.1(a) has strictly larger power than the two-sided one, and against \(\mu<\mu_0\) the left-sided test does (Neyman–Pearson, Filling the gap 6.15). Equal tails is the sensible compromise, and it is also the generalized likelihood ratio test (Filling the gap 6.14).
pp. 350–351 Example 6.2.1. A cohort of \(n=86\) randomly chosen Bayview sophomores took a new algebra and geometry curriculum and averaged \(\bar y=502\) on the SAT-I mathematics test; nationally the average is \(\mu_0=494\) with \(\sigma=124\). Is there an effect at \(\alpha=0.05\)? A new curriculum might lower scores, so the alternative is two-sided, \(H_1\colon\mu\ne494\), and \[z=\frac{502-494}{124/\sqrt{86}}=0.60.\] This lies between \(-1.96\) and \(1.96\) (Figure 6.2.5), so \(H_0\) is not rejected: eight points above average is well within chance variation.
fig_6_2_5.p. 351 Fail to reject, do not accept. When the statistic is not in \(C\) the proper conclusion is "fail to reject \(H_0\)", not "accept \(H_0\)". As with a "not guilty" verdict, the evidence was not strong enough to overturn the presumption; it has not shown the presumption to be true. Part of the reason is quantitative: the power of the test against a close alternative can be small (Section 6.4), so failing to reject is weak evidence that \(H_0\) holds.
pp. 351–352 There are two ways to report the strength of the evidence. The first fixes \(\alpha\) in advance and reports reject or not. The second reports the P-value, which does not depend on a pre-chosen \(\alpha\).
The P-value of an observed test statistic is the probability, computed when \(H_0\) is true, of a value of the statistic at least as extreme as the one observed, where "extreme" is measured in the direction of \(H_1\).
Small P-values are evidence against \(H_0\); \(H_0\) is rejected at level \(\alpha\) exactly when \(P\le\alpha\), so the P-value is the smallest \(\alpha\) at which the data reject (Filling the gap 6.2). Example 6.2.2. For \(z=0.60\) in Example 6.2.1 and the two-sided alternative, both tails count: \(P=\P(Z\ge0.60)+\P(Z\le-0.60)\), which is \(0.2743+0.2743=0.5486\) (Figure 6.2.6; doubling the unrounded tail area 0.27425 gives 0.5485, and without rounding \(z=0.598\) the P-value is 0.5496). So \(H_0\) would not be rejected at any \(\alpha\) up to 0.5485. With the one-sided alternative \(H_1\colon\mu>494\) only the right tail is extreme and \(P=0.2743\), half as large.
fig_6_2_6.The Comment after Definition 6.2.4 says that \(H_0\) is rejected at level \(\alpha\) if and only if the P-value is at most \(\alpha\), and calls the P-value "the smallest \(\alpha\) at which we can reject". Both statements need an argument, and there is a further fact the book does not state: when \(H_0\) is true, the P-value of the \(z\) test is itself a Uniform\((0,1)\) random variable. That is why "reject if \(P\le\alpha\)" has size exactly \(\alpha\) for every \(\alpha\).
The P-value is a strictly decreasing function of the observed \(z\). What does that say about the set of levels \(\alpha\) at which the data reject, and about the law of the P-value when \(Z\) is standard normal?
Show \(p(z)\le\alpha\iff z\ge z_\alpha\). Aim for: the data reject at level \(\alpha\) exactly for \(\alpha\ge p(z)\), so \(p(z)\) is the smallest such level.
Under \(H_0\), compute \(\P(p(Z)\le u)\) using the equivalence. Aim for: \(\P(p(Z)\le u)=u\). Repeat for the two-sided \(p=2(1-\Phi(|z|))\) with \(z_{u/2}\).
Read off Questions 6.2.3 and 6.2.8: which of the levels 0.01 and 0.05 is the stricter requirement, and what does nesting of the rejection sets imply?
Take the right-sided test; the other two are the same with the obvious tails. If the observed ratio is \(z\), the P-value is \(p(z)=\P(Z\ge z)=1-\Phi(z)\), a strictly decreasing continuous function of \(z\), and \(z_\alpha\) is defined by \(p(z_\alpha)=\alpha\).
Smallest level. For any \(\alpha\in(0,1)\), \[p(z)\le\alpha=p(z_\alpha)\iff z\ge z_\alpha,\] because \(p\) is strictly decreasing. The right-hand side is the rejection rule of Theorem 6.2.1(a). So \(H_0\) is rejected at level \(\alpha\) exactly when \(\alpha\ge p(z)\): the set of levels at which the data reject is \([p(z),1)\), and its smallest member is \(p(z)\). For the two-sided rule the P-value is \(p(z)=2(1-\Phi(|z|))\) and \(p(z)\le\alpha\iff|z|\ge z_{\alpha/2}\), the same argument.
Uniformity. Under \(H_0\), \(Z\sim\N(0,1)\), and for \(u\in(0,1)\) \[\P(p(Z)\le u)=\P(Z\ge z_u)=u,\] by the equivalence just shown. This is the cdf of Uniform\((0,1)\). For the two-sided P-value, \(\P(2(1-\Phi(|Z|))\le u)=\P(|Z|\ge z_{u/2})=u\) as well. ∎
Consequences. (i) Questions 6.2.3 and 6.2.8: the sets of levels at which the data reject are nested, so rejection at \(\alpha=0.01\) implies rejection at \(0.05\) (a smaller \(\alpha\) is a stricter requirement), and the converse fails. (ii) The P-value is a statement about the data under \(H_0\); it is not the probability that \(H_0\) is true. (iii) For discrete statistics the P-value is not exactly uniform and the achievable levels jump (Filling the gap 6.5); the first-year Theorem 4.1 handles the general case.
Three small facts connect the rules of Theorem 6.2.1. (a) Rejection by the two-sided test at level \(\alpha\) always implies rejection by the one-sided test in the direction of the data at the same \(\alpha\), but not the other way round (this is what Question 6.2.5 asks, and the answer is "no"). (b) The two-sided P-value is twice the smaller one-sided P-value. (c) The acceptance region of the two-sided test is a confidence interval, so "reject at level \(\alpha\)" and "\(\mu_0\) lies outside the \(100(1-\alpha)\%\) interval" say the same thing.
Compare the three critical values \(z_\alpha\), \(z_{\alpha/2}\) and the P-values of the two tails. Which rule rejects more easily for data that point to the right, and why does \(z_\alpha<z_{\alpha/2}\)?
For \(z>0\) compare \(z\ge z_{\alpha/2}\) with \(z\ge z_\alpha\). Aim for: two-sided rejection implies one-sided rejection, and a counterexample such as \(z=1.8\) at \(\alpha=0.05\).
Write the left, right and two-sided P-values for \(z>0\). Aim for: \(p_{\text{two}}=2\min(p_{\text{left}},p_{\text{right}})\).
Solve the acceptance condition for \(\mu_0\). Aim for: \(\mu_0\) inside the \(100(1-\alpha)\%\) interval \(\bar y\pm z_{\alpha/2}\sigma/\sqrt n\). Check with Example 6.2.1.
(a) Suppose the data point to the right, \(z>0\). The two-sided rule rejects when \(z\ge z_{\alpha/2}\); the right-sided rule rejects when \(z\ge z_\alpha\). Since \(z_\alpha<z_{\alpha/2}\) (the tail area \(\alpha\) is larger than \(\alpha/2\), so the cut-off is lower), two-sided rejection implies right-sided rejection. The converse fails for \(z\in[z_\alpha,z_{\alpha/2})\): for \(\alpha=0.05\), \(z=1.8\) is rejected by the one-sided test and not by the two-sided one. So rejection in favour of \(H_1\colon\mu>\mu_0\) does not force rejection in favour of \(H_1\colon\mu\ne\mu_0\) at the same \(\alpha\).
(b) If the data are on the right, \(p_{\text{two}}=2\P(Z\ge|z|)=2p_{\text{right}}\) and \(p_{\text{left}}=1-p_{\text{right}}>p_{\text{right}}\) when \(z>0\); so \(p_{\text{two}}=2\min(p_{\text{left}},p_{\text{right}})\) (this is the halving noticed in Example 6.2.2).
(c) The two-sided rule accepts \(H_0\colon\mu=\mu_0\) exactly when \(|\bar y-\mu_0|<z_{\alpha/2}\sigma/\sqrt n\), that is \[\bar y-z_{\alpha/2}\frac{\sigma}{\sqrt n}<\mu_0<\bar y+z_{\alpha/2}\frac{\sigma}{\sqrt n},\] the statement that \(\mu_0\) lies in the usual \(100(1-\alpha)\%\) confidence interval of Chapter 5. Hence the interval is the set of null values that the data do not reject at level \(\alpha\) (and has coverage \(1-\alpha\) because each such test has size \(\alpha\)). ∎
Check with Example 6.2.1. The 95% interval for the Bayview mean is \(502\pm1.96\cdot124/\sqrt{86}=502\pm26.2\), which contains \(\mu_0=494\): not rejected. It also contains 500, 480 and 525, none of which would be rejected either, which is another way of seeing why "fail to reject" is not "accept".
See also (companion courses): Theorem 4.2 of the first-year advanced notes (tests and intervals for any parameter) and its demo Tests and intervals: two views of one object; Theorem 10.10 of the graduate course.
p. 353 Let \(k_1,\dots,k_n\) be the results of \(n\) Bernoulli trials (\(k_i=1\) for a success), with unknown success probability \(p\), and suppose the question is whether \(p\) equals a status-quo value \(p_0\). The natural statistic is the number of successes \(k=k_1+\dots+k_n\), which by Theorem 3.2.1 is binomial: \(\P(X=k)=\binom nk p^k(1-p)^{n-k}\). Two procedures are needed, according to the size of \(n\): a \(z\) ratio when the normal approximation is good, the exact binomial law when it is not.
p. 354 The book switches between the two by the condition \[ 0<np_0-3\sqrt{np_0(1-p_0)}\quad\text{and}\quad np_0+3\sqrt{np_0(1-p_0)}<n.\tag{6.3.1} \] It says that the whole range "mean \(\pm\) three standard deviations" lies inside the possible values \(0,\dots,n\), so the binomial histogram is not squashed against a wall and looks bell-shaped. (Filling the gap 6.4 writes (6.3.1) as a condition on \(n\) alone and says how good the approximation is.)
Let \(k\) be the number of successes in \(n\) trials, with (6.3.1) satisfied, and \(z=\dfrac{k-np_0}{\sqrt{np_0(1-p_0)}}\). To test \(H_0\colon p=p_0\) at level \(\alpha\) (approximately):
When \(p=p_0\), \(\E X=np_0\) and \(\V X=np_0(1-p_0)\), so \(z\) is the standardised count, approximately \(\N(0,1)\) by the central limit theorem; the rules are then those of Theorem 6.2.1.
A point spread is a handicap added to the weaker team so that each side has a 50% chance of beating it. Among 124 National Football League games the favourite beat the spread in 67 (54%). Let \(p=\P(\text{favourite beats the spread})\) and test \(H_0\colon p=0.50\) against \(H_1\colon p\ne0.50\) at \(\alpha=0.05\). Here \(n=124\), \(p_0=0.5\), (6.3.1) holds, and \[ z=\frac{67-124(0.5)}{\sqrt{124(0.5)(0.5)}}=0.90,\] which is inside \((-1.96,1.96)\): fail to reject. The data are consistent with the bookmakers being right. The two-sided P-value is \(2\P(Z\ge0.90)=0.37\), so \(H_0\) would be rejected only at levels \(\alpha\ge0.37\). The book stresses that, in theory, "reject at \(\alpha=0.40\)" would be a correct statement, but a test whose false-alarm rate is 40% is not an acceptable standard of evidence: \(\alpha\) is kept small (at most about 0.10) before looking at the data, and not raised afterwards to obtain a rejection.
Of 747 decedents in a Salt Lake City newspaper's obituaries, 60 (8.0%) died in the three months before their birth month. If deaths are unrelated to birthdays the chance is \(p_0=3/12=0.25\); the postponement theory predicts less. Test \(H_0\colon p=0.25\) against \(H_1\colon p<0.25\) at \(\alpha=0.05\). Then \[z=\frac{60-747(0.25)}{\sqrt{747(0.25)(0.75)}}=-10.7,\] far below \(-z_{.05}=-1.64\): reject. The exact binomial probability \(\P(X\le60)\) is about \(4\times10^{-33}\), so chance alone cannot explain the dip. Other explanations are not ruled out by the test: it says the pattern is not random, not why. The same kind of dip appears in the book's example of elderly Chinese women and the Harvest Moon festival (33 deaths the week before, 70 the week after, against about 51 and 52 expected).
pp. 357–358 When (6.3.1) fails, \(n\) is too small for the normal curve and the critical region is built from the exact binomial probabilities. Example 6.3.1. An experimental arthritis drug is given to \(n=19\) patients; the standard treatment works in 85% of cases. Test \(H_0\colon p=0.85\) against \(H_1\colon p\ne0.85\), with \(\alpha\) near 10%. Here \(np_0+3\sqrt{np_0(1-p_0)}=20.8>19\), so (6.3.1) fails. The null probabilities \(\P(X=k)=\binom{19}k0.85^k0.15^{19-k}\) are in Figure 6.3.1. The expected count is \(np_0=16.15\), and the least likely outcomes are far on either side of it. The critical region \[C=\{k\le13\}\cup\{k=19\}\] has \(\P(X\le13)=0.0537\) and \(\P(X=19)=0.0456\), so \[\alpha=0.0537+0.0456=0.0993\approx0.10,\] with about half of the false-alarm probability on each side. (Filling the gap 6.5 shows where this region comes from.)
fig_6_3_1.See also (companion courses): the first-year advanced notes on proportions and the proportions demo (sizes of the exact and \(z\) tests, and coverage of the corresponding intervals).
The book explains (6.3.1) in words and then uses it as a switch without saying how accurate the \(z\) test is on either side of it. Two facts fill this in. First, (6.3.1) is equivalent to \[n>9\max\Bigl(\frac{p_0}{1-p_0},\ \frac{1-p_0}{p_0}\Bigr),\] a condition on \(n\) alone (for \(p_0=0.5\), \(n>9\); for \(p_0=0.25\), \(n>27\); for \(p_0=0.85\), \(n>51\), which is why \(n=19\) in Example 6.3.1 fails). Second, the error of the normal approximation to the distribution of the \(z\) ratio is at most \(0.4748\,(p_0^2+q_0^2)/\sqrt{np_0q_0}\) (Berry–Esseen), and the continuity correction usually improves it.
Each half of (6.3.1) is an inequality between positive numbers, so you may square it. What condition on \(n\), written without a square root, comes out?
Square \(np_0>3\sqrt{np_0q_0}\) and \(3\sqrt{np_0q_0}<nq_0\). Aim for: \(n>9q_0/p_0\) and \(n>9p_0/q_0\), hence \(n>9\max(p_0/q_0,q_0/p_0)\).
Compute \(\E|k_i-p_0|^3=p_0q_0(p_0^2+q_0^2)\) and plug into Berry–Esseen. Aim for: a bound of the form \(0.4748(p_0^2+q_0^2)/\sqrt{np_0q_0}\); evaluate it for \(n=124\).
Apply the corrected statistic \(z_{cc}=(|k-np_0|-\tfrac12)/\sqrt{np_0q_0}\) to Case Study 6.3.1 and compare its P-value with the exact binomial one.
Closed form. Write \(q_0=1-p_0\) and \(s=\sqrt{np_0q_0}\). The left half of (6.3.1), \(np_0>3s\), has positive sides, so squaring is allowed: \(n^2p_0^2>9np_0q_0\iff np_0>9q_0\iff n>9q_0/p_0\). The right half, \(np_0+3s<n\iff3s<nq_0\iff9np_0q_0<n^2q_0^2\iff9p_0<nq_0\iff n>9p_0/q_0\). Both together are \(n>9\max(p_0/q_0,q_0/p_0)\). The threshold is smallest (\(n>9\)) at \(p_0=1/2\) and grows without bound as \(p_0\to0\) or \(1\) (Figure x6.1, right).
Berry–Esseen. The standardised count is a standardised sum of \(n\) i.i.d. variables with \(\E|k_i-p_0|^3=p_0q_0(p_0^2+q_0^2)\) and variance \(p_0q_0\). The Berry–Esseen inequality (Theorem 5.11 of the graduate course; the constant 0.4748 is due to Shevtsova) bounds the distance between the exact cdf and \(\Phi\) by \(0.4748\cdot\dfrac{p_0q_0(p_0^2+q_0^2)}{(p_0q_0)^{3/2}\sqrt n}=0.4748\,\dfrac{p_0^2+q_0^2}{\sqrt{np_0q_0}}\). For Case Study 6.3.1 (\(n=124\), \(p_0=\frac12\)) this is \(0.4748\times0.5/5.57=0.043\): a guarantee, not the typical error.
Why the true size wanders. The statistic takes only \(n+1\) values, so the true size \(\P(|Z|\ge z_{\alpha/2})\) jumps as \(p_0\) or \(n\) changes, around the nominal \(\alpha\) (Figure x6.1, left). The continuity correction replaces \(k\) by \(k\mp\tfrac12\) toward \(np_0\) (the integer \(k\) stands for the interval \((k-\frac12,k+\frac12)\) of the histogram bar), that is \[z_{cc}=\frac{|k-np_0|-\frac12}{\sqrt{np_0q_0}}.\] For Case Study 6.3.1, \(z_{cc}=(5-0.5)/5.568=0.808\) and the two-sided P-value is \(0.419\), which equals the exact binomial P-value 0.419; the uncorrected \(z=0.898\) (which the book rounds to 0.90) gives 0.369 (0.368 from the rounded 0.90). The correction matters when \(n\) is moderate and the decision is close. ∎
fig_x6_1.See also (companion course): The exact Berry–Esseen error (the exact error of the normal approximation for Bernoulli observations).
Example 6.3.1 picks "\(k\le13\) or \(k=19\)" by inspection of a printout. Two things deserve an argument: why the achievable levels are a short list rather than a continuum, and why this particular two-sided region is the natural choice.
A rule \(C\) has size equal to a sum of some of the \(n+1\) null probabilities. Which outcomes are the most surprising under \(H_0\), and how do you stop adding them?
For \(n=7\), \(p_0=\tfrac12\) list \(\P(X\ge k^*)\) for \(k^*=4,\dots,7\). Aim for: the short list of attainable sizes and the reason no rule has size 0.05.
For Example 6.3.1 sort the probabilities of \(\Bin(19,0.85)\) from the smallest. Aim for: the outcomes \(k\le13\) and then \(k=19\) (0.0456 versus 0.0907 for \(k=14\)).
Define the exact P-value as the total null probability of outcomes no more likely than the observed one, and compute it for Case Study 6.3.1 and for the mice of Question 6.3.2.
Achievable sizes. A rule "reject if \(X\in C\)" has size \(\sum_{k\in C}\P_{p_0}(X=k)\), a sum of some of the \(n+1\) probabilities, so only finitely many sizes are possible. For \(n=7\) and \(H_0\colon p=\tfrac12\) against \(p>\tfrac12\) with rules "reject if \(k\ge k^*\)", the sizes \(\P(X\ge k^*)\) are \(\binom7k/128\) summed from \(k^*\): \[k^*=4:\ 0.5,\quad5:\ 0.2266,\quad6:\ 0.0625,\quad7:\ 0.0078\] (Question 6.3.7, in the book's rounding 0.50, 0.23, 0.06, 0.01). No rule of this form has size 0.05: the choice is between 0.0625, which exceeds the intended 5%, and 0.0078. The usual convention is to take the largest size not exceeding \(\alpha\), so the exact test has size at most \(\alpha\) and often noticeably less.
The "least likely outcomes" rule. A good critical region collects the outcomes that are most surprising if \(H_0\) is true. For a one-sided alternative this means one tail. For a two-sided alternative the outcomes least likely under \(H_0\) lie in both tails, and if the null law is not symmetric the two tails need not have equal probability. The rule is: sort the outcomes by their null probability \(\P_{p_0}(X=k)\) from smallest upwards, and add them to \(C\) while the total stays at most \(\alpha\). For Example 6.3.1 (\(n=19\), \(p_0=0.85\)) the smallest probabilities are those for \(k=0,1,\dots,13\) (total \(0.0537\)) and then \(k=19\) (0.0456; the next, \(k=14\), has 0.0907). Adding \(k=19\) gives 0.0993, and adding \(k=14\) would overshoot to 0.19. So \(\{k\le13\}\cup\{19\}\) is exactly what the rule produces for \(\alpha\approx0.10\). The matching exact P-value of an observed \(k\) is the total null probability of the outcomes no more likely than \(k\): \[P(k)=\sum_{j:\ \P(X=j)\le\P(X=k)}\P(X=j).\]
Illustration. For Case Study 6.3.1 (\(n=124\), \(k=67\), \(p_0=\frac12\); the law is symmetric) this gives \(P=2\P(X\ge67)=0.419\), against 0.369 from the uncorrected \(z\) and 0.419 from the continuity-corrected \(z\). In Question 6.3.2 below the exact P-value (0.070) and the uncorrected \(z\) P-value (0.050) fall on opposite sides of 0.05, and the decision at \(\alpha=0.05\) depends on which is used. ∎
Because the binomial statistic is discrete, no non-randomized rule has size exactly 0.05 in Question 6.3.8 (\(n=9\), \(H_0\colon p=0.6\), \(H_1\colon p>0.6\)). A randomized test adds a coin toss on the boundary: reject always if \(k=9\), reject with probability \(\gamma\) if \(k=8\), and never otherwise. Choose \(\gamma\) so that the size is exactly 0.05.
The sizes of \(\{9\}\) and \(\{8,9\}\) straddle 0.05. If you choose between the two regions with an independent coin, what is the size of the combined rule?
Compute the sizes \(\alpha_1=\P(X=9)\) and \(\alpha_2=\P(X\ge8)\) under \(p=0.6\).
Let the coin show heads with probability \(\gamma\); on heads use \(\{8,9\}\), on tails \(\{9\}\). Write the size as \(\alpha_1+\gamma(\alpha_2-\alpha_1)\) and set it to 0.05. Aim for: \(\gamma\approx0.66\).
Find the power at \(p=0.8\) by the same mixing, and say why the construction is rarely used in practice.
The null probabilities are \(\P(X=9)=0.6^9=0.010078\) and \(\P(X=8)=9\cdot0.6^8\cdot0.4=0.060466\), so \(\P(X\ge8)=0.070544\) is too large and \(\P(X=9)\) is too small for a size of 0.05. Let \(U\) be uniform on \((0,1)\), independent of the data (a random-number generator), and reject if \(X=9\), or if \(X=8\) and \(U\le\gamma\). By the law of total probability (Theorem 2.4.1) the size is \[\P(X=9)+\P(X=8)\,\P(U\le\gamma)=0.010078+0.060466\,\gamma.\] Setting this equal to 0.05 gives \(\gamma=0.039922/0.060466=0.6602\).
The test therefore rejects when \(X=9\), and, when \(X=8\), in about two cases out of three. Its power at a true \(p>0.6\) is \(\P_p(X=9)+\gamma\P_p(X=8)\); at \(p=0.8\) this is \(0.1342+0.6602\times0.3020=0.3336\). In general, for any size \(\alpha\) between two achievable sizes one tosses a coin on the boundary outcome in the same way, and by the Neyman–Pearson lemma (Filling the gap 6.15) the randomized rule is the most powerful test of that size against a simple alternative. Statisticians seldom randomize in practice, because a decision that depends on a coin toss is hard to defend; the construction shows what the discreteness of the data costs, and why one often reports the P-value rather than a yes/no decision. ∎
pp. 359–360 No test can guarantee the right answer. There are two ways to be wrong and two to be right (the book's Figure 6.4.1, a two-by-two table, is shown here as a table).
| \(H_0\) is true | \(H_1\) is true | |
|---|---|---|
| Fail to reject \(H_0\) | correct decision | Type II error, probability \(\beta\) |
| Reject \(H_0\) | Type I error, probability \(\alpha\) | correct decision, probability \(1-\beta\) (the power) |
Comment (p. 370): the two errors first appeared in industrial quality control at Bell Telephone Laboratories as the producer's risk (rejecting a good lot, \(\alpha\)) and the consumer's risk (accepting a bad one, \(\beta\)); Neyman and Pearson generalised them in the 1930s. The apple-sampling plan of Case Study 3.2.1 is exactly this situation (Chapter 3).
p. 360 Type I. For the additive test (\(H_0\colon\mu=25.0\), \(n=30\), reject if \(\bar y\ge25.718\)), \[\begin{aligned}\P(\text{Type I})&=\P(\bar Y\ge25.718\mid\mu=25)\\&=\P(Z\ge1.64)=0.05:\end{aligned}\]it equals \(\alpha\) by construction. Computing it is a non-problem.
pp. 360–361 Type II. \(H_1\) contains many values of \(\mu\), and \(\beta\) is a different number for each. If the additive really lifts the mean to 25.75, \[ \beta(25.75)=\P(\bar Y<25.718\mid\mu=25.75)=\P\Bigl(Z<\frac{25.718-25.75}{2.4/\sqrt{30}}\Bigr)=\P(Z<-0.07)=0.4721, \] so the rule is fooled almost half the time (Figure 6.4.2). If it lifts the mean to 26.8, \(\beta(26.8)=\P(Z<-2.47)=0.0068\) (Figure 6.4.3). (Without rounding \(z\) to two decimals the first value is 0.471; see Notes on the book.)
fig_6_4_2.fig_6_4_3.pp. 362–363 The power \(1-\beta\) is the probability of correctly rejecting a false \(H_0\). Plotting it against the parameter gives the power curve (Figure 6.4.4, for the additive rule). Two points are free: at \(\mu=\mu_0\) the "power" is \(\alpha\), and as the true mean moves away the power rises to 1. The curve describes everything the test can do. At \(\mu=25.75\) the power is 0.53 and at \(\mu=26.8\) it is 0.99. The book reads 0.72 at \(\mu=26.0\) and 0.29 at \(\mu=25.5\) from its graph; the formula of Filling the gap 6.7 gives 0.74 and 0.31.
fig_6_4_4.Power curves serve two purposes: they describe how a single test will perform, and they compare competing tests of the same size. If two tests have the same \(\alpha\), the one whose power curve lies higher at every alternative (Method B in the book's schematic Figure 6.4.5, which is not redrawn) is better. Section 6.5 and Filling the gap 6.15 ask how to find the highest such curve.
Every power calculation in the section has the same form. For the right-sided test of \(H_0\colon\mu=\mu_0\) at level \(\alpha\) with known \(\sigma\), the power at the true mean \(\mu\) is \[ \pi(\mu)=\P_\mu(\text{reject})=\Phi\Bigl(\frac{\sqrt n(\mu-\mu_0)}{\sigma}-z_\alpha\Bigr). \] It is a continuous, strictly increasing function of \(\mu\), equal to \(\alpha\) at \(\mu_0\), tending to 0 as \(\mu\to-\infty\) and to 1 as \(\mu\to\infty\). Consequently the size of the rule "reject if \(z\ge z_\alpha\)" for the composite null \(H_0\colon\mu\le\mu_0\) is still \(\alpha\), attained at the boundary. For the two-sided test, with \(\delta=\sqrt n(\mu-\mu_0)/\sigma\), \(\pi=\Phi(\delta-z_{\alpha/2})+\Phi(-\delta-z_{\alpha/2})\).
Under the true mean \(\mu\) the test statistic is a standard normal shifted by a constant. By how much, and what happens to the rejection probability?
Show \(\pi(\mu)=\P(Z_0\ge z_\alpha-\delta)=\Phi(\delta-z_\alpha)\). Aim for: that formula, equal to \(\alpha\) at \(\mu=\mu_0\) and strictly increasing in \(\mu\).
Deduce that the size for the composite null \(\mu\le\mu_0\) is \(\alpha\). Then redo the two-sided case: \(\Phi(\delta-z_{\alpha/2})+\Phi(-\delta-z_{\alpha/2})\).
Recompute the book's numbers (with cut-off 25.718 at \(\mu=25.75\), 26.8, 26.0, 25.5) and Question 6.4.1. Aim for: 0.529, 0.993, 0.740, 0.309 and 0.0734.
Under the true mean \(\mu\), \(\bar Y\sim\N(\mu,\sigma^2/n)\), so \(Z_0=(\bar Y-\mu)/(\sigma/\sqrt n)\sim\N(0,1)\) and the test statistic is \(Z=(\bar Y-\mu_0)/(\sigma/\sqrt n)=Z_0+\delta\) with \(\delta=\sqrt n(\mu-\mu_0)/\sigma\). Therefore \[\pi(\mu)=\P(Z_0+\delta\ge z_\alpha)=\P(Z_0\ge z_\alpha-\delta)=1-\Phi(z_\alpha-\delta)=\Phi(\delta-z_\alpha).\] Since \(\Phi\) is continuous and strictly increasing and \(\delta\) is increasing in \(\mu\), so is \(\pi\); at \(\mu=\mu_0\), \(\delta=0\) and \(\pi=\Phi(-z_\alpha)=\alpha\). For a composite null \(\mu\le\mu_0\), \(\pi(\mu)\le\pi(\mu_0)=\alpha\), so the size is \(\alpha\) (the first-year course and the graduate course prove the same fact: Theorem 5.2, Filling the gap 10.1). For the two-sided rule, \(\P(Z_0+\delta\ge z_{\alpha/2})+\P(Z_0+\delta\le-z_{\alpha/2})\) gives the formula in the same way.
The book's numbers. With the book's cut-off \(y^*=25.718\) and \(\sqrt{30}/2.4=2.282\): at \(\mu=25.75\), \(\beta=\Phi(-0.0730)=0.4709\) (the book rounds \(-0.0730\) to \(-0.07\) and reads 0.4721 from the table); at \(\mu=26.8\), \(\beta=\Phi(-2.4694)=0.0068\); at \(\mu=26.0\) and \(25.5\) the power is 0.740 and 0.309 (0.738 and 0.307 with the unrounded cut-off \(25+1.6449\cdot2.4/\sqrt{30}=25.721\)). For Question 6.4.1 (Example 6.2.1 at \(\mu=500\), two-sided, \(n=86\), \(\sigma=124\)): \(\delta=6/(124/\sqrt{86})=0.4487\), so \(\pi=\Phi(0.4487-1.96)+\Phi(-0.4487-1.96)=0.0653+0.0080=0.0734\), which is the book's answer 0.0735 up to rounding: with a true mean six points above the national average the test notices only about 7% of the time. ∎
pp. 363–366 For the \(z\) test the power depends on \(\alpha\), \(\sigma\) and \(n\) (and on how far the true mean is from \(\mu_0\)); each can be changed.
fig_6_4_6.fig_6_4_7.pp. 366–367 Example 6.4.1 (sample size). What is the smallest \(n\) for the test of \(H_0\colon\mu=100\) against \(H_1\colon\mu>100\) at \(\alpha=0.05\) to have power 0.60 at \(\mu=103\), when \(\sigma=14\)? The cut-off \(y^*\) must satisfy two equations at once, one from the null distribution (\(\P(\bar Y\ge y^*\mid\mu=100)=0.05\)) and one from the alternative (\(\P(\bar Y\ge y^*\mid\mu=103)=0.60\)): \[ y^*=100+1.64\cdot\frac{14}{\sqrt n}\ (6.4.1),\qquad y^*=103-0.25\cdot\frac{14}{\sqrt n}\ (6.4.2). \] Equating them gives \(\sqrt n\) and \(n\doteq78\) (Filling the gap 6.8 derives the general formula and shows that, without rounding the two quantiles, the smallest sample size is 79).
The book solves each sample-size problem by equating two expressions for \(y^*\). The general solution, and the monotonicity in \(\alpha\), \(\sigma\) and \(n\) that the book illustrates with pictures, are short consequences of the power formula of Filling the gap 6.7.
Power and sample size are linked through one number, \(\sqrt n\,(\mu-\mu_0)/\sigma\). How do \(z_\alpha\) and \(z_\beta\) share it?
State the monotonicity of \(\Phi(\sqrt n(\mu-\mu_0)/\sigma-z_\alpha)\) in \(n\), \(\sigma\) and \(\alpha\). Why do \(\sigma\to\sigma/2\) and \(n\to4n\) coincide?
Require power \(\ge1-\beta\). Aim for: \(n\ge((z_\alpha+z_\beta)\sigma/(\mu-\mu_0))^2\).
Apply it to Example 6.4.1 with the book's quantiles and with exact ones, and check the power at \(n=78\) and \(79\). Aim for: 77.8 versus 78.5, so the smallest \(n\) is 79.
Fix \(n\), \(\sigma\), \(\mu\): \(z_\alpha+z_\beta\) is constant, so what must happen to \(\beta\) when \(\alpha\) falls? Use it backwards on Question 6.4.9.
Monotonicity. Take \(\mu>\mu_0\) fixed. The power \(\pi=\Phi\bigl(\sqrt n(\mu-\mu_0)/\sigma-z_\alpha\bigr)\) increases with \(n\), decreases as \(\sigma\) grows, and increases with \(\alpha\), because \(\Phi\) is increasing and \(z_\alpha\) decreases as \(\alpha\) increases. Moreover \(n\) and \(\sigma\) enter only through \(\sqrt n/\sigma\), which is why \(\sigma\to\sigma/2\) and \(n\to4n\) have identical effect.
Sample size. Let \(z_\beta\) be the number with \(\P(Z\ge z_\beta)=\beta\), so \(\Phi(z_\beta)=1-\beta\). The power is at least \(1-\beta\) exactly when \(\Phi(\delta\sqrt n-z_\alpha)\ge\Phi(z_\beta)\), that is \(\delta\sqrt n-z_\alpha\ge z_\beta\), that is \[ n\ \ge\ \Bigl(\frac{(z_\alpha+z_\beta)\,\sigma}{\mu-\mu_0}\Bigr)^2.\] (The same formula is Theorem 5.2 of the first-year advanced notes.) For the two-sided test replace \(z_\alpha\) by \(z_{\alpha/2}\); the far tail adds a negligible amount of power. For Example 6.4.1, \(\mu-\mu_0=3\), \(\sigma=14\), \(\beta=0.40\). With the book's table values \(z_{.05}=1.64\) and \(z_{.40}=0.25\), \(n\ge(1.89\cdot14/3)^2=77.8\), which the book rounds to 78. With exact quantiles, \(z_{.05}=1.6449\) and \(z_{.40}=0.2533\), \(n\ge(1.8982\cdot14/3)^2=78.5\), and the smallest integer is 79: \(\Phi(\sqrt{78}\cdot\tfrac3{14}-1.6449)=0.5978\) falls just short of 0.60, while \(n=79\) gives 0.6025. (The book's printed form \((16.134)^2(1.64/3)^2\) is the same arithmetic, because \(16.134=14\cdot1.89/1.64\).)
The trade-off between \(\alpha\) and \(\beta\). For fixed \(n\), \(\sigma\) and \(\mu\) the identity above reads \(z_\alpha+z_\beta=\delta\sqrt n\), a constant. Making \(\alpha\) smaller (\(z_\alpha\) larger) therefore forces \(z_\beta\) to be smaller, that is \(\beta\) larger: no cut-off improves both error rates, and only more data (a larger \(\delta\sqrt n\)) can lower both. Question 6.4.9 runs the identity backwards: \(n=16\), \(\sigma=9\), \(\mu-\mu_0=4\) give \(\delta\sqrt n=16/9=1.778\); power 0.85 means \(\delta\sqrt n-z_\alpha=\Phi^{-1}(0.85)=1.036\), so \(z_\alpha=0.742\) and \(\alpha=\P(Z\ge0.742)=0.23\), the book's answer. ∎
p. 367 The same recipe works for any parametric family. To test \(H_0\colon\theta=\theta_0\) in a density \(f_Y(y;\theta)\), the book first writes the rule in terms of a sufficient statistic \(\hat\theta\) for \(\theta\), and takes as critical region the values of \(\hat\theta\) least compatible with \(\theta_0\) but allowed by \(H_1\), with total null probability \(\alpha\). For the normal mean, \(\bar Y\) is sufficient and the least compatible values (for \(H_1\colon\mu>\mu_0\)) are the large ones.
The book asserts that one may "initially define the decision rule in terms of a sufficient statistic" and does not say what, if anything, is lost. Nothing is: for every test that uses the whole sample there is a test that uses only the sufficient statistic \(T\) and has the same power function. (A randomized test is allowed in the statement; see Filling the gap 6.6.)
Given a sufficient statistic \(T\), the conditional law of the data given \(T\) does not involve \(\theta\). How could you average any test over that conditional law?
Define \(\psi(t)=\E[\varphi(\mathbf Y)\mid T=t]\). Why can it be computed without knowing \(\theta\)?
Show \(\E_\theta\psi(T)=\E_\theta\varphi(\mathbf Y)\) for all \(\theta\). Aim for: equal power functions, so nothing is lost by using \(T\) only.
Use the factorisation \(L(\theta)=g(T;\theta)h(\mathbf y)\) to show that the GLR depends on the data only through \(T\) (Question 6.5.6).
Describe a test by its test function \(\varphi(\mathbf y)\in[0,1]\), the probability of rejecting \(H_0\) when the data are \(\mathbf y\); non-randomized tests have \(\varphi\in\{0,1\}\). The power function is \(\pi_\varphi(\theta)=\E_\theta\varphi(\mathbf Y)\). Let \(T=T(\mathbf Y)\) be sufficient for \(\theta\): the conditional law of \(\mathbf Y\) given \(T=t\) does not depend on \(\theta\) (Theorem 5.6.1 of the book gives the factorisation criterion). Define \[\psi(t)=\E[\varphi(\mathbf Y)\mid T=t].\] Because the conditional law does not involve \(\theta\), \(\psi\) is a function of \(t\) alone that can be computed without knowing \(\theta\), so "reject with probability \(\psi(T)\)" is a legitimate test based on \(T\). By the tower property of conditional expectation, for every \(\theta\), \[\pi_\psi(\theta)=\E_\theta\psi(T)=\E_\theta\bigl[\E(\varphi(\mathbf Y)\mid T)\bigr]=\E_\theta\varphi(\mathbf Y)=\pi_\varphi(\theta).\] So the new test has the same Type I and Type II error probabilities everywhere. In particular every power function that can be reached with the full data can be reached from \(T\) alone, and the search for good tests may be restricted to functions of the sufficient statistic. For discrete \(\mathbf Y\), \(\psi(t)=\sum_{\mathbf y:\,T(\mathbf y)=t}\varphi(\mathbf y)\,\P(\mathbf Y=\mathbf y\mid T=t)\), the average of \(\varphi\) over the data sets that give the same value of \(T\). ∎
This is the testing version of the Rao–Blackwell idea of Chapter 5. It also explains Question 6.5.6: the generalized likelihood ratio, which by the factorisation \(L(\theta)=g(T;\theta)\,h(\mathbf y)\) equals \(\max_\omega g(T;\theta)/\max_\Omega g(T;\theta)\), depends on the data only through \(T\), the factor \(h\) cancelling.
pp. 367–368 Example 6.4.2 (uniform). A sample of \(n=8\) comes from the uniform density \(f_Y(y;\theta)=1/\theta\) on \([0,\theta]\), and we test \(H_0\colon\theta=2.0\) against \(H_1\colon\theta<2.0\) at \(\alpha=0.10\), using the largest observation \(Y'_8\) (sufficient for \(\theta\)). Values of \(Y'_8\) well below 2 favour \(H_1\), so the rule is "reject if \(y'_8\le c\)". By Theorem 3.10.1, under \(H_0\) the largest of eight has density \(8(y/2)^7\cdot\frac12\) on \([0,2]\), so \(\P(Y'_8\le c)=(c/2)^8=0.10\), giving \(c=2\cdot0.10^{1/8}=1.50\). If in fact \(\theta=1.7\), \[\beta=\P(Y'_8>1.50\mid\theta=1.7)=1-\Bigl(\frac{1.5}{1.7}\Bigr)^8=0.63\] (Figure 6.4.8): this test is fooled about two times in three by a true upper limit of 1.7, because even when \(\theta=1.7\) the largest of eight observations exceeds 1.50 with substantial probability. The same test reappears in Section 6.5 as the generalized likelihood ratio test.
fig_6_4_8.pp. 368–369 Example 6.4.3 (Poisson). Four counts \(k_1,\dots,k_4\) come from a Poisson law with parameter \(\lambda\), to test \(H_0\colon\lambda=0.8\) against \(H_1\colon\lambda>0.8\) at \(\alpha\) near 0.10. The sum \(\sum k_i\) is sufficient and, when \(H_0\) is true, Poisson with mean \(4\cdot0.8=3.2\) (Figure 6.4.9); its upper tail \(\P(\sum k_i\ge6)=0.1054\), so "reject if \(\sum k_i\ge6\)" has \(\alpha=0.1054\) (the next rule, \(\ge7\), has 0.0446). If \(\lambda=1.2\) the sum is Poisson with mean 4.8, and the probability of \(\sum k_i\ge6\) is the power, \(1-\beta=0.3490\) (Figure 6.4.10): with only four observations the rule detects a 50% increase in the rate about one time in three.
fig_6_4_9.fig_6_4_10.Example 6.4.3 uses two facts without proof: that \(\sum k_i\) is Poisson with parameter \(n\lambda\), and that the right shape of critical region for \(H_1\colon\lambda>0.8\) is "reject for large sums". The first is a moment-generating-function calculation; the second says that large sums are the outcomes that favour every \(\lambda>0.8\) over \(0.8\), by an argument that previews Section 6.5.
Two separate facts. The sum of independent Poissons is Poisson (think moment-generating functions), and a likelihood ratio that is monotone in the sum tells you which tail to reject in.
Compute the mgf of \(\sum X_i\). Aim for: the mgf of \(\Pois(n\lambda)\).
Write \(L(\lambda_1)/L(\lambda_0)\) for \(\lambda_1>\lambda_0\). Aim for: a strictly increasing function of \(s=\sum k_i\), independent of the choice of \(\lambda_1\).
Compute \(\P(\Pois(3.2)\ge6)\) and \(\P(\Pois(4.8)\ge6)\), and note the other available size, \(\P(\Pois(3.2)\ge7)\).
The sum. A Poisson(\(\lambda\)) variable has moment-generating function \(M(t)=\sum_k e^{tk}e^{-\lambda}\lambda^k/k!=\exp\{\lambda(e^t-1)\}\). For independent \(X_1,\dots,X_n\) the mgf of the sum is the product (Theorem 3.12.3), \(\exp\{n\lambda(e^t-1)\}\), the mgf of Poisson(\(n\lambda\)); by uniqueness of the mgf (Theorem 3.12.2; see Section 3.12 of these notes) \(\sum X_i\sim\Pois(n\lambda)\).
The shape of the region. Compare the null value \(\lambda_0=0.8\) with any single alternative \(\lambda_1>\lambda_0\). The joint probability of the data is \(\prod_i e^{-\lambda}\lambda^{k_i}/k_i!\), so the ratio of its values under \(\lambda_1\) and \(\lambda_0\) is \[\frac{L(\lambda_1)}{L(\lambda_0)}=\Bigl(\frac{\lambda_1}{\lambda_0}\Bigr)^{\sum k_i}e^{-n(\lambda_1-\lambda_0)},\] a strictly increasing function of \(s=\sum k_i\) because \(\lambda_1/\lambda_0>1\). The data sets that favour \(\lambda_1\) most over \(\lambda_0\) are therefore those with large \(s\), whatever \(\lambda_1>\lambda_0\) is. By the Neyman–Pearson lemma (Filling the gap 6.15) the rule "reject if \(s\ge c\)" is the most powerful of its size against each \(\lambda_1>0.8\), hence against all of \(H_1\) at once.
Numbers. \(\P(\Pois(3.2)\ge6)=0.1054\) and \(\P(\Pois(4.8)\ge6)=0.3490\); the power increases with \(\lambda\), because \(\frac{d}{d\lambda}\P_\lambda(S\ge c)=\P_\lambda(S=c-1)>0\). Because \(S\) is discrete the size \(0.10\) cannot be hit exactly (the choice is between 0.1054 and 0.0446, as in Filling the gap 6.5). ∎
p. 370 Example 6.4.4. Seven observations are taken from \(f_Y(y;\theta)=(\theta+1)y^\theta\) on \([0,1]\) to test \(H_0\colon\theta=2\) against \(H_1\colon\theta>2\); the rule records \(X\), the number of observations above 0.9, and rejects if \(X\ge4\). Under \(H_0\) the density is \(3y^2\), so each observation exceeds 0.9 with probability \(p=\int_{0.9}^13y^2\,dy=1-0.9^3=0.271\), and \(X\sim\Bin(7,0.271)\) because the observations are independent. Then \[\alpha=\P(X\ge4)=\sum_{k=4}^7\binom7k0.271^k0.729^{7-k}=0.092.\] The trick, turning a continuous problem into a binomial one by counting exceedances, is a general way to build a simple test when the exact law of a better statistic is awkward.
p. 370 Sometimes the test statistic \(X\) has a null law that is unknown, but values of \(X\) can be simulated when \(H_0\) holds. A large number of simulations estimates \(\mu_0=\E X\) and \(\sigma_0^2=\V X\) under \(H_0\), and then \(\dfrac{\bar X-\hat\mu_0}{\hat\sigma_0/\sqrt n}\) may be treated as approximately standard normal for the mean of \(n\) independent observations of \(X\).
In the marine worm Ophryotrocha gracilis two hermaphrodites mate in pairs, one giving eggs and the other sperm. Ten pairs, one member dyed, were watched through six matings each, and each sequence of egg-givers was written as a string of A (unmarked) and B (dyed). The data are in the book's Table 6.4.1; for example pair 7 gave BBAABA. A run is an unbroken stretch of one letter (BBAABA has four: BB, AA, B, A). If one partner tends to give the eggs, runs are few; if they alternate, runs are many; if the donor is chosen at random, a moderate number. The ten run counts are 6, 5, 5, 4, 5, 6, 4, 5, 4, 6, with mean 5.0.
Let \(X\) be the number of runs in one sequence and \(\mu_0=\E X\) when donors are chosen at random; test \(H_0\colon\mu=\mu_0\) against \(\mu\ne\mu_0\). The book does not have the null law \(p_0(k)\) of \(X\) to hand and estimates it by simulating 500 random sequences (Table 6.4.2: relative frequencies 0.022, 0.160, 0.334, 0.298, 0.162, 0.024 for \(k=1,\dots,6\)), obtaining \(\hat\mu_0=3.49\) and \(\hat\sigma_0^2=1.17\). Then \[Z=\frac{5.0-3.49}{\sqrt{1.17}/\sqrt{10}}=4.41,\] far beyond 1.96: reject \(H_0\). The pairs alternate egg-giving much more than chance would produce. (Filling the gap 6.11 shows that the null law can in fact be found exactly, and that \(Z=4.24\); the conclusion does not change.)
The book says it has "not developed the necessary background" to find \(p_0(k)\) and falls back on simulation. The background is in fact elementary. For \(L\) independent fair letters (A or B with probability \(\frac12\) each), the number of runs is \(X=1+\operatorname{Bin}(L-1,\tfrac12)\): \[\P(X=k)=\binom{L-1}{k-1}2^{-(L-1)},\quad\E X=1+\frac{L-1}2,\quad\V X=\frac{L-1}4.\] For \(L=6\): \(\P(X=k)=\frac1{32}(1,5,10,10,5,1)\) for \(k=1,\dots,6\), \(\mu_0=3.5\) and \(\sigma_0^2=1.25\).
A new run starts exactly where two consecutive letters differ. If you record the first letter and the \(L-1\) changes instead of the letters, what do the changes look like when letters are fair and independent?
Express the number of runs as \(1+\sum D_i\) and show \((\ell_1,D_1,\dots,D_{L-1})\) determines the sequence. Aim for: the \(D_i\) are i.i.d. Bernoulli(\(\tfrac12\)).
Deduce \(X-1\sim\Bin(L-1,\tfrac12)\) and the moments 3.5 and 1.25 for \(L=6\). Compare with the simulated 3.49 and 1.17.
Recompute \(Z=(5.0-3.5)/(\sqrt{1.25}/\sqrt{10})\). Then use the exact law of the sum of ten counts, \(10+\Bin(50,\tfrac12)\), for the exact P-value. Aim for: \(Z=4.24\) and \(P\approx2\times10^{-5}\).
Let \(\ell_1,\dots,\ell_L\) be the letters and \(D_i=\mathbf 1\{\ell_i\ne\ell_{i+1}\}\) for \(i=1,\dots,L-1\). A new run starts exactly where the letter changes, so the number of runs is \(X=1+\sum_{i=1}^{L-1}D_i\). The map \((\ell_1,\dots,\ell_L)\mapsto(\ell_1,D_1,\dots,D_{L-1})\) is a bijection of \(\{A,B\}^L\) onto itself (given the first letter and the changes, the sequence is recovered: \(\ell_{i+1}=\ell_i\) if \(D_i=0\) and the other letter if \(D_i=1\)). All \(2^L\) sequences are equally likely, hence so are all \(2^L\) values of \((\ell_1,D_1,\dots,D_{L-1})\): the coordinates are independent and each is uniform on its two values. So \(D_1,\dots,D_{L-1}\) are independent Bernoulli(\(\frac12\)), and \(\sum D_i\sim\Bin(L-1,\frac12)\). The mean and variance are \(1+(L-1)/2\) and \((L-1)/4\).
The book's simulated frequencies (0.022, 0.160, 0.334, 0.298, 0.162, 0.024) scatter around the exact values (0.031, 0.156, 0.3125, 0.3125, 0.156, 0.031) by the usual Monte Carlo error of 500 draws, about \(\pm0.02\); its estimates 3.49 and 1.17 compare with the exact 3.5 and 1.25. With exact moments the ratio for the ten pairs is \[Z=\frac{5.0-3.5}{\sqrt{1.25}/\sqrt{10}}=4.24,\] not 4.41, and the two-sided normal P-value is \(2.2\times10^{-5}\). The normal approximation can itself be checked, because the total number of runs in 10 independent sequences is \(10+\Bin(50,\tfrac12)\): the observed total 50 corresponds to 40 successes and the exact two-sided P-value is \(2\,\P(\Bin(50,\tfrac12)\ge40)=2.4\times10^{-5}\), in close agreement (Figure x6.2). The conclusion is the same as the book's; only the 4.41 changes, and only because 500 simulations are noisier than a formula. ∎
fig_x6_2.p. 375 Sections 6.2 to 6.4 chose a test statistic by common sense: \(\bar y\) for a normal mean, the count for a proportion, the largest observation for a uniform limit. The generalized likelihood ratio (GLR) is a single principle that produces a test in any parametric model, and the later chapters of the book (7, 9 and others) use it repeatedly. The chapter introduces it on the problem of testing the upper limit of a uniform density, where everything can be computed by hand.
Let \(y_1,\dots,y_n\) be a sample from the uniform density on \([0,\theta]\), \(\theta\) unknown, and test \(H_0\colon\theta=\theta_0\) against \(H_1\colon\theta<\theta_0\) at level \(\alpha\). Two parameter sets are needed: \(\omega\), the values allowed by \(H_0\) (here \(\omega=\{\theta_0\}\)), and \(\Omega\), all values allowed at all (here \(\Omega=\{\theta\colon0<\theta\le\theta_0\}\)). The likelihood is \(L(\theta)=\theta^{-n}\) if all \(y_i\le\theta\) and 0 otherwise. Its maximum over \(\omega\) is \(L(\theta_0)=\theta_0^{-n}\), and over \(\Omega\) it is \(y_{\max}^{-n}\) because the maximum likelihood estimate is \(\hat\theta=y_{\max}\) (Question 5.2.10).
For a sample from \(f_Y(y;\theta_1,\dots,\theta_k)\), the generalized likelihood ratio is \[\lambda=\frac{\max_{\omega}L(\theta_1,\dots,\theta_k)}{\max_{\Omega}L(\theta_1,\dots,\theta_k)}=\frac{L(\omega_e)}{L(\Omega_e)}.\] For the uniform model, \(\lambda=(y_{\max}/\theta_0)^n\).
Because \(\omega\subseteq\Omega\), \(0<\lambda\le1\) (Filling the gap 6.12). A value near 1 means that the null value explains the data almost as well as the best value of the parameter; a value near 0 means the data are much more probable under some other parameter, which is evidence against \(H_0\).
A generalized likelihood ratio test (GLRT) rejects \(H_0\) when \(0<\lambda\le\lambda^*\), where \(\lambda^*\) is chosen so that \(\P(0<\Lambda\le\lambda^*\mid H_0)=\alpha\) (\(\Lambda\) is the GLR as a random variable).
The density of \(\Lambda\) under \(H_0\) is often unknown, in which case one shows that \(\Lambda\) is a monotone function of a statistic \(W\) with a known law; a test based on \(W\) is then the same test (Filling the gap 6.12). Here \(\Lambda=W^n\) with \(W=Y_{\max}/\theta_0\), and the book finds the density of \(W\) from Theorem 3.8.2 and Theorem 3.10.1: \(f_W(w)=nw^{n-1}\) on \([0,1]\), so \(\P(W\le w^*)=(w^*)^n=\alpha\) gives \(w^*=\alpha^{1/n}\). The GLRT therefore rejects when \[ \frac{y_{\max}}{\theta_0}\le\alpha^{1/n},\qquad\text{that is}\qquad y_{\max}\le\theta_0\,\alpha^{1/n}. \] For \(n=8\), \(\theta_0=2\), \(\alpha=0.10\) the cut-off is \(2\cdot0.10^{1/8}=1.50\): the GLRT is the test of Example 6.4.2. In fact \(\Lambda\) is exactly Uniform\((0,1)\) under \(H_0\), for every \(n\), so \(\lambda^*=\alpha\) (Figure 6.5.1, Filling the gap 6.13).
fig_6_5_1.The book asks "why?" about \(\lambda\le1\) and then asserts that a test based on a statistic \(W\) is "equivalent" to one based on \(\lambda\) when \(\Lambda\) is a monotone function of \(W\). Both are short.
\(\omega\) is a subset of \(\Omega\). What does that say about two maxima of the same function? And if \(\Lambda\) is a monotone function of \(W\), how are the events \(\{\Lambda\le\lambda^*\}\) and \(\{W\le w^*\}\) related?
Show \(0\le\lambda\le1\), and say when \(\lambda=1\) and when \(\lambda=0\). Aim for: \(0<\lambda\le1\) for data that \(H_0\) does not exclude.
Take \(\Lambda=g(W)\) with \(g\) strictly increasing. Aim for: \(\{\Lambda\le\lambda^*\}=\{W\le g^{-1}(\lambda^*)\}\), hence the same size and the same power function. Apply it to \(g(w)=w^n\).
Range. A maximum over a larger set is at least as large as the maximum over a smaller one. Since \(\omega\subseteq\Omega\), \(\max_\omega L\le\max_\Omega L\), so \(\lambda\le1\), with \(\lambda=1\) when the overall maximum is attained inside \(\omega\) (the null value is as good as any). The ratio is \(\ge0\) because likelihoods are, and it is \(>0\) whenever the data have positive likelihood under some parameter of \(\omega\). When the data are impossible under every null value, \(\lambda=0\) and the test rejects with certainty (for example, \(y_{\max}>\theta_0\) in the uniform model if \(\Omega\) were all \(\theta>0\)). So \(0<\lambda\le1\) for data that \(H_0\) does not exclude.
Equivalence. If \(\Lambda=g(W)\) with \(g\) strictly increasing on the range of \(W\), then \(\{\Lambda\le\lambda^*\}=\{W\le g^{-1}(\lambda^*)\}=\{W\le w^*\}\) as events, so \(\P(\Lambda\le\lambda^*\mid H_0)=\P(W\le w^*\mid H_0)\), and the two rules are the same test with the same size and the same power function; only the labelling of the cut-off differs. (If \(g\) is decreasing the inequality reverses.) For the uniform model, \(g(w)=w^n\) is strictly increasing on \([0,1]\), so \(\lambda\le\lambda^*\iff w\le\lambda^{*\,1/n}\), as the book writes. ∎
Three facts that the book leaves implicit for the uniform model: (1) \(\Lambda\sim\) Uniform\((0,1)\) under \(H_0\), so \(\lambda^*=\alpha\) for every \(n\); (2) the power function of the GLRT is \(\pi(\theta)=\min\{1,\ \alpha(\theta_0/\theta)^n\}\) for \(0<\theta\le\theta_0\); (3) among all tests of level \(\alpha\) it has the largest power at every \(\theta<\theta_0\) (it is uniformly most powerful, and so deserves the name "optimal" of the section title).
Under \(H_0\) the cdf of \(Y_{\max}/\theta_0\) is \(w^n\). What law does \((Y_{\max}/\theta_0)^n\) then have? And how does the density under \(\theta_1<\theta_0\) compare with the density under \(\theta_0\)?
Show \(\P(\Lambda\le\lambda)=\lambda\) on \([0,1]\). Aim for: \(\Lambda\sim\) Uniform(0,1) and \(\lambda^*=\alpha\).
With \(c=\theta_0\alpha^{1/n}\) compute \(\P_\theta(Y_{\max}\le c)\) for \(\theta\le\theta_0\). Aim for: \(\min\{1,\alpha(\theta_0/\theta)^n\}\); check \(0.367\) at \(\theta=1.7\).
Write \(f_{\theta_1}=(\theta_0/\theta_1)^nf_{\theta_0}\mathbf 1\{y_{\max}\le\theta_1\}\) and bound \(\E_{\theta_1}\varphi\) for any level-\(\alpha\) test. Aim for: no test beats \(\min\{1,\alpha(\theta_0/\theta_1)^n\}\).
(1) Under \(H_0\) the observations are i.i.d. uniform on \([0,\theta_0]\), so by independence \(\P(Y_{\max}\le w\theta_0)=\P(Y_1\le w\theta_0)^n=w^n\) for \(0\le w\le1\): \(W=Y_{\max}/\theta_0\) has cdf \(w^n\) (differentiating gives the book's \(nw^{n-1}\)). Then \(\Lambda=W^n\) satisfies \(\P(\Lambda\le\lambda)=\P(W\le\lambda^{1/n})=\lambda\) for \(0\le\lambda\le1\): uniform. Hence \(\P(\Lambda\le\lambda^*)=\lambda^*=\alpha\).
(2) With \(c=\theta_0\alpha^{1/n}\) and a true \(\theta\le\theta_0\), \(\pi(\theta)=\P_\theta(Y_{\max}\le c)=\min\{1,(c/\theta)^n\}=\min\{1,\alpha(\theta_0/\theta)^n\}\): if \(\theta\le c\) every observation is below \(c\) and the test certainly rejects. Check with Example 6.4.2: \(n=8\), \(\theta_0=2\), \(\theta=1.7\), \(\alpha=0.1\) give \(\pi=0.1\cdot(2/1.7)^8=0.367\) and \(\beta=0.633\), the book's 0.63. (For \(\theta=1.9\) the power is 0.151; for \(\theta=1.5\) it is 0.999.) The power rises from \(\alpha\) at \(\theta=\theta_0\) and reaches 1 at \(\theta=c\).
(3) Let \(\varphi\) be any test (possibly randomized, with values in \([0,1]\)) with \(\E_{\theta_0}\varphi\le\alpha\), and fix \(\theta_1<\theta_0\). The density of the sample under \(\theta_1\) is \(\theta_1^{-n}\) on \(\{y_{\max}\le\theta_1\}\) and 0 elsewhere; under \(\theta_0\) it is \(\theta_0^{-n}\) on the larger set \(\{y_{\max}\le\theta_0\}\). So \(f_{\theta_1}(\mathbf y)=(\theta_0/\theta_1)^nf_{\theta_0}(\mathbf y)\mathbf 1\{y_{\max}\le\theta_1\}\), and \[\E_{\theta_1}\varphi=\Bigl(\frac{\theta_0}{\theta_1}\Bigr)^n\E_{\theta_0}\bigl[\varphi\,\mathbf 1\{Y_{\max}\le\theta_1\}\bigr]\le\Bigl(\frac{\theta_0}{\theta_1}\Bigr)^n\E_{\theta_0}\varphi\le\alpha\Bigl(\frac{\theta_0}{\theta_1}\Bigr)^n.\] Of course also \(\E_{\theta_1}\varphi\le1\). So no test of level \(\alpha\) has power above \(\min\{1,\alpha(\theta_0/\theta_1)^n\}\), which the GLRT attains. This is the Neyman–Pearson lemma at work (Filling the gap 6.15) and is proved here directly. ∎
A rival test shows what is gained. A test of the same size based on the sample mean has to cut off the lower tail of \(\bar Y\) under \(H_0\); for \(n=8\), \(\theta_0=2\), \(\alpha=0.10\) its power at \(\theta=1.7\) is about 0.26 (simulated), against 0.367 for the GLRT, and at \(\theta=1.9\) about 0.14 against 0.151 (Figure x6.3). The sample mean throws away the information in the largest observation, which is the sufficient statistic (Filling the gap 6.9).
fig_x6_3.For a sample from \(\N(\mu,\sigma^2)\) with \(\sigma\) known, the GLR for \(H_0\colon\mu=\mu_0\) against \(H_1\colon\mu\ne\mu_0\) is \[\lambda=\exp\Bigl\{-\tfrac12z^2\Bigr\},\qquad z=\frac{\bar y-\mu_0}{\sigma/\sqrt n}.\] So \(\lambda\le\lambda^*\iff|z|\ge z_{\alpha/2}\), and the GLRT is the two-sided test of Theorem 6.2.1(c). With a simple alternative \(H_1\colon\mu=\mu_1\) the likelihood ratio is monotone in \(\bar y\), and the critical region lies in the right tail if \(\mu_1>\mu_0\), in the left tail if \(\mu_1<\mu_0\), whatever the value of \(\mu_1\) (Question 6.5.4).
Under the normal model the log likelihood is a sum of squares. Split it around \(\bar y\); what does the ratio of the two maxima reduce to?
Compute \(\lambda\) and show \(\lambda=e^{-z^2/2}\). Aim for: \(\lambda\le\lambda^*\iff|z|\ge c\).
Fix \(c\) by size \(\alpha\) under \(H_0\). Aim for: \(c=z_{\alpha/2}\): the GLRT is the equal-tailed \(z\) test. What is the law of \(-2\ln\Lambda\)?
For a simple alternative \(\mu_1\) compute \(\ln[L(\mu_1)/L(\mu_0)]\). Aim for: an increasing function of \(\bar y\) if \(\mu_1>\mu_0\) and decreasing if \(\mu_1<\mu_0\) (Question 6.5.4).
The likelihood is \(L(\mu)=(2\pi\sigma^2)^{-n/2}\exp\{-\sum(y_i-\mu)^2/(2\sigma^2)\}\). Expanding \(\sum(y_i-\mu)^2=\sum(y_i-\bar y)^2+n(\bar y-\mu)^2\) shows that \(L\) is largest at \(\mu=\bar y\), so \(\max_\Omega L=(2\pi\sigma^2)^{-n/2}\exp\{-\sum(y_i-\bar y)^2/(2\sigma^2)\}\), while \(\max_\omega L=L(\mu_0)\). The common factors cancel and \[\lambda=\exp\Bigl\{-\frac{n(\bar y-\mu_0)^2}{2\sigma^2}\Bigr\}=e^{-z^2/2}.\] This is a strictly decreasing function of \(|z|\), so \(\lambda\le\lambda^*\iff|z|\ge c\) with \(c=\sqrt{-2\ln\lambda^*}\), and by Filling the gap 6.12 the test is that with critical region \(|z|\ge c\). Under \(H_0\), \(Z\sim\N(0,1)\), so size \(\alpha\) requires \(c=z_{\alpha/2}\). (Question 6.5.3 is the case \(\sigma=1\).) A by-product: \(-2\ln\Lambda=Z^2\) has exactly the \(\chi^2_1\) law under \(H_0\); in general Wilks' theorem says that \(-2\ln\Lambda\) is approximately \(\chi^2\) with \(\dim\Omega-\dim\omega\) degrees of freedom for large \(n\) (Theorem 10.22 of the graduate course); here it holds exactly.
Simple alternative. For \(H_1\colon\mu=\mu_1\), \[\ln\frac{L(\mu_1)}{L(\mu_0)}=\frac{1}{2\sigma^2}\sum\bigl[(y_i-\mu_0)^2-(y_i-\mu_1)^2\bigr]=\frac{n(\mu_1-\mu_0)}{\sigma^2}\Bigl(\bar y-\frac{\mu_0+\mu_1}2\Bigr),\] which is increasing in \(\bar y\) if \(\mu_1>\mu_0\) and decreasing if \(\mu_1<\mu_0\). A large ratio therefore means a large \(\bar y\) in the first case and a small one in the second, and the cut-off for size \(\alpha\) is \(\mu_0\pm z_\alpha\sigma/\sqrt n\) whatever \(\mu_1\) is on that side: the critical region depends on \(\mu_1\) only through the side on which it lies. This is why one rule is best against all \(\mu_1>\mu_0\) (Filling the gap 6.15). ∎
The section title promises "a notion of optimality" but the book never defines one. The standard definition: among all tests of level \(\alpha\), a test is uniformly most powerful (UMP) for \(H_1\) if its power at every parameter value in \(H_1\) is at least that of every other level-\(\alpha\) test. The tool that finds such tests is the lemma below.
To test a simple \(H_0\colon\theta=\theta_0\) against a simple \(H_1\colon\theta=\theta_1\), let \(L(\theta)\) be the likelihood and \(k\ge0\) a constant. The test that rejects when \(L(\theta_1)>k\,L(\theta_0)\) and has size \(\alpha\) has power at least that of every other test of level \(\alpha\) (randomization on the boundary \(L(\theta_1)=kL(\theta_0)\) is needed when the data are discrete).
Compare a likelihood ratio test \(\varphi^*\) with any rival \(\varphi\) point by point: where is \(\varphi^*-\varphi\) positive, and where is \(L(\theta_1)-kL(\theta_0)\) positive?
Show \((\varphi^*-\varphi)(L(\theta_1)-kL(\theta_0))\ge0\) at every data point. Aim for: the product is never negative.
Sum or integrate over the data. Aim for: \(\E_{\theta_1}\varphi^*-\E_{\theta_1}\varphi\ge k(\E_{\theta_0}\varphi^*-\E_{\theta_0}\varphi)\ge0\).
When does the same rule work for all \(\theta_1>\theta_0\) at once? Apply it to \(\bar y\) in the normal model and to \(\sum k_i\) in Example 6.4.3, and say why no UMP two-sided test exists.
Write \(\varphi^*\) for the likelihood ratio test and \(\varphi\) for any other test with \(\E_{\theta_0}\varphi\le\alpha=\E_{\theta_0}\varphi^*\). At every data point, \((\varphi^*-\varphi)(L(\theta_1)-kL(\theta_0))\ge0\): where \(L(\theta_1)>kL(\theta_0)\), \(\varphi^*=1\ge\varphi\); where \(L(\theta_1)<kL(\theta_0)\), \(\varphi^*=0\le\varphi\). Summing (or integrating) over all data gives \(\E_{\theta_1}\varphi^*-\E_{\theta_1}\varphi\ge k(\E_{\theta_0}\varphi^*-\E_{\theta_0}\varphi)\ge0\). ∎
Consequences for this chapter. If the likelihood ratio is increasing in a statistic \(T\) (as for \(\bar y\) in the normal model with \(\mu_1>\mu_0\), and for \(\sum k_i\) in Example 6.4.3), the rule "reject for large \(T\)" does not depend on the particular \(\theta_1>\theta_0\) and is therefore UMP for the whole one-sided alternative: the one-sided \(z\) test and the Poisson test are UMP, and the uniform GLRT of Section 6.5 is UMP (proved directly in Filling the gap 6.13). For a two-sided alternative no UMP test exists (Filling the gap 6.1); the GLRT is then a good compromise rather than a provably best rule.
See also (companion courses): the full proof and the UMP \(z\)-test in Section 6 of the first-year advanced notes (Theorem 6.1); the proof with randomization in Filling the gap 10.16 of the graduate course; the demonstration The Neyman–Pearson lemma (preset 1: normal mean, the \(z\)-test is most powerful; preset 2: Laplace data, where the \(z\)-type test is not).
pp. 378–379 The notion of statistical significance is the most important in the chapter and the easiest to misread. "The difference between \(\bar y\) and \(\mu_0\) is statistically significant" says that a sample mean this far from \(\mu_0\) would be unlikely if the true mean were \(\mu_0\). It does not say that the true mean is far from \(\mu_0\).
The reason is the dependence of the power on \(n\) (Section 6.4). Figure 6.6.1 is the power curve of the additive test with \(n=30\); Figure 6.6.2 adds those for \(n=60\) and \(n=900\), all with \(\alpha=0.05\) and \(\sigma=2.4\). If the true mean is 25.25, a quarter of a mile per gallon above 25.0, the test rejects \(H_0\) in 14% of experiments with \(n=30\), 20% with \(n=60\) and 93% with \(n=900\). That is the good news: more data detect smaller effects. The bad news is that any false null hypothesis, however close the truth is to \(\mu_0\), is rejected with probability close to 1 if \(n\) is large enough. An additive that raised mileage from 25.000 to 25.001 mpg would be worthless to a consumer, but a large enough sample would reject \(H_0\colon\mu=25.000\) with near certainty, and the result would be "statistically significant" while having no practical significance at all.
fig_6_6_1.fig_6_6_2.The book draws two lessons. The new one: be wary of conclusions from very large samples, where many rejections of \(H_0\) may be driven by \(n\) rather than by anything important; look at the size of the difference \(\bar y-\mu_0\) (or \(k/n-p_0\)) as well as at the verdict. The old one: data analysis is not plugging into formulas or reading printouts, and every procedure has assumptions and limits.
The statement that a large enough sample makes any false null "reject with probability near 1" is the consistency of the test: for every fixed \(\mu>\mu_0\), \(\pi_n(\mu)\to1\) as \(n\to\infty\). The sample size needed for a given effect is quantified by the formula of Filling the gap 6.8, and the arithmetic for 25.001 mpg shows how absurd the sample would have to be. What the data show is the size of the effect, which is the confidence interval, not the P-value.
Fix any \(\mu>\mu_0\) and let \(n\) grow in the power formula. What happens to the argument of \(\Phi\), and what does that mean for the claim 'rejects with probability near 1'?
Take the limit \(n\to\infty\). Aim for: \(\pi_n(\mu)\to1\) for every \(\mu>\mu_0\) (consistency), but \(\pi_n(\mu_0)=\alpha\).
Use \(n\ge((z_\alpha+z_\beta)\sigma/\delta)^2\) with \(\sigma=2.4\), \(\alpha=0.05\), power 0.9 and \(\delta=0.5,\ 0.25,\ 0.001\). Aim for: 198, 790 and about 49 million.
Compute the half-width of the 95% interval at that \(n\). What does it tell you that the P-value does not?
Consistency. By Filling the gap 6.7, \(\pi_n(\mu)=\Phi\bigl(\sqrt n(\mu-\mu_0)/\sigma-z_\alpha\bigr)\). For \(\mu>\mu_0\) the argument tends to \(+\infty\) as \(n\to\infty\), so \(\pi_n(\mu)\to1\); for \(\mu=\mu_0\) it stays at \(\alpha\). Hence "significant" can be reached for any \(\mu\ne\mu_0\) by taking \(n\) large, however small \(|\mu-\mu_0|\) is.
The sample needed. For a mean shift of \(\delta=\mu-\mu_0\), power \(1-\beta\) needs \(n\ge((z_\alpha+z_\beta)\sigma/\delta)^2\). With \(\sigma=2.4\), \(\alpha=0.05\), power 0.90 (\(z_\alpha+z_\beta=1.645+1.282=2.927\)): \(\delta=0.5\) mpg needs \(n=198\) cars, \(\delta=0.25\) needs 790, and \(\delta=0.001\) mpg needs \(n=49{,}327{,}761\), about 49 million cars. Halving the effect multiplies the sample size by four.
What to report. The \(z\) ratio of the data is about \(\sqrt n\,\delta/\sigma\) plus noise, so a P-value of \(10^{-6}\) can come from a large effect measured on a few units or from a trivial effect measured on a huge sample, and the P-value alone cannot tell the two apart. The 95% confidence interval \(\bar y\pm1.96\,\sigma/\sqrt n\) can: with 49 million cars it has half-width \(1.96\cdot2.4/\sqrt{4.9\times10^7}=0.0007\) mpg, and it shows at once that the improvement is about 0.001 mpg and not what a consumer would care about. Practical significance is a judgement about the size of the effect, made before the experiment (this fixes the \(\delta\) that the sample size must detect), not something a test can decide. ∎
On page 360 the book computes \(\beta=0.4721\) for \(\mu=25.75\), so the power is \(1-0.4721=0.5279\). On page 362 the "pair just determined" is printed as \((25.75,\,0.5297)\), with the last two digits transposed. (Without rounding \(z\), \(\beta=0.4709\) and the power is 0.5291; with the exact quantile \(z_{.05}=1.6449\) for the cut-off the power is 0.5266.)
The book rounds each \(z\) to two decimals before reading a table, which shifts the fourth decimal of the probabilities. With the cut-off 25.718 and no rounding of \(z\):
| Quantity | book | unrounded |
|---|---|---|
| \(\P(\bar Y\ge25.25\mid\mu=25)\) (Fig. 6.2.2) | 0.2843 | 0.2842 |
| \(\beta\) at \(\mu=25.75\) (Fig. 6.4.2) | 0.4721 | 0.4709 |
| power at \(\mu=25.75\), \(\alpha=0.10\) (Fig. 6.4.6) | 0.6664 | 0.6669 |
| power at \(\mu=25.75\), \(\sigma=1.2\) (Fig. 6.4.7) | 0.9625 | 0.9628 |
| power at \(\mu=26.0\) and \(25.5\) (read from Fig. 6.4.4) | 0.72, 0.29 | 0.740, 0.309 |
None of these changes a conclusion. The two readings from Figure 6.4.4 are the ones that differ at the second decimal; the formula of Filling the gap 6.7 gives the values in the last column.
With the two-decimal quantiles \(1.64\) and \(0.25\) the book obtains \(n=77.8\doteq78\). With exact quantiles (\(1.6449\) and \(0.2533\)) the requirement is \(n\ge78.47\), the power at \(n=78\) is 0.5978 (below the required 0.60) and the smallest sample size that meets it is 79 (power 0.6025). See Filling the gap 6.8.
The statistic \(4.41=(5.0-3.49)/(\sqrt{1.17}/\sqrt{10})\) uses the Monte Carlo estimates 3.49 and 1.17 of the null mean and variance of the number of runs. The exact values are 3.5 and 1.25, which give \(Z=4.24\) (Filling the gap 6.11). The conclusion, a rejection, is unchanged. The book also writes \(E(X)\) and \(E(X^2)-[E(X)]^2\) for what are sample estimates; read them as \(\hat\mu_0\) and \(\hat\sigma_0^2\).
The printed answer gives \(\bar y=12.76\) and \(z=2.19\). The mean of the thirty readings is \(12.7567\) and the unrounded ratio is \(z=2.145\) (\(P=0.032\)); the decision at \(\alpha=0.05\) is the same (see Question 6.2.7 below).
Eight of the book's questions, restated in my own words and covering Sections 6.2 to 6.5, with complete solutions (hidden). Numbers were cross-checked with the book's answers to the odd-numbered questions, which they match except where noted in Notes on the book.
Question 6.2.6 (an odd critical region). A random sample of \(n=16\) comes from a normal law with \(\sigma=6.0\) to test \(H_0\colon\mu=30\) against \(H_1\colon\mu\ne30\). The experimenter takes the critical region to be the set of sample means in the interval \((29.9,\,30.1)\). What is the level of significance? Why is this a poor choice? Which values of \(\bar y\) should form \(C\) for the same \(\alpha\)?
The 'critical region' is a small interval around \(\mu_0\). Which sample means are those, and so which sample means does the rule reject?
Compute \(\P(29.9<\bar Y<30.1\mid\mu=30)\) with \(\sigma/\sqrt n=1.5\). Aim for: \(\alpha\approx0.053\).
Think about where the data fall when \(\mu=30\) and when \(\mu\) is far away, and compare the rejection probabilities. Why is a power below \(\alpha\) alarming?
Keep the same \(\alpha\) and split it equally between the tails. Aim for: \(z_{\alpha/2}\approx1.93\) and \(C=\{\bar y\le27.10\}\cup\{\bar y\ge32.90\}\).
When \(\mu=30\), \(\bar Y\sim\N(30,\,6^2/16)\), with standard deviation \(1.5\). The level is \[\alpha=\P(29.9<\bar Y<30.1)=\P(|Z|<0.1/1.5)=2\Phi(0.0667)-1=0.0532.\]
The region is a poor choice because it consists of the values of \(\bar y\) that agree best with \(H_0\): the test rejects when the data look most like \(\mu=30\) and accepts when they look least like it. Its power at a far-away mean is tiny: at \(\mu=45\) a sample mean within 0.1 of 30 has probability about \(\Phi(-9.9)\), essentially zero, which is far below the level 0.0532. A test whose power falls below \(\alpha\) is worse than ignoring the data (it is badly biased; Filling the gap 6.1).
For the same level, \(C\) should be the two tails, each of probability \(\alpha/2=0.0266\). Then \(z_{0.0266}=1.934\) and \[C=\{\bar y\le30-1.934(1.5)\}\cup\{\bar y\ge30+1.934(1.5)\}=\{\bar y\le27.10\}\cup\{\bar y\ge32.90\}.\] (At \(\alpha=0.05\) the tails would be \(30\pm1.96\cdot1.5=27.06\) and \(32.94\).)
Question 6.2.7 (the breath analyzer). Thirty readings (in percent) from a three-year-old breath analyzer, all taken on a sample whose true value is 12.6, are 12.3, 12.7, 13.6, 12.7, 12.9, 12.6, 12.6, 13.1, 12.6, 13.1, 12.7, 12.5, 13.2, 12.8, 12.4, 12.6, 12.4, 12.4, 13.1, 12.9, 13.3, 12.6, 12.6, 12.7, 13.1, 12.4, 12.4, 13.1, 12.4, 12.9. (a) Taking \(\sigma=0.4\), test \(H_0\colon\mu=12.6\) against \(H_1\colon\mu\ne12.6\) at \(\alpha=0.05\). Should the machine be readjusted? (b) What assumptions does the test make, and are they plausible? (Data: Question 6.2.7 of Larsen and Marx (2018).)
This is Theorem 6.2.1(c) with \(\sigma\) given. The second part is about what could make the \(z\) test unreliable for these readings.
Compute \(\bar y\) without rounding, then \(z\) and the P-value. Aim for: \(z\approx2.15\) and \(P\approx0.03\). What do you recommend, and is a 0.16 shift practically relevant?
List the assumptions, then look at the data: independence of repeated readings, the shape of the sample, the sample standard deviation against 0.4, and the effect of the single reading 13.6.
(a) The mean is \(\bar y=12.7567\) and \(n=30\), so \[z=\frac{12.7567-12.6}{0.4/\sqrt{30}}=\frac{0.1567}{0.0730}=2.145.\] Since \(|z|>1.96\) we reject \(H_0\); the two-sided P-value is \(2\P(Z\ge2.145)=0.032\). (The book's answer 2.19 uses \(\bar y\) rounded to 12.76 first.) The analyzer reads about 0.16 above the true value, and its 95% interval for the mean reading is \(12.757\pm0.143\), that is \((12.61,\,12.90)\), which just excludes 12.6. The test says the bias is real; whether 0.16 percentage points matters is a practical question about how close readings must be (Section 6.6). If it does, recalibrate.
(b) The test assumes (i) the readings are independent and identically distributed, (ii) normal, (iii) with \(\sigma\) known and equal to 0.4. Independence is doubtful for repeated readings of one sample on one machine, because drift or warm-up would make neighbouring readings alike; the order of the readings would need to be examined. The sample standard deviation is 0.32, smaller than the assumed 0.4, so \(\sigma=0.4\) is conservative here. The data are rounded to 0.1 and are right-skewed (skewness 0.67), with one large reading, 13.6. The conclusion is not robust to that single value: deleting it and testing again with \(n=29\) gives \(z=1.72\), no longer significant, though ad hoc deletion of an observation is not a valid way to analyse data. A sensible follow-up is a larger sample, or a test that does not assume normality.
Question 6.3.2 (pawed mice). In mouse strain A/J, 67% of animals are right-pawed. In a sample of 35 mice of strain A/HeJ, 18 were right-pawed. Is the proportion of right-pawed A/HeJ mice significantly different from 0.67? Use a two-sided alternative and \(\alpha=0.05\).
First check the large-sample condition (6.3.1) for \(n=35\), \(p_0=0.67\). Then compute \(z\): is it just inside or just outside the critical values?
Compute \(np_0\), \(\sqrt{np_0(1-p_0)}\) and the interval \(np_0\pm3\sqrt{\cdot}\); then \(z\). Aim for: \(z\approx-1.96\), a borderline case.
Decide at \(\alpha=0.05\) and give the two-sided normal P-value. Aim for: 0.0501, just above 0.05.
Compute the continuity-corrected and the exact P-values. Aim for: about 0.075 and 0.070. Write a conclusion that does not overstate a borderline result.
Let \(p\) be the probability that a mouse of strain A/HeJ is right-pawed and test \(H_0\colon p=0.67\) against \(H_1\colon p\ne0.67\). With \(n=35\), \(np_0=23.45\) and \(\sqrt{np_0(1-p_0)}=\sqrt{35(0.67)(0.33)}=2.782\); \(23.45\pm3(2.782)=(15.1,\,31.8)\) lies inside \((0,35)\), so (6.3.1) holds and Theorem 6.3.1(c) applies: \[z=\frac{18-23.45}{2.782}=-1.959.\] The critical values are \(\pm1.96\), and \(-1.959\) falls (barely) inside, so \(H_0\) is not rejected at \(\alpha=0.05\). The two-sided P-value from the normal curve is \(0.0501\).
The decision is borderline, so look at the other procedures (Filling the gap 6.4, 6.5). The exact binomial P-value (total probability of outcomes no more likely than 18 under \(p=0.67\)) is \(0.070\); the continuity-corrected \(z=(5.45-0.5)/2.782=1.779\) gives \(0.075\). All three agree that, at the 0.05 level, there is no convincing evidence that A/HeJ differs from A/J, while 18 of 35 (51%) is noticeably below 67% and a larger sample would be informative.
Question 6.3.8 (a randomized test of exact level 0.05). A sample of \(n=9\) Bernoulli trials tests \(H_0\colon p=0.6\) against \(H_1\colon p>0.6\), and the level must be exactly 0.05. The probabilities of \(\Bin(9,0.6)\) are \(\P(X=8)=0.060466\) and \(\P(X=9)=0.010078\). Combine two critical regions into one randomized rule with \(\alpha=0.05\), and find the rule's power at \(p=0.8\).
The regions \(\{9\}\) and \(\{8,9\}\) have sizes on either side of 0.05. Mix them with an independent coin.
Compute \(\alpha_1\) and \(\alpha_2\), the sizes of \(\{9\}\) and \(\{8,9\}\) under \(p=0.6\).
Choose \(\gamma\) with \(\gamma\alpha_2+(1-\gamma)\alpha_1=0.05\). Aim for: \(\gamma\approx0.66\), and state the rule in words.
Mix the powers at \(p=0.8\) in the same way. Aim for: a value between the powers of \(\{9\}\) and of \(\{8,9\}\), about 0.33.
The regions \(C_1=\{9\}\) and \(C_2=\{8,9\}\) have sizes \(\alpha_1=0.010078\) and \(\alpha_2=0.060466+0.010078=0.070544\), one below and one above 0.05. Toss a coin that shows heads with probability \(\gamma\) (independent of the data): on heads use \(C_2\), on tails \(C_1\). By the law of total probability (Theorem 2.4.1), \[\alpha=\gamma\alpha_2+(1-\gamma)\alpha_1=\alpha_1+\gamma(\alpha_2-\alpha_1)=0.010078+0.060466\,\gamma.\] Setting \(\alpha=0.05\) gives \(\gamma=0.039922/0.060466=0.660\). In words: reject when \(X=9\); when \(X=8\), reject with probability 0.660; otherwise do not reject.
The power at \(p=0.8\) is, by the same mixing, \[\P_{0.8}(X=9)+\gamma\,\P_{0.8}(X=8)=0.1342+0.660(0.3020)=0.3336.\] For comparison, the non-randomized rule \(C_1\) has power 0.1342 and has size only 0.0101, while \(C_2\) has power 0.4362 but size 0.0705, above 0.05. The randomized rule sits in between, with the exact size demanded (Filling the gap 6.6).
Question 6.4.6 (a mistaken region and the correct one). A sample of \(n=36\) comes from a normal law with \(\sigma=8.0\) to test \(H_0\colon\mu=60\) against \(H_1\colon\mu\ne60\) at \(\alpha=0.07\). An investigator who skipped the lecture takes the critical region to be the interval \((60-y^*,\,60+y^*)\). (a) Find \(y^*\). (b) What is the power at \(\mu=62\)? (c) What would the power be at \(\mu=62\) with the correct two-tailed region?
Part (a) asks for the level of an interval centred at \(\mu_0\): a two-sided probability near the middle. Then compare how often that region and the correct region fire when \(\mu=62\).
Solve \(2\Phi(y^*/1.333)-1=0.07\). Aim for: \(y^*\approx0.117\).
Compute \(\P(60-y^*<\bar Y<60+y^*\mid\mu=62)\). Aim for: about 0.023, below \(\alpha\).
Use the cut-offs \(60\pm z_{0.035}\cdot1.333\) and add the two tails of \(\bar Y\) at \(\mu=62\). Aim for: about 0.38.
Here \(\sigma/\sqrt n=8/6=1.333\). (a) The level of the interval region is \(\P(|\bar Y-60|<y^*)=2\Phi(y^*/1.333)-1=0.07\), so \(\Phi(y^*/1.333)=0.535\), \(y^*/1.333=0.0878\) and \(y^*=0.117\).
(b) At \(\mu=62\), \(\bar Y\sim\N(62,1.333^2)\), and \[\text{power}=\P(59.883<\bar Y<60.117)=\Phi(-1.412)-\Phi(-1.588)=0.0790-0.0562=0.023.\] The power is smaller than \(\alpha=0.07\): the test rejects less often when \(\mu=62\) than when \(\mu=60\), which is the signature of a rule that rejects the values most compatible with \(H_0\).
(c) The correct region has \(z_{\alpha/2}=z_{0.035}=1.812\), so reject if \(|\bar y-60|\ge1.812(1.333)=2.416\), that is \(\bar y\le57.58\) or \(\bar y\ge62.42\). At \(\mu=62\), \[\text{power}=\P(\bar Y\ge62.42)+\P(\bar Y\le57.58)=\bigl(1-\Phi(0.312)\bigr)+\Phi(-3.312)=0.3775+0.0005=0.378.\] The correct region has more than sixteen times the power of the mistaken one.
Question 6.4.12 (chips in an urn). An urn holds ten chips, some white and the rest red. To test \(H_0\colon\) exactly half are white against \(H_1\colon\) more than half are white, three chips are drawn without replacement and \(H_0\) is rejected if two or more are white. Find \(\alpha\), and find \(\beta\) when the urn is (a) 60% white, (b) 70% white.
Sampling without replacement from ten chips: what is the law of the number of white chips among the three drawn, and how does it change with the number in the urn?
For \(r=5\) white chips compute \(\P(X\ge2)\). Aim for: \(\alpha=0.5\).
For \(r=6\) and \(r=7\) compute \(\P(X\le1)=\P(X=0)+\P(X=1)\). Aim for: \(\beta=1/3\) and \(11/60\).
Comment on a test with \(\alpha=0.5\), and compare with the rule 'reject only if all three are white'.
The number \(X\) of white chips among the three drawn is hypergeometric (Theorem 3.2.2) with \(N=10\), \(n=3\) and \(r\) white chips in the urn: \(\P(X=j)=\binom rj\binom{10-r}{3-j}/\binom{10}3\), \(\binom{10}3=120\).
\(\alpha\) (\(r=5\)): \(\P(X\ge2)=\bigl[\binom52\binom51+\binom53\bigr]/120=(50+10)/120=0.5\). This is a very high false-alarm rate: three chips from ten say little.
(a) \(r=6\): \(\beta=\P(X\le1)\). Here \(\P(X=0)=\binom60\binom43/120=4/120\) and \(\P(X=1)=\binom61\binom42/120=36/120\), so \(\beta=40/120=0.333\).
(b) \(r=7\): \(\P(X=0)=\binom33/120=1/120\) and \(\P(X=1)=\binom71\binom32/120=21/120\); \(\beta=22/120=0.183\).
So \(\beta\) falls as the urn gets whiter (the power is 0.667 and 0.817), but the rule's \(\alpha=0.5\) makes it nearly useless as a test of \(H_0\); a larger sample or a stricter cut-off (rejecting only if all three are white gives \(\alpha=10/120=0.083\)) would be needed.
Question 6.4.22 (a product rule). Two observations \(y_1,y_2\) are drawn from the uniform density on \([0,\theta]\) to test \(H_0\colon\theta=2\) against \(H_1\colon\theta<2\). Find \(k^*\) so that "reject if \(y_1y_2\le k^*\)" has level 0.05 (Theorem 3.8.5 is useful), and compare with the rule "reject if \(y_1+y_2\le k\)" of Question 6.4.21.
Rescale to uniforms on \([0,1]\). The event \(\{U_1U_2\le t\}\) is a region under a hyperbola; compute its probability by conditioning on \(U_1\).
Show \(\P(U_1U_2\le t)=t(1-\ln t)\) and solve \(t(1-\ln t)=0.05\) numerically. Aim for: \(k^*=4t\approx0.035\).
Do the sum rule of Question 6.4.21 as an area. Aim for: \(k^2/8=0.05\), \(k\approx0.632\).
Compare the powers at \(\theta=1.5\) of the two rules and of the GLRT based on \(\max(y_1,y_2)\). Aim for: 0.080, 0.089 and 0.089. Why does the product region lose power?
Under \(H_0\) put \(U_i=Y_i/2\), independent and uniform on \([0,1]\); then \(Y_1Y_2\le k^*\iff U_1U_2\le t\) with \(t=k^*/4\). By conditioning on \(U_1=u\), \[\P(U_1U_2\le t)=\int_0^1\P\bigl(U_2\le t/u\bigr)du=\int_0^t1\,du+\int_t^1\frac tu\,du=t+t\ln\frac1t=t(1-\ln t).\] (This is the cdf of a product of two uniforms from Theorem 3.8.5.) Setting \(t(1-\ln t)=0.05\) gives \(t=0.00870\) numerically, so \(k^*=4t=0.0348\).
For the sum rule of Question 6.4.21, \(\P(Y_1+Y_2\le k)\) is the area of a triangle: \(k^2/(2\cdot4)=k^2/8=0.05\), so \(k=\sqrt{0.4}=0.632\) (the book's 0.63).
Comparison. If the true limit is \(\theta=1.5\), the sum rule rejects with probability \(\frac{k^2/2}{\theta^2}=\frac{0.2}{2.25}=0.0889\) (the triangle lies inside the square \([0,\theta]^2\) when \(k\le\theta\)), while the product rule rejects with probability \(t'(1-\ln t')\) with \(t'=k^*/\theta^2=0.01547\), that is \(0.0800\). The sum rule is better here. The generalized likelihood ratio test based on \(\max(y_1,y_2)\le2\sqrt{0.05}=0.447\) (Section 6.5) has power \(0.05\,(2/\theta)^2=0.0889\) as well at \(\theta=1.5\): the three tests differ only at much smaller \(\theta\) (the GLRT is certain to reject once \(\theta\le0.447\)). Any region of size \(\alpha\) that fits inside the square \([0,\theta]^2\) has power exactly \(\alpha(2/\theta)^2\); the product region reaches out along both axes (\(y_1\) can be up to \(\theta\) with \(y_2\) tiny), so it spills out of every square and loses power.
Question 6.5.5 (GLRT for a binomial proportion). Let \(k\) be the number of successes in \(n\) independent Bernoulli trials, \(p=\P(\text{success})\). (a) Show that the critical region of the generalized likelihood ratio test of \(H_0\colon p=\frac12\) against \(H_1\colon p\ne\frac12\) can be written \(k\ln k+(n-k)\ln(n-k)\ge\lambda^{**}\). (b) Use the symmetry of \(f(k)=k\ln k+(n-k)\ln(n-k)\) to show that the region can be written \(|k-\frac n2|\ge c\).
The GLR is the ratio of two binomial likelihoods; the maximum over all \(p\) is at \(\hat p=k/n\). Take logarithms and look at what depends on \(k\).
Write \(\lambda=2^{-n}/[(k/n)^k(1-k/n)^{n-k}]\) and take logs. Aim for: \(\lambda\le\lambda^*\iff k\ln k+(n-k)\ln(n-k)\ge\lambda^{**}\).
Show \(f(k)=k\ln k+(n-k)\ln(n-k)\) is symmetric about \(n/2\) and increasing in \(|k-n/2|\) (look at \(f'\)). Aim for: the region \(|k-\tfrac n2|\ge c\).
(a) The likelihood of \(k\) successes is \(L(p)=\binom nkp^k(1-p)^{n-k}\) (the binomial coefficient cancels in the ratio). Under \(H_0\) it equals \(\binom nk2^{-n}\). The unrestricted maximum is at \(\hat p=k/n\), so \[\lambda=\frac{2^{-n}}{(k/n)^k(1-k/n)^{n-k}}=\frac{2^{-n}n^n}{k^k(n-k)^{n-k}}\] (with \(0^0=1\); for \(k=0\) or \(n\), \(\lambda=2^{-n}\)). Taking logarithms, \[\ln\lambda=-n\ln2+n\ln n-\bigl[k\ln k+(n-k)\ln(n-k)\bigr].\] So \(\lambda\le\lambda^*\iff f(k)\ge\lambda^{**}\) with \(\lambda^{**}=n\ln n-n\ln2-\ln\lambda^*\), where \(f(k)=k\ln k+(n-k)\ln(n-k)\).
(b) \(f(k)=f(n-k)\), so \(f\) is symmetric about \(n/2\). Moreover \(f'(k)=\ln k-\ln(n-k)\), which is negative for \(k<n/2\) and positive for \(k>n/2\) (equivalently \(f''(k)=1/k+1/(n-k)>0\): \(f\) is convex with minimum at \(n/2\)). Hence \(f\) increases with \(|k-n/2|\), and \(\{f(k)\ge\lambda^{**}\}=\{|k-\frac n2|\ge c\}\) for some \(c\) determined by \(\alpha\). The rejection region is symmetric about \(n/2\), as it must be because the null law \(\Bin(n,\frac12)\) is symmetric.
Illustration. For \(n=10\), \(\lambda(9)=2^{-10}/(0.9^9\cdot0.1)=0.0252\) and \(\lambda(5)=1\). The achievable sizes are \(2\P(X\le1)=0.0215\) (reject for \(|k-5|\ge4\)) and \(2\P(X\le2)=0.1094\) (for \(|k-5|\ge3\)); no size is close to 0.05. For large \(n\) the rule \(|k-n/2|\ge c\) is exactly the rule \(|z|\ge z_{\alpha/2}\) of Theorem 6.3.1(c) with \(p_0=\frac12\), because \(z=(k-n/2)/(\sqrt n/2)\).
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.
| Demonstration | What you can see | Sections and results |
|---|---|---|
| The likelihood ratio test for a uniform upper limit | The likelihood \(L(\theta)\) of a simulated sample, the ratio \(\lambda=(y_{\max}/\theta_0)^n\), the histogram of \(\lambda\) over many samples (flat when \(H_0\) is true), the cut-off \(\theta_0\alpha^{1/n}\), and the power curve of the GLRT against a test based on the sample mean. Presets: 1 Example 6.4.2; 2 \(H_0\) true, \(\Lambda\) is uniform; 3 GLRT against the sample-mean test; 4 \(n=20\), \(\alpha=0.05\); 5 stricter \(\alpha=0.01\). | Sections 6.4 and 6.5; 6.9, 6.12, 6.13, 6.15; Question 6.4.22 |
| Statistical versus practical significance | The power of the gas-mileage test as a function of the sample size for a chosen true improvement, a seeded batch of studies drawn with their 95% intervals against the null value and a "practically important" threshold, and the verdict for the first study (P-value, interval, significant or not, important or not). Presets: 1 the book's \(n=30\); 2 \(n=60\); 3 \(n=900\); 4 0.001 mpg with 49 million cars; 5 no effect at all. | Sections 6.4 and 6.6; 6.7, 6.8, 6.16 |
Related first-year and graduate demonstrations: A hypothesis test on trial (P-values, errors and power; Sections 6.2 and 6.4), Power and sample size (Section 6.4), Exact and approximate methods for proportions (Section 6.3), Tests and intervals (Filling the gap 6.3) and The Neyman–Pearson lemma (Filling the gap 6.15).