Print this page and work through it on paper. Revealed answers are never printed, so you can check one question and still print a clean sheet.

  1. Show the solution to question 1

    (a) Both gaps at every jump. The empirical distribution function is a staircase that equals just before and just after it. Since is continuous, the largest vertical distance between the two functions occurs at one of these eight values.

    The “after” gaps are

    The “before” gaps are

    The largest of the eight is , so , attained just after the fourth observation: the staircase has reached while is still at .

    (b) Move the last point. Only the two gaps at change. After the jump, ; before it, . The other six gaps are as in (a), the largest of them being (twice). So now

    attained just before the fourth observation. In (a) the maximum came from the after-side of the last jump; here it comes from the before-side of the same jump, and a computation that checked only the after-gaps would have reported instead of . The supremum of is always at a jump, but it can be on either side, so both must be checked at every observation.

    (c) Distribution-free. By the probability integral transform, if has continuous distribution function then is Uniform. Since is non-decreasing, the empirical distribution function of the transformed values , evaluated at , equals ; hence

    where is the empirical distribution function of four uniforms. Nothing about the particular survives the substitution, so the null distribution of is the same for every continuous — which is why a single table of critical values serves every goodness-of-fit problem of this type. Notice that the data in (a) were given to you already in the form : those four numbers are exactly the transformed sample .

  2. Show the solution to question 2

    (a) Expected counts. Under independence , so

    All four are below . The distribution for is asymptotic and needs expected counts of roughly or more; with the statistic takes only a handful of distinct values, and the continuous approximation cannot be trusted. Fisher's exact test is the right tool.

    (b) The possible tables. The row totals are and and the column totals are and . Since the improved column has total and each row has only patients, and , so . By the hypergeometric formula with , and ,

    The numerators are

    and , so the probabilities sum to . ✓ The observed table has probability .

    (c) The -values. “Treatment improves the outcome” means large . The observed is the largest possible value, so the only table at least as extreme is the observed one:

    For the two-sided test, the tables with probability at most are and (the mirror image, in which the control group does all the improving). So

    (d) The approximation, for comparison. With the observed counts and expected counts ,

    which is well beyond and corresponds to a -value near . The exact two-sided is — nearly five times larger. This is the small expected counts limitation: with a discrete, skewed statistic the approximation rejects too often, exactly as the rule of thumb warns. (The other limitation, arbitrariness of binning, does not arise because the data are genuinely categorical.) Note what not to do: there is nothing here to pool, and pooling would change the hypothesis anyway.

  3. Show the solution to question 3

    (a) Study I. Degrees of freedom , and , so independence is rejected at the level (the -value is far below ). For the strength, , so

    For a fixed pattern of association is proportional to , so at the statistic is , which is below : not significant. But

    exactly as before. The statistic measures evidence and tracks the sample size; measures strength and does not — and is a weak association whether or not is large enough to make it significant.

    (b) Study II. With and ,

    so McNemar's test rejects at the level.

    Exactly: under each changer is equally likely to change in either direction, so conditional on changers, . The one-sided tail is

    and doubling gives the two-sided — not significant at .

    The verdicts differ because is an asymptotic approximation to a statistic that, with only discordant pairs, takes very few values; the expected count of each kind of change is only , below the working threshold of . The exact binomial calculation is the one to trust. The chi-square version is the same statistic with a continuous distribution stretched over nine possible outcomes, and it rejects too readily, as approximations to discrete counts do.

    (c) Why the concordant pairs drop out. The question is whether the marginal proportion of yes answers moved. A subject who answered the same way twice contributes one yes (or one no) to both margins and therefore cannot move the difference between them, whichever way the campaign worked. Under the null the only random quantity is the direction of each change, and that is what the test conditions on — the same logic as pairing in the paired -test, where within-pair differences discard between-subject variation.

    A chi-square test of independence on the before-by-after table would ask a different question: whether a person's before answer is associated with their after answer. With of unchanged it would reject overwhelmingly, reporting only that people tend to agree with themselves — which says nothing about whether the campaign shifted opinion.

  4. Show the solution to question 4

    (a) Sign test. Seven differences are positive and one is negative, no ties. Under the number of positives is , which needs only that each difference is positive with probability — no symmetry, no shape. Then

    so the two-sided -value is . Not significant at the level.

    (b) Signed-rank test. Order the absolute differences and rank them:

    The only negative difference is , with rank , so and, since the ranks sum to ,

    By the null moments of the signed-rank statistic with ,

    So . Since , the standard deviation lies between and , hence

    and every value in that range exceeds . Reject at the level; , two-sided .

    (c) Exact . Under the null (differences symmetric about ) each of the sign patterns is equally likely. means , which happens for exactly two patterns: no negatives () or the rank- difference alone negative (). So

    in close agreement with the normal approximation.

    The two tests disagree because the sign test sees only that of differences are positive, and with that pattern is simply not rare enough (). The signed-rank test also sees that the one negative difference is the smallest in magnitude while the positives include all the large ones. That extra information is what pushes the evidence past the line — and it is bought with the extra assumption of symmetry, which the sign test does not need.

  5. Show the solution to question 5

    (a) The moments. Rank the absolute differences from to and let if the difference holding absolute rank is positive, otherwise. Then , the sum of the ranks of the positive differences, is .

    Under symmetry about zero, each difference is equally likely to be positive or negative, and its sign is independent of its magnitude: symmetry says the conditional distribution of the sign given is still a fair coin. Hence the signs are independent of the ranking, and the are independent Bernoulli variables. This is the step that needs symmetry. Under a skewed null with median zero the signs are still fair coins, but they are no longer independent of the magnitudes — large would be more often positive, say — so the attached to large ranks would not be Bernoulli, and neither formula would hold.

    By linearity,

    By independence the variance of the sum is the sum of the variances, and , so

    Linearity did not need independence; the variance step did.

    (b) Symmetry of the null distribution. The ranks of the negative differences are those with , so

    Under the null the vector consists of independent fair coins, and so does : the two vectors have the same joint distribution, namely uniform over the sign patterns. Since is the function of the first vector and is the same function of the second, and have the same distribution. Therefore, for any ,

    The null distribution is symmetric about , which is why one tail of a table suffices.

    (c) The floor. With the ranks sum to and there are equally likely sign patterns. The most extreme value arises from exactly one pattern (all positive), so the smallest one-sided -value is . By (b) the lower tail has the same probability, so the smallest two-sided -value is , which exceeds : no two-sided signed-rank test on five pairs can reject at the level, whatever the data.

    In general the smallest two-sided is , and requires , that is : with six pairs the extreme pattern gives . (One-sided, suffices, so is enough.) A rank test cannot be more decisive than the number of sign patterns allows, and with tiny samples that ceiling binds before any question about power arises.

  6. Show the solution to question 6

    (a) The identity. Let the first-sample observations in increasing order have combined ranks . The -th smallest first-sample value has first-sample values below it, so the remaining observations below it all belong to the second sample: is the number of it exceeds. Summing over ,

    Its range is to , and alone ranges from upward, which is exactly why the offset matters.

    (b) Three errors.

    Step 1 confuses with . By the definition of the Mann-Whitney statistic, , not . The null moments and are moments of ; feeding them compares a statistic with the wrong centre. (Note that is only above its minimum of : the first sample holds nearly all the lowest ranks, which is the opposite of “no evidence”.)

    Step 3 turns non-rejection into acceptance. Failing to reject means the data are compatible with ; it never establishes it. With and the test has modest power, so a non-significant result would be weak evidence of anything.

    Step 3 also misstates the hypothesis. The Mann-Whitney null is that the two distributions are identical, and the alternative is a stochastic ordering, . A conclusion about medians is valid only under the extra assumption that the two distributions differ by a pure shift and are otherwise the same shape — an assumption the student never stated.

    (c) The correct test. With ,

    Compare squares: if and only if . The left side is . On the right, and , so the right side is below . Since , comfortably; in fact gives , so and the two-sided is about .

    Reject at the level. The justified conclusion: the two samples are unlikely to come from the same distribution, and the direction is that first-sample values tend to be smaller — only of the pairs have the first-sample value on top. Any statement about medians requires adding, and stating, the shift assumption.

  7. Show the solution to question 7

    (a) Spearman. With and , the rank differences are

    There are no ties, so the computing formula applies with :

    (b) Kendall. Listing the second-exam ranks in first-exam order, , a pair with is concordant when the second rank increases too. The pairs:

    So , and

    As usual for the same data; here exactly, the rough rule of thumb landing on the nose. The interpretation of is direct: a randomly chosen pair of students is ordered the same way by both exams with probability and the opposite way with probability , and is the difference.

    (c) Correcting the error. With the true score the second-exam values are . Since is still the largest, student still has rank and every other rank is unchanged: the rank vector is exactly as before. Every is unchanged, so still; every pair is concordant or discordant exactly as before, so still. A rank depends only on order, and correcting to preserves the order of the five scores. The same is true of any strictly increasing transformation of the scores — squaring them, taking logarithms — which is why rank correlation detects any monotone relationship and not merely a linear one.

    Pearson's is built from products of deviations, , and with that single term dominates while dominates . In the limit of an ever larger , tends to the correlation between and the indicator of student : the -deviations are , the indicator's deviations from its mean are , the cross-products sum to , and with and the limit is . So is being reported by one observation, and correcting that observation to moves appreciably, while a second error putting it at would move it again. The rank statistics bound the influence of any one observation — the erroneous score can never contribute more than a rank difference of — and that robustness is a different property from being assumption-free.

  8. Show the solution to question 8

    (a) The sum of squared deviations of . Expand the square and use the two quoted sums:

    The last two terms combine to . Factor out and put everything over :

    (b) The computing formula. Because there are no ties, each rank vector is a permutation of . So both have the same mean and, by (a), the same sum of squared deviations,

    (With ties, averaged ranks would spoil both of these — the means would still agree but the sums of squares would be smaller, and the formula would need a correction.)

    Now write , which is legitimate because the two means are equal, and expand:

    Hence , and Pearson's correlation of the ranks is

    (c) Reversed rankings. If then

    so, since the are a permutation of , part (a) gives

    and the computing formula returns .

    For the bound: is a Pearson correlation, so by the Cauchy–Schwarz inequality for any two rankings. Substituting the computing formula, rearranges to , with equality exactly when — which the reversed ranking attains. (Equivalently: reversing the order minimises , the rearrangement inequality in rank form.)

    Check, . The bound is . Reversing to gives and , so . ✓ The other five permutations give , all below , so the bound is attained only by the reversal. ✓

  9. Show the solution to question 9

    (a) Reduce to the group sum. The pooled total is . If the first group's two values sum to , the second group's three values sum to , so

    This is a strictly decreasing function of , so “ at least as large as observed” is exactly “ at least as small as observed”, and the two tests have identical -values. Tabulating is better because it takes integer values, and because the argument shows that any statistic that is a monotone function of the first group's sum — a difference of totals, of means, a -statistic with pooled variance — yields the same test.

    (b) The ten relabellings. Choosing which two of go to the first group:

    The observed labelling is , so , the smallest value in the list. The ten values sum to , so their average is ; the pooled mean is and . ✓ (Under exchangeability each of the two first-group slots holds a randomly chosen pooled value, so pooled mean.)

    The chart. Horizontal axis from to with integer ticks; vertical axis “number of relabellings” from to . Draw a bar of height at each of and a bar of height at : nine bars, total height . Mark the bar at as the observed value — it stands alone at the far left. The rejection region defined by the data is , which is just that one bar, so shade it. Draw a vertical dashed line at ; it falls between the bars at and .

    (c) Reading off. Exactly one of the ten equally likely relabellings has , so

    This is also the smallest -value the design can produce: with and nothing can reach , however cleanly the groups separate.

    For the two-sided rule, the observed distance is , so a relabelling counts if or . From the chart that is and , two of ten: .

    Why no symmetry. In the chapter's equal-sizes example every relabelling has a mirror image obtained by swapping the two groups, which negates , so the null distribution is symmetric about . Here the groups have sizes and , and swapping them is not a relabelling of the same design, so nothing forces symmetry. The chart shows it: the bars to the left of sit at distances while those to the right sit at , and the value stretches the right tail. Exactness does not need symmetry — the proof that the permutation test has the stated level uses only that the ten relabellings are equally likely — but reading a two-sided -value from an asymmetric distribution does require saying which rule is being used.

  10. Show the solution to question 10

    (a) Argument A: Step 2 is the fatal one. Step 1 is correct, and Step 3 is only wrong as a consequence of Step 2.

    The resample maximum is at most the observed maximum, because a resample contains only observed values. It equals unless all five draws miss the largest observation, and each draw misses it with probability independently, so

    So the bootstrap distribution of the maximum puts about two-thirds of its mass on the single point and the rest at , , or — a distribution that lives entirely at or below the estimate. Its quantile is therefore itself (indeed every quantile above the point is ), so the percentile interval has the form .

    That is fatal because with certainty — the population cannot produce a value larger than — and with probability one. An interval whose upper endpoint is contains with probability zero, not . The bootstrap fails here because the statistic depends on an extreme order statistic, and the empirical distribution is a poor stand-in for the population exactly at its boundary. (As grows the defect does not go away: .)

    Correction. The sampling distribution of the maximum is not awkward at all: for a Uniform sample of size , for . Use that exact distribution to build the interval, as the estimation of for the uniform is done in closed form; the bootstrap is the wrong tool for a boundary parameter. Step 3's claim of “no assumption” is also empty: the argument already assumed a uniform population to justify the maximum in Step 1.

    (b) Argument B: Step 2 is the fatal one. Step 1 is a fair observation, and Step 3 merely acts on Step 2.

    The null hypothesis of the Wilcoxon signed-rank test is that the differences are symmetric about zero, not merely that their median is zero. The null distribution of — , , and the uniform distribution over the sign patterns — is derived by writing with the signs independent fair coins independent of the magnitudes. Symmetry is what delivers that independence.

    On these data the assumption is visibly false. Ranking the absolute values gives ; the two negatives hold ranks and , so and , against a null mean of and null standard deviation — about standard deviations up, a “significant” result. But look at where the evidence comes from: the three largest magnitudes, , carry ranks and contribute of the on their own, while the small differences are split almost evenly in sign. Under a right-skewed population with median zero that pattern is typical, not evidence: the long right tail supplies large magnitudes far more often than the short left tail does, so the signs attached to the largest ranks are not fair coins, exceeds under the null, and the test rejects a true null far more often than . The user would be “detecting” a shift whose existence the test had assumed away.

    Correction. With skewed differences, use the sign test: positives out of , and under the null that the median difference is zero , with no further assumption — that null needs only . Then , two-sided about : not significant, which is the honest reading of eight positives in ten.

    “Distribution-free” promises only that the null distribution of the statistic can be computed without knowing the population — for the sign test under any continuous distribution with median zero, for the signed-rank test under any distribution symmetric about zero. It does not mean assumption-free, and the assumption a rank test does make is exactly what fixes which null distribution one is entitled to use.

  11. Show the solution to question 11

    (a) Exactness. Under the null the pooled observations are independent draws from one distribution, so their joint distribution is unchanged by any permutation of the labels: the observations are exchangeable. This is the only place the null hypothesis enters. Condition on the multiset of pooled values. Given that multiset, each of the ways of choosing which values carry the first label has the same conditional probability , so the observed labelling is a uniform draw from the relabellings, and is a uniform draw from the distinct values that takes.

    If , the -th largest value, then exactly relabellings have and . Hence is uniform on , and

    This is the conditional probability given the multiset; since it does not depend on the multiset, it is the unconditional probability too. Equality holds precisely when is an integer.

    So “exact” means: the rejection probability under the null is known exactly, for every sample size, with no approximation — it is , and it equals whenever is one of the attainable levels . It does not mean that every is attainable, and it says nothing about power. Nothing about the form of was used, which is why any statistic may be permuted.

    (b) The floor. The smallest occurs when is the largest of the values, giving ; no relabelling can have smaller, since the observed one always counts. For , runs for

    One-sided at requires , i.e. : gives and fails, gives and succeeds, with exactly. So is the smallest, and only the single most extreme relabelling rejects.

    Two-sided with doubled requires , i.e. : fails and gives , . So is the smallest.

    (c) The example. The pooled values are and . Since where is the first group's sum, is largest when is smallest, and the observed labelling has the smallest possible sum . It is the unique relabelling with , so , exactly the floor from (b).

    Replacing values by ranks. The values are their own ranks, so nothing changes and . More generally, replacing observations by ranks is a strictly increasing transformation, and under it the ordering of relabellings by any statistic that is monotone in the group sum is preserved whenever, as here, the observed group holds the smallest values — that relabelling is the unique extreme one before and after ranking.

    Replacing by . With the rank sum of the second sample, , which equals , the maximum possible: every exceeds every . Across relabellings is a strictly increasing function of the second group's rank sum, hence a strictly decreasing function of , so it orders the relabellings exactly as does, and again exactly one relabelling is at least as extreme: .

    The lesson. The Mann-Whitney test is a permutation test — the permutation test whose statistic is the rank sum, applied to the ranks. Its tabulated null distribution is precisely the permutation distribution of over the relabellings, which is why it is the same for every continuous population: ranking has already removed the data's values, so the enumeration can be done once. A permutation test on the raw values keeps the magnitudes and can use any statistic, at the price of redoing the enumeration for each data set. Both are exact for the same reason, exchangeability under the null; they differ in what they throw away, and hence in power against particular alternatives.

  12. Show the solution to question 12

    (a) Counting. Each of the three positions takes one of three values, so there are equally likely ordered resamples. Ignoring order, a resample is a multiset of size from types, of which there are — but these are not equally likely. A resample contains all three distinct values in of the orderings, so the probability is ; the other of resamples repeat at least one observation, which is what makes sampling with replacement produce any variation at all.

    (b) The median. The resample median is the middle value of the three draws.

    The median is exactly when at least two of the three draws are : two of them, , or all three, . So , and by the same count .

    The median is in the remaining cases — at least two s ( again) or all three values distinct (, from (a)), which are disjoint — giving .

    Check: . ✓

    (c) Moments of the bootstrap median. Writing for the resample median,

    Hence

    and the bootstrap standard error of the median is

    Note that the bootstrap mean is above the observed median : the resampling distribution has inherited the right skew of the data, since a resample that picks up the twice moves the median much further than one that picks up the twice.

    (d) The percentile interval. The bootstrap distribution has only three atoms. Its cumulative probabilities are and . The quantile is the smallest value with cumulative probability at least , which is ; the quantile is the smallest value with cumulative probability at least , which is . The percentile interval is — the entire range of the data. Indeed every percentile interval wider than the middle is : the distribution is far too coarse to yield anything else. The bootstrap has not manufactured information three observations do not contain; a resample median is always one of the observed values, so with tiny the bootstrap distribution of the median is a handful of points and its quantiles are crude.

    The mean, without enumeration. A resample mean is the average of three independent draws from the empirical distribution, which puts mass on each of . That distribution has mean and variance

    so the variance of the average of three independent draws is and

    This is just with the divisor- standard deviation — the bootstrap reproduces the textbook formula because the mean is linear in the data. The mean behaves better as a bootstrap target because it varies continuously with the resample: the resamples give many distinct means spread smoothly over the range, whereas the median jumps between three values. The same reasoning is why a trimmed mean bootstraps more smoothly than a median at small .

Full solutions sheet →