2.8 Practice Problems
Problem 2.1. A traffic warden records how long sixteen cars remained illegally parked after their meter expired, in minutes: \[10,\ 42,\ 29,\ 11,\ 63,\ 145,\ 11,\ 8,\ 23,\ 17,\ 5,\ 20,\ 15,\ 36,\ 32,\ 15 .\] Obtain an appropriate \(95\%\) confidence interval for the median overstay time, and state what assumptions justify the method used.
Show solution
Solution. Order the data: \[5,\ 8,\ 10,\ \mathbf {11},\ 11,\ 15,\ 15,\ 17,\ 20,\ 23,\ 29,\ 32,\ \mathbf {36},\ 42,\ 63,\ 145 .\] A distribution-free interval for the median is \(\left (X_{(k)},\ X_{(n+1-k)}\right )\), whose coverage is \[1 - 2\,P\!\left (\text {Bin}\!\left (n,\tfrac 12\right ) \leq k-1\right ).\] With \(n = 16\): \[\begin {array}{c|c|c} k & \text {interval} & \text {coverage}\\\hline 3 & (10,\ 42) & 0.9958\\ 4 & (11,\ 36) & 0.9787\\ 5 & (11,\ 32) & 0.9232 \end {array}\] Take the largest \(k\) whose coverage still reaches \(95\%\), namely \(k = 4\): \[\boxed {\left (X_{(4)},\ X_{(13)}\right ) = (11,\ 36) \text { minutes, with actual confidence } 97.87\% .}\]
Assumptions. Only that the sixteen observations are independent and come from a continuous distribution. Nothing is assumed about its shape — which is the point, since the value \(145\) is a severe outlier and would wreck any interval built on the mean and standard deviation.
Note on the confidence level. The attainable levels are discrete, so \(95\%\) cannot be hit exactly; one reports the interval and its true coverage rather than pretending it is \(95\%\). The next interval down, \((11,32)\), covers only \(92.3\%\) and is not a \(95\%\) interval at all.
Problem 2.2. Eleven people with sleep problems have a median sleeping time of \(2\) hours per night before treatment. A drug is administered; if it has any effect it will increase sleeping time, though some doctors doubt it does anything. After treatment the hours slept are \[3.1,\ 1.8,\ 2.7,\ 2.4,\ 2.9,\ 0.2,\ 3.7,\ 5.1,\ 8,\ 2.1,\ 2 .\] Are the doctors’ doubts justified?
Show solution
Solution. Hypotheses. \(H_0 : \theta = 2\) against the one-sided \(H_1 : \theta > 2\), the direction fixed in advance by the pharmacology and not by the data.
Signs. Comparing each value with \(2\): \[+,\ -,\ +,\ +,\ +,\ -,\ +,\ +,\ +,\ +,\ 0 .\] The observation of exactly \(2\) gives no sign and is discarded, leaving \[n' = 10,\qquad N_{+} = 8,\qquad N_{-} = 2 .\]
Exact test. Under \(H_0\), \(N_{+} \sim B\!\left (10,\tfrac 12\right )\), so \[P\left (N_{+} \geq 8\right ) = \dfrac {\binom {10}{8}+\binom {10}{9}+\binom {10}{10}}{2^{10}} = \dfrac {45+10+1}{1024} = \dfrac {56}{1024} = 0.0547 .\]
Decision. Since \(0.0547 > 0.05\) we do not reject \(H_0\) at the \(5\%\) level. On this evidence the doctors’ doubts are not overturned.
But only just. Eight of ten moving the right way is suggestive, and the \(P\)-value misses the conventional threshold by \(0.0047\). The honest report is the \(P\)-value itself, not a verdict: a trial of even modest additional size would settle the question, and dismissing the drug on this result would be as wrong as adopting it.
Problem 2.3. A realtor claims the median sale price of houses sold in a certain month is \(\$134{,}500\). In a random sample of \(85\) sales, \(30\) houses sold for less than that figure and \(51\) for more. Test the claim at the \(10\%\) significance level.
Show solution
Solution. The sample size is not \(85\). Only \(30 + 51 = 81\) houses are recorded above or below the claimed median, so \(4\) sold at exactly \(\$134{,}500\). Those give no sign and are discarded: \[n' = 81,\qquad N_{-} = 30,\qquad N_{+} = 51 .\]
Hypotheses. \(H_0 : \theta = 134{,}500\) against \(H_1 : \theta \neq 134{,}500\), two-sided, at \(\alpha = 0.10\).
Large-sample statistic. With \(R = \min (N_{+},N_{-}) = 30\), \[Z = \dfrac {n' - 2R - 1}{\sqrt {n'}} = \dfrac {81 - 60 - 1}{\sqrt {81}} = \dfrac {20}{9} = 2.2222 ,\] giving a two-sided \(P\)-value of \[2\left [1 - \Phi (2.2222)\right ] = 0.0263 .\] (The exact binomial two-sided value is \(0.0257\), so the approximation is good at this size.)
Decision. Since \(0.0263 < 0.10\) we reject \(H_0\): the data do not support the realtor’s claim, and the evidence points to a median above \(\$134{,}500\).
The trap. Using \(n = 85\) instead of \(n' = 81\) gives \(Z = 2.6032\) — a different and wrong answer. Ties with the hypothesised median must be removed and the sample size reduced to match; keeping \(85\) in the denominator while having dropped the four observations from the counts is inconsistent.
Problem 2.4. On average about \(90\%\) of the prospective guests at a hotel arrive on a given night. The hotel has \(200\) rooms and \(215\) reservations have been accepted for one night.
- (a).
- The number \(X\) of guests arriving is assumed binomial with \(n = 215\) and \(\pi = 0.9\). Find the mean and variance of \(X\), and state the assumption needed for the arrivals to be binomial.
- (b).
- Using the normal approximation to the binomial, find the probability that all guests can be accommodated.
Show solution
Solution. (a). \(E(X) = n\pi = 215(0.9) = 193.5\) and \(\operatorname {var}(X) = n\pi (1-\pi ) = 215(0.9)(0.1) = 19.35\), so the standard deviation is \(4.399\). For \(X\) to be binomial, the guests must arrive independently of one another, each with the same probability \(0.9\). A party of several guests on one booking, who arrive or fail to arrive together, breaks the independence.
(b). All guests are accommodated when \(X\leq 200\). With the continuity correction, \[P(X\leq 200)\approx P\left (Z\leq \frac {200.5-193.5}{4.399}\right ) = P(Z\leq 1.59) = 0.9441.\] The exact binomial probability is \(0.9504\). Overbooking by \(15\) rooms therefore leaves the hotel about a \(5\%\) risk of turning someone away on a given night.
Problem 2.5. Records show that one in every fifty male adults develops a serious respiratory illness.
- (a).
- In a random sample of \(400\) male adults, find the mean and standard deviation of the number who will suffer from the illness.
- (b).
- A random sample of \(400\) workers in a certain occupation shows \(15\) with the illness. Using the normal approximation to the binomial, find the probability that \(15\) or more in a sample of \(400\) will suffer from the illness. What do you conclude?
Show solution
Solution. (a). \(X\sim B(400, 0.02)\), so \(E(X) = 400(0.02) = 8\) and \(\sigma = \sqrt {400(0.02)(0.98)} = \sqrt {7.84} = 2.8\).
(b). With the continuity correction, \begin {align*} P(X\geq 15)&\approx P\left (Z\geq \frac {14.5-8}{2.8}\right ) = P(Z\geq 2.32)\\ &= 1-0.9898 = 0.0102. \end {align*}
If these workers had the same risk as the general population, a count as high as \(15\) would occur only about once in a hundred samples. That is strong evidence that the illness is more common in this occupation, and it is a reason to investigate the working conditions. (The exact binomial tail is \(0.016\); the normal approximation is rough here because \(n\pi = 8\) is small, but the conclusion stands.)
Problem 2.6. Under simple Mendelian inheritance, a cross between plants of two particular genotypes may be expected to produce progeny one quarter of which are “dwarf” and three quarters “tall”. In an experiment, a cross results in \(243\) dwarf plants and \(682\) tall plants. Let “class 1” denote tall, so that \(p^{*} = \frac 34\), and let \(T\) be the number of tall plants.
- (a).
- Are the null and alternative hypotheses simple or composite?
- (b).
- Test at \(\alpha = 0.05\) whether simple Mendelian inheritance applies.
Show solution
Solution. (a). \(H_0: p = \frac 34\) is simple: it specifies the distribution of \(T\) completely, as \(B\left (925, \frac 34\right )\). \(H_1: p\neq \frac 34\) is composite: it contains infinitely many values of \(p\).
(b). This is the binomial test. With \(n = 925\), under \(H_0\), \[E(T) = 925(0.75) = 693.75,\qquad \sigma _T = \sqrt {925(0.75)(0.25)} = 13.17.\] The observed \(T = 682\), a proportion \(\frac {682}{925} = 0.737\) tall, is below expectation, so with the continuity correction \[z = \frac {682.5-693.75}{13.17} = -0.85,\] \[p\text {-value} = 2\,\Phi (-0.85) = 2(0.1977)\approx 0.39.\] Since \(0.39 > 0.05\), \(H_0\) is not rejected: a proportion of \(73.7\%\) tall is well within the chance variation expected from a \(75\%\) model, and the data are consistent with simple Mendelian inheritance. (The exact binomial \(p\)-value is also \(0.39\).)
Problem 2.7. Sixteen transistors are selected at random from a large batch and tested. The numbers of hours until failure, arranged in increasing order, are \begin {gather*} 46.9,\ 47.2,\ 49.1,\ 56.5,\ 56.8,\ 59.2,\ 59.9,\ 63.2,\\ 63.3,\ 63.4,\ 63.7,\ 64.1,\ 67.1,\ 67.7,\ 73.3,\ 78.5. \end {gather*} Find a confidence interval for the upper quartile, with confidence coefficient close to \(90\%\).
Show solution
Solution. The interval for the median generalises to any quantile, as the quartile test does. Let \(x_{0.75}\) be the upper quartile and let \(Y\) be the number of observations below it. Each observation falls below \(x_{0.75}\) with probability \(0.75\), so \(Y\sim B(16, 0.75)\), and the interval \(\left (X_{(r)}, X_{(s)}\right )\) covers \(x_{0.75}\) exactly when \(r\leq Y\leq s-1\). Hence \[P\left (X_{(r)} < x_{0.75} < X_{(s)}\right ) = P(Y\leq s-1)-P(Y\leq r-1).\] For about \(90\%\) we want each tail near \(0.05\). From the cumulative probabilities of \(B(16, 0.75)\), \[\begin {array}{c|cccccc} y & 8 & 9 & 10 & \cdots & 14 & 15\\\hline P(Y\leq y) & 0.0271 & 0.0796 & 0.1897 & \cdots & 0.9365 & 0.9900 \end {array}\] the values closest to \(0.05\) and \(0.95\) are \(P(Y\leq 8) = 0.0271\) and \(P(Y\leq 14) = 0.9365\). So \(r-1 = 8\) and \(s-1 = 14\), giving \(r = 9\) and \(s = 15\). The interval is \[\left (X_{(9)},\ X_{(15)}\right ) = (63.3,\ 73.3),\qquad \text {confidence } 0.9365-0.0271 = 0.9094.\] We are \(90.9\%\) confident that three quarters of the batch fail before somewhere between \(63.3\) and \(73.3\) hours. The interval is not centred on \(X_{(12)}\), the natural point estimate, because the binomial with \(p = 0.75\) is not symmetric.
Problem 2.8. The following are the IQs of drug abusers who were arrested aged 16 years or older: \[99,\ 100,\ 90,\ 94,\ 135,\ 108,\ 107,\ 111,\ 119,\ 104,\ 127,\ 109,\ 117,\ 105,\ 125.\] Is there evidence that the median IQ of drug abusers in the population is greater than \(107\)? Use the sign test with \(\alpha = 0.05\).
Show solution
Solution. Test \(H_0: M = 107\) against \(H_1: M > 107\). One observation equals \(107\) and is discarded, leaving \(n' = 14\). Of these, \(N_{+} = 8\) lie above \(107\) (\(135, 108, 111, 119, 127, 109, 117, 125\)) and \(N_{-} = 6\) below. Under \(H_0\), \(N_{+}\sim B\left (14, \frac 12\right )\), and large \(N_{+}\) supports \(H_1\), so \[p\text {-value} = P(N_{+}\geq 8) = \frac {1}{2^{14}}\sum _{j=8}^{14}\binom {14}{j} = \frac {6476}{16384} = 0.3953.\] Since \(0.3953 > 0.05\) we do not reject \(H_0\). Eight of fourteen above the hypothesised median is close to the seven expected by chance, and there is no evidence that the median IQ exceeds \(107\). The signed-rank test of the next section uses the same data more fully.
Problem 2.9. Suppose the median house price in an upmarket suburb is K2 million. Over the last two weeks an estate agent sold \(5\) houses there at the following prices, in millions of Kwacha: \[2.15,\quad 1.13,\quad 2.25,\quad 2.50,\quad 2.30.\]
- (a).
- Treating these as a random sample, test whether the median price has been exceeded.
- (b).
- Why is a \(t\)-test for the population mean not appropriate here?
Show solution
Solution. (a). Test \(H_0: M = 2\) against \(H_1: M > 2\). Four of the five prices exceed \(2\), so \(N_{+} = 4\), and under \(H_0\), \(N_{+}\sim B\left (5,\frac 12\right )\): \[p\text {-value} = P(N_{+}\geq 4) = \frac {\binom 54+\binom 55}{2^{5}} = \frac {6}{32} = 0.1875.\] Since \(0.1875 > 0.05\), \(H_0\) is not rejected: there is no evidence that the median has been exceeded. With only five houses this is almost inevitable. Even if all five had sold above K2 million, the \(p\)-value would be \(\frac {1}{32} = 0.031\), so only that one outcome could lead to rejection at the \(5\%\) level.
(b). The \(t\)-test assumes the prices come from a normal population. Five observations are far too few to check that, house prices are typically skewed to the right, and the sample contains an outlying \(1.13\) which would pull the mean down and inflate the standard deviation. The question is also about the median, the usual summary of house prices precisely because of that skewness, and the sign test addresses it directly with no assumption about shape.
Problem 2.10. Before a televised debate between two presidential candidates, a random sample of \(100\) people stated their choice: \(84\) favoured the Democratic candidate and \(16\) the Republican. After the debate the same \(100\) people were asked again. A quarter of those who had favoured the Democrat changed their minds, and a quarter of those who had favoured the Republican switched to the Democrat:
| After: Democrat | After: Republican | |
| Before: Democrat | \(a = 63\) | \(b = 21\) |
| Before: Republican | \(c = 4\) | \(d = 12\) |
Use McNemar’s test to decide, at the \(0.05\) level, whether the debate produced a significant change in voting alignment.
Show solution
Solution. The same people are asked twice, so the two proportions are paired and a two-sample comparison would be wrong. McNemar’s test (Section 2.7) handles pairing as the sign test does: the \(a+d = 75\) people who did not change carry no information about the direction of change and are set aside. Each of the \(b+c = 25\) who changed is a “plus” (Democrat to Republican) or a “minus” (Republican to Democrat), and under \(H_0\) (no change in overall alignment) each switch is equally likely to go either way: \[H_0:\ P(\text {D}\to \text {R}) = P(\text {R}\to \text {D}),\qquad b\sim B\left (b+c,\tfrac 12\right ).\] The usual form of the statistic is \[T = \frac {(b-c)^{2}}{b+c} = \frac {(21-4)^{2}}{25} = \frac {289}{25} = 11.56,\] referred to \(\chi ^{2}_{1}\). Since \(11.56 > \chi ^{2}_{0.05,1} = 3.841\), \(H_0\) is rejected. (With the continuity correction, \((|b-c|-1)^{2}/(b+c) = 10.24\); the exact binomial \(p\)-value is \(2P\left (B(25,\frac 12)\leq 4\right ) = 0.0009\). Every version gives the same decision.)
The debate changed the alignment significantly. Of the \(25\) people who switched, \(21\) moved away from the Democrat. The Democrat still leads after the debate, by \(67\) to \(33\) against \(84\) to \(16\) before, but the movement was overwhelmingly one way. The statistic \(T\) is the square of the large-sample sign-test statistic \(\frac {b-c}{\sqrt {b+c}}\), which is why McNemar’s test belongs with the binomial tests.
Questions on this section
Stuck on something here? Ask below and it stays attached to this topic.