Statistics · Solutions
Statistical Inference: Hypothesis Testing
Work this sheet on paper, showing every step — the method is what is being tested, and the solutions are written so you can check your route rather than just your verdict. For every test, write down , and the rejection region before you compute anything, name the theorem that gives the statistic its null distribution (“by the one-sample -test”, “by the Neyman–Pearson lemma”, “by duality”), and state each conclusion in the form the theorem actually licenses. No calculator is needed: every critical value and every value of you need is printed in the question, and every other number is exact. Full worked solutions are on a separate page; each question also has its own reveal, so you can check one answer without seeing the rest.
- 1.Computation
A laboratory's assay is supposed to read a reference sample at units. The measurement error is known to have standard deviation units. A technician takes readings and obtains . Use , and .
- (a)Test against at . State the rejection region before computing the statistic.
- (b)Now test against the two-sided alternative, first at and then at .
- (c)Write the two-sided verdict in one correct sentence, and explain why the sentence “at the level we accept that ” is not licensed by the test.
Solution
(a) Set up, then compute. The hypotheses are and . By the one-sample -test the statistic is standard normal under , and for an upward alternative the rejection region is .
The standard error is , so
Since , reject at the level: the readings are consistent with the assay reading high.
(b) Two-sided. The region is now , and the statistic is unchanged, .
At : , so reject.
At : , so fail to reject.
The same data yield different verdicts because the standard of doubt is different, and that standard is fixed before the data are seen — it is not to be adjusted afterwards to reach a preferred verdict.
(c) A correct sentence: “At the level the data do not provide sufficient evidence that the assay's mean reading differs from .”
The test controls one error only: the probability of rejecting a true null. It says nothing about how often it fails to reject a false one. Failing to reject can happen because is true or because the test lacks the power to see the departure — and here the second explanation is live, since is fairly unusual under (the test rejected). Absence of evidence is not evidence of absence.
If one wanted to argue that is close to , the tool is a confidence interval: the interval is . It contains , but it also contains , which is hardly a demonstration that .
- 2.Computation
A supplier claims that at most of its components are defective. An inspector tests components and finds defective. Use , and .
- (a)Check that the normal approximation is usable, then test against at .
- (b)At , give the verdict of the one-sided test against and of the two-sided test. They differ. Under what circumstances is the one-sided verdict the legitimate one to report?
- (c)Explain why the standard error in a test of a proportion uses and not . Then recompute the statistic with in the denominator, give the exact value, and say what it would have done to the one-sided verdict.
Solution
(a) Under , and , both far above , so the normal approximation to the sample proportion applies.
The observed proportion is . The standard error is computed under the null:
So . The two-sided rejection region is , and , so reject at the level.
(b) One-sided against : the region is , and , so reject. Two-sided: the region is , and , so fail to reject.
The one-sided verdict is legitimate only if the direction was fixed before the data were seen — for instance because the inspector's brief was specifically to detect a rate above the claimed one, and a rate below would never have been reported as a violation however small. If the direction was chosen because happened to come out above , the procedure rejects whenever , an event of probability under : it is a test being reported as a one.
(c) The null hypothesis specifies the distribution of the count completely — Binomial — and in particular its variance . A test asks how surprising the data would be if held, so the null variance is the one to use. (An interval has no null value available, which is why it falls back on .)
With in the denominator, , so
It is smaller than because : the function is largest at , and is nearer to than is. Since , the one-sided test would now fail to reject — the choice of denominator is not a technicality here, it changes the verdict.
- 3.Computation
A quality engineer adopts the rule: reject in favour of whenever , using observations from a population with . Use , and .
- (a)Find the significance level of this rule.
- (b)Find the Type II error probability and the power when the true mean is , and again when it is . In each case say which mean you standardise with, and why.
- (c)Keeping the rule “reject when ” fixed, find the smallest for which . Show that at that the Type II error at is also smaller than in (b), and reconcile this with the statement that and trade against each other.
Solution
(a) The standard error is . The significance level is the rejection probability computed under , so standardise with :
This is a lax rule: it convicts a correctly calibrated process about one time in six.
(b) A Type II error is failing to reject when the alternative holds, so the probability is computed under the true mean, not under : it is that is normal with mean , and it is that is standard normal.
At :
so the power is . (That here is not a coincidence: the cutoff sits exactly halfway between and , one standard error from each.)
At : , so the power is . Power rises with the distance of the alternative from the null, as it must.
(c) With the cutoff fixed and free, and
We need , i.e. , i.e. . So the smallest is .
At the Type II error at is
and since , this is less than . Both errors fell.
There is no contradiction. The trade-off is a statement about the cutoff at fixed : sliding upward lowers and raises , and vice versa. Increasing shrinks the standard error, so the sampling distributions under and both tighten around their means and overlap less; the tail of each beyond shrinks at once. Sample size is the lever that relaxes the trade-off, which is exactly why it is computed before a study, not after.
- 4.Computation
A process has nominal mean and known . A sample of gives . Use .
- (a)Compute the -value against and the -value against . Write each as a probability statement about the test statistic before you evaluate it.
- (b)Give all four verdicts: each alternative at and at .
- (c)A colleague writes: “, so the probability that the mean really is is about , and there is a chance the effect is real.” Say precisely what the -value does assert, then explain why each half of the colleague's sentence is wrong.
Solution
(a) The standard error is , so .
Against , “at least as extreme” means at least as far above , so
Against , deviations of either sign count, so by symmetry of the normal
(b) The rule is: reject exactly when .
One-sided: , reject at ; , fail to reject at .
Two-sided: and , fail to reject at both levels.
The one-sided verdicts are only available if the upward direction was specified before the data; otherwise the two-sided pair is the honest report.
(c) What asserts: if the true mean were exactly , a sample of would produce a mean at least units above about of the time. It is a probability of data, computed assuming .
First half. “The probability that the mean is ” is , which conditions in the opposite direction. Converting from to needs Bayes' theorem and a prior probability for , and the -value contains no such thing. The two numbers can differ enormously.
Second half. is not the probability of anything about the hypotheses. Under a true null the -value is uniform on , so is a uniform random number — it is not a level of confidence in . The sentence is also internally inconsistent: the two-sided is , and the same reasoning would then give the effect an chance of being real, so the “probability the effect is real” would depend on which alternative the colleague happened to write down.
- 5.Sketch
A one-sided -test of against is run at with . Use and .
A sketch with no formula beside it earns nothing here: every feature you draw must be justified by an equation or a limit.
- (a)For , write the power as an explicit function of the true mean , and find the values of at which the power equals , and .
- (b)Do the same for .
- (c)Sketch both power curves on one pair of axes for . Mark the three labelled points on each curve, the horizontal line at height , and the behaviour for . State the shape of each curve and where it is steepest, and explain in one sentence how the curve is obtained geometrically from the curve.
Solution
(a) For the standard error is , so the test rejects when . By the theorem on the power of the one-sided -test,
Power : we need , so the argument is , so . The power at the null is the significance level, always.
Power : the argument must be , so , giving — the critical value itself. A true mean sitting exactly on the cutoff is detected half the time.
Power : we need , so . Then , giving .
(b) For the standard error is , the cutoff is , and
The three points are (power ), (power ) and (power ).
(c) Rewrite each curve using :
So each power curve is a normal distribution function in , centred at the critical value with scale : an increasing S-shape, rising from on the far left to on the far right, steepest at its centre where the power is (at for and for ), and symmetric about that point.
The sketch: horizontal axis from to , vertical axis from to , a dashed horizontal line at . Both curves pass through the point where they cross the dashed line, since power at the null equals whatever is. To the left of both curves lie below the dashed line and flatten toward : at the curve is , essentially zero, and the curve is , smaller still — a true mean below the null is almost never “detected” as being above it. To the right, the curve passes through and and is close to by (there it is ); the curve passes through and and is visually from about on.
Geometry: since , the curve at equals the curve at . The curve is the curve compressed horizontally by a factor of toward the pivot — quadrupling the sample halves the effect size that can be detected at any given power, which is the law.
- 6.Computation
A single observation is drawn from the density on , so that is the uniform distribution and the distribution function is . Throughout, .
- (a)Construct the most powerful level- test of against . State the likelihood ratio, the direction in which it is monotone, the rejection region in terms of , and the power.
- (b)A colleague proposes instead: reject when . Verify that this test also has level , compute its power against , and explain what the comparison with (a) illustrates. Comment on the fact that its power is below its level.
- (c)Now construct the most powerful level- test of against , and give its power exactly. Then say whether a uniformly most powerful test exists against , and why.
Solution
(a) The likelihood ratio of to is
strictly increasing in . So is the event for a corresponding constant , and by the Neyman–Pearson lemma the most powerful test rejects for large .
Choose for level under , where is uniform: , so .
Power: under , , so
By the lemma, no level- test has power above against .
(b) Level: under , ✓. Power: under , .
So a test of the same level has power against : the two tests spend the same Type I budget, and the likelihood-ratio test buys nineteen times as much power with it. This is the content of the lemma — controlling is a constraint every admissible test satisfies, not a criterion for choosing among them, and the likelihood ratio tells you where to place the rejection region.
The power is below the level : this test is more likely to reject when is true than when is true, so its rejections are evidence in favour of the null. The reason is visible in the densities: has density , which puts very little mass near , so a small observation is evidence for the uniform and against . The colleague has the direction backwards.
(c) Now
strictly decreasing in . So is : the most powerful test rejects for small . Under , , so .
Power: under , , so
(The density is unbounded near , which is why small observations are the evidence here.)
No uniformly most powerful test exists against . The most powerful test against any rejects for large — the ratio is increasing whenever — while the most powerful test against any rejects for small . A single rejection region cannot be the upper tail and the lower tail at once, so no one test is best against both sides simultaneously.
- 7.Critique
A student pre-registers a two-sided -test of at , collects the data, and obtains . Using , the write-up reads:
Step 1. The two-sided -value is , which exceeds .
Step 2. However, came out above , so the effect is clearly in the positive direction and the appropriate test is one-sided. The one-sided -value is , so we reject .
Step 3. There is therefore only a chance that is true. The effect is real with probability , and a replication of the study would succeed with the same probability.
Step 1 is correct. Nothing after it is.
- (a)Identify every error in Steps 2 and 3. For each, name the definition or theorem it violates and say exactly what the quantity in question actually is.
- (b)Compute the true Type I error rate of the procedure used in Step 2 — “test one-sided at in whichever direction the data point” — and then give the correct verdict and a correct one-sentence report of the result.
Solution
(a) There are four distinct errors.
Step 2: the direction was chosen from the data. The one-sided test's guarantee — level exactly — is a statement about a rejection region fixed before the data are seen. The sentence “the effect is clearly in the positive direction” assumes the conclusion: under , lands above half the time, so the sign of is not evidence of a direction. Picking the tail after looking at the sign is the error the chapter's caution on one-sided tests is about; its true level is computed in (b).
Step 3, first clause: “ chance that is true.” By definition, : a probability of data, computed assuming the null. The clause describes , which conditions the other way round and requires a prior for via Bayes' theorem. The -value contains no prior and cannot be converted without one.
Step 3, second clause: “real with probability .” is not , for the same reason, and it is not a probability of anything about the hypotheses. Under a true null, is uniform on by the theorem that the -value is uniform under the null, so is a uniform random number.
Step 3, third clause: replication. The probability that a replication reaches significance is the power of the replication, which depends on the true effect size and the replication's sample size, neither of which encodes. If is in fact true, a replication “succeeds” with probability — that is what uniformity of under the null means — and if is false the probability could be anything from near to near .
(b) The procedure rejects whenever the one-sided in the observed direction is below , i.e. whenever or , i.e. whenever . Under ,
So the “ test” of Step 2 is a test: choosing the direction after the fact doubles the Type I error rate while reporting the nominal one. (Equivalently, the honest -value for this procedure is the two-sided one, .)
Correct verdict: the pre-registered test was two-sided, , so fail to reject at the level. A correct report: “, two-sided ; the data do not provide sufficient evidence at the level that differs from .” Failing to reject is not a finding that , and a confidence interval for would say more than the verdict does — it would show the size of the estimated effect and how imprecisely it is pinned down.
- 8.Computation
Nine subjects have a reading taken before and after a treatment.
Use and . Assume the differences are approximately normal.
- (a)Form the differences , compute and exactly, and test against at .
- (b)Write down the confidence interval for and show, by rearranging the inequality, that it gives the same verdict as (a) — and what it says that the verdict does not.
- (c)A colleague ignores the pairing and treats the two rows as independent samples of size . Each row has standard deviation close to (the exact values are and ); take . Compute the colleague's statistic exactly, give its verdict, and explain which analysis is valid and why the two disagree so sharply.
Solution
(a) Differences. After minus before, subject by subject: . Their sum is , so .
Deviations from : ; their squares sum to . Hence
The test. By the paired -test — the one-sample -test applied to the differences — the statistic is under . The standard error is , so
The two-sided region is , and , so reject at the level: the treatment changes the reading.
(b) The interval is
Duality: the test rejects exactly when , and multiplying through by the positive this is , i.e. lies outside . Zero is indeed outside , so the interval rejects too — the same inequality read two ways.
What it adds: the test says “not zero”; the interval says the mean improvement is somewhere between about and units, which is the effect size and its precision, neither of which reports.
(c) The difference of the row means is the mean of the differences, so the numerator is again . With and the pooled standard error is
so the colleague's statistic is
Since , the colleague fails to reject — nowhere near significance.
The paired analysis is the valid one. The two-sample -test assumes the two samples are independent, and they are not: they are the same nine people measured twice. The disagreement is not a matter of taste but of a violated hypothesis.
Why so sharp: the readings vary a great deal between subjects (from to before treatment — a spread of about ), but that variation is common to both of a subject's readings and cancels completely in the difference, whose spread is only . The unpaired analysis leaves the between-subject noise in the denominator, inflating the standard error by a factor of , and a real effect of units disappears into it.
- 9.Computation
Use , and .
- (a)A genetic model predicts that four phenotypes occur in the ratio . Among plants the observed counts are . Test the model at , giving as an exact fraction, and state the conclusion in the form the test licenses.
- (b)Fifty patients receive treatment A and fifty receive treatment B. Under A, recover and do not; under B, recover and do not. Test whether recovery is independent of treatment at and at .
- (c)Explain why the degrees of freedom are in (a) but in (b), and why all four deviations in (b) have the same magnitude. Then state the condition under which the approximation is trusted, and decide whether the test in (a) would still be usable if the same ratios had been observed in a sample of plants.
Solution
(a) Under the category probabilities are , so the expected counts are :
all at least . The deviations are (they sum to , as they must). By the chi-square goodness-of-fit theorem,
No parameter was estimated, so . Since , fail to reject: the counts are consistent with . What is licensed is “not shown to depart from the model”, not “the model is confirmed”; and the scale is reassuring, since the mean of a is and is entirely typical of what the model itself would produce.
(b) The row totals are and , the column totals (recovered) and (not), and . By the proposition on the test for independence, :
all at least . The deviations are , , , , so
With : , so reject independence at ; , so fail to reject at . The recovery rates are under A and under B; the evidence that they differ is moderate, not overwhelming.
(c) Degrees of freedom. Each counts the freely varying deviations. In (a) there are categories and one constraint (the counts sum to ), and the null specifies every probability outright, so nothing is estimated: . In (b) there are cells and the same one constraint, but the null “independence” does not specify the cell probabilities — the two marginal proportions (row and column) are estimated from the data, costing one degree each: , which is .
Equal magnitudes. With the margins fixed, the whole table is determined by one cell: , , . Since the expected counts satisfy the same margins, every deviation is . One free cell is another way of seeing .
The condition. The distribution is an approximation, trusted when every expected count is at least about ; the condition is on expected counts, not observed ones. With the expected counts under would be , and the last is below : the statistic is discrete and skewed where is continuous, and the test would reject too often. The remedy is an exact multinomial test or more data — not pooling the rare category into another, which changes the hypothesis being tested.
- 10.Proof
Let be i.i.d. Poisson, so . Use and in part (c) only.
- (a)For , write the likelihood ratio of to in terms of , and prove that the Neyman–Pearson test rejects for large .
- (b)Prove that the test in (a) is uniformly most powerful against the composite alternative , and explain why no uniformly most powerful test exists against .
- (c)Take and . Show that the rule “reject when ” has level and the rule “reject when ” has level . Deduce that no rule of the form “reject when ” has level exactly , identify the one whose level is largest without exceeding , and find its power against as an exact expression.
Solution
(a) The likelihood is
The factorials are the same under both hypotheses and cancel in the ratio:
Since , the coefficient is positive, so — and hence — is a strictly increasing function of alone. Therefore with . By the Neyman–Pearson lemma the most powerful test of level rejects when exceeds the constant that gives level .
(b) The constant is fixed by the requirement , and under the statistic is Poisson. So depends on , and only — the alternative dropped out, exactly as it did for the normal mean. The same rejection region is therefore most powerful against every at once, which is the definition of uniformly most powerful for .
For the coefficient is negative, so is strictly decreasing in and the most powerful test rejects for small . The two-sided alternative contains values on both sides; the best region against one side is an upper tail and against the other a lower tail, and no single region can be both. So no test is most powerful against every simultaneously.
(c) Under , , so
The level of “reject when ” is , which is decreasing in and takes only the discrete values . The value is not among them: overshoots and undershoots. The rule with the largest level not exceeding is , with level about .
Its power against : , so
One observation carries little information about a rate, and the discreteness has forced the test to run at level rather than the nominal , which costs power on top of that.
A remark on the lemma's wording. “ chosen so that the level is exactly ” is not achievable with a non-randomised rule when the data are discrete. The exact-level Neyman–Pearson test here rejects when , and when rejects with a probability chosen so that ; since , this gives . In practice one reports the attainable level instead.
- 11.Proof
Throughout, the test statistic has a continuous distribution under with distribution function .
- (a)Suppose is symmetric about , so , and the test is two-sided with . Prove that, when is true, is uniform on .
- (b)For the one-sided -test rejecting when , with observed value and , prove that is the smallest significance level at which the observed data lead to rejection: .
- (c)A journal publishes a result only if its -value is at most . Suppose every null hypothesis submitted is in fact true. Prove that the -values appearing in the journal are uniform on , find the fraction of published -values below and the fraction in , and say what an observed pile-up of published -values just below would therefore indicate.
Solution
(a) Let for . By symmetry,
which is continuous and strictly increasing on the support of , from to . The two-sided -value is , matching the stated formula; as a random variable, .
Now fix . Because is continuous and strictly increasing it has an inverse on , and
where the third equality uses continuity, so that and the inequality may be taken strict or not. A random variable with on is uniform on .
The argument is the one-sided proof applied to the statistic : symmetry was used only to write in terms of . In particular , so “reject when ” is a level- test, and it coincides with rejecting when , the two-sided critical value.
(b) By definition , which is a strictly decreasing function of because is increasing. Then, for ,
applying the increasing function in the first step and rearranging in the second. So the set of levels at which the data are rejected is exactly the interval , whose infimum is .
At itself the strict rule does not reject — exactly — which is why the statement is an infimum rather than a minimum; the distinction has probability zero and is invisible in practice. This is the operational meaning of a -value: it is the level at which the verdict flips, so reporting tells every reader the verdict at their own .
(c) Let be the -value of a submitted test. Its null is true, so by the theorem that the -value is uniform under the null (or by (a)), . Publication is the event , of probability . For ,
and for the conditional probability is . This is the distribution function of Uniform.
Hence , and likewise : each fifth of the interval receives of the published values.
Interpretation. If the published nulls were all true and the filter were the only selection, the published -values would be flat across . If instead some effects were real, their -values would concentrate near — under a real effect the distribution of piles up at the low end — and the published histogram would be heavier below than just below . Neither honest scenario produces an excess just under the threshold. A pile-up in relative to is therefore the signature of results that were nudged across the line: choosing among analyses, subgroups, or stopping times until dipped below , which the printed -value does not record.
- 12.Computation
Use , and .
- (a)A study runs independent tests, each at level , and every null is true. Show that the number of false rejections is Binomial, and find and for , . Then find the smallest for which at .
- (b)Prove that testing each hypothesis at level keeps the probability of at least one false rejection at most under any dependence between the tests. Then, for independent tests with all nulls true, write the exact family-wise error rate under this correction and prove from Bernoulli's inequality (valid for ) that it is at most — so the correction is conservative even in the independent case.
- (c)In a field, a fraction of tested hypotheses are genuinely non-null, and tests have level and power . Show that a rejected null is more likely true than false — that is, — exactly when . With , find the power required at and at , and draw the conclusion.
Solution
(a) Let be the event that test falsely rejects, and its indicator. Since every null is true, , so each is Bernoulli; the tests are independent, so the are independent; and is a sum of independent Bernoulli variables, which is Binomial.
For , : — on average one false finding per study of pure noise — and
which is the family-wise error rate under multiplicity.
Smallest with : we need . Taking logarithms (which reverses the inequality, since ),
so . Check: and , so while ✓. Fourteen honest tests on noise are more likely than not to yield a “finding”.
(b) Bonferroni under arbitrary dependence. With each test at level , for every true null. By the union bound — subadditivity of probability, which needs no independence —
The independent case. By (a) with in place of , the number of false rejections is Binomial and the exact family-wise error rate is
Bernoulli's inequality with gives , hence
(For completeness, Bernoulli's inequality by induction: it is an equality at , and if then, multiplying by , .)
The inequality is strict for and , so even independent tests do not use the whole budget: at , the true rate is . The shortfall is small here — of order — but it grows when the tests are positively correlated, where the union bound is far from tight and the correction costs power for a guarantee that was already met.
(c) By the post-test probability theorem,
This is at least exactly when the numerator is at least half the denominator, i.e. , i.e.
and every step reverses, since the denominator is positive. In words: the rate of true positives must at least match the rate of false positives.
With : the false-positive rate is .
At : , so the power must be at least .
At : , so the power must be at least .
Conclusion. In a field that tests long shots — one hypothesis in twenty being real — a significant result at the conventional level is more likely false than true unless the study has power, which almost no study has; and even at perfect power the post-test probability is only . Power cannot rescue such a literature, because the false positives come from the large pool of true nulls, not from the small pool of real effects. Lowering tenfold shrinks that pool's contribution tenfold, and then even a modest power makes a rejection more likely right than wrong. The -value's meaning depends on two things it does not contain: how plausible the hypothesis was before the data, and how powerful the test was.