Homework 7

Table of Contents

Problem 1

It is claimed that the median weight mm of certain loads of candy is 4000040000 pounds.

  1. Use the following 1313 observations and the Wilcoxon signed rank statistic to test the null hypothesis H0 ⁣:m=40000H_0\colon m = 40000 against the one-sided alternative hypothesis H1 ⁣:m<40000H_1\colon m < 40000 at an approximate significance level of α=0.05\alpha = 0.05.

    41195394853805040890392453103130906412293684038345349304078038050\begin{array}{rrrrrrr} 41195 & 39485 & 38050 & 40890 & 39245 & 31031 & 30906 \\ 41229 & 36840 & 38345 & 34930 & 40780 & 38050 & \end{array}
  2. Use the sign test to test the same hypotheses.

Solution.
  1. Recall that the Wilcoxon signed rank statistic is

    W=i=1nsign(xim)Rank(xim)W = \sum_{i=1}^n \operatorname{sign}\p{x_i - m} \operatorname{Rank}\p{\abs{x_i - m}}

    and we use it with

    Z=Wn(n+1)(2n+1)/6N(0,1).Z = \frac{W}{\sqrt{n\p{n+1}\p{2n+1}/6}} \approx \mathcal{N}\p{0, 1}.

    For a one-sided test, we reject if z<z0.05=1.645z < -z_{0.05} = -1.645. Computing the signs and ranks gives the following table:

    xi41195394853805040890392453103130906412293684038345349304078038050xim119551519508907558969909412293160165550707801950sign(xi)Rank(xim)51842121361071139\begin{array}{r|rrrrrrrrrrrrr} x_i & 41195 & 39485 & 38050 & 40890 & 39245 & 31031 & 30906 & 41229 & 36840 & 38345 & 34930 & 40780 & 38050 \\ \abs{x_i - m} & 1195 & 515 & 1950 & 890 & 755 & 8969 & 9094 & 1229 & 3160 & 1655 & 5070 & 780 & 1950 \\ \operatorname{sign}\p{x_i} \operatorname{Rank}\p{\abs{x_i - m}} & 5 & -1 & -8 & 4 & -2 & -12 & -13 & 6 & -10 & -7 & -11 & 3 & -9 \end{array}

    Summing the last row, we get W=55W = -55, so

    z=55(131427)/6=1.9219z = \frac{-55}{\sqrt{\p{13 \cdot 14 \cdot 27} / 6}} = −1.9219

    Thus, we reject H0H_0 at α=0.05\alpha = 0.05.

  2. The sign test statistic is given by

    Y=(# i’s such that Xi<m)Bin(n,12).Y = \p{\#\ i \text{'s such that } X_i < m} \sim \operatorname{Bin}\p{n, \frac{1}{2}}.

    There are 99 of these, so our pp-value is

    p-value=P(Y9)=k=913(13k)1213=0.1334,p\text{-value} = \P\p{Y \geq 9} = \sum_{k=9}^{13} \binom{13}{k} \frac{1}{2^{13}} = 0.1334,

    so we fail to reject H0H_0 at α=0.05\alpha = 0.05.

Python Code

x = np.array([41195, 39485, 38050, 40890, 39245, 31031, 30906, 41229, 36840, 38345, 34930, 40780, 38050])
m = 40000
sign = np.sign(x - m)
rank = np.argsort(np.argsort(np.abs(x - m))) + 1
print(f"w = {np.sum(sign * rank)}") # w = -55
print(f"y = {np.sum(sign < 0)}")    # y = 9

Problem 2

Let XX equal the number of milliliters of a liquid in a bottle that has a label volume of 350 ml350~\mathrm{ml}. Assume that the distribution of XX is N(μ,4)\mathcal{N}\p{\mu, 4}. To test the null hypothesis H0 ⁣:μ=355H_0\colon \mu = 355 against the alternative hypothesis H1 ⁣:μ<355H_1\colon \mu < 355, let the critical region be defined by C={xx354.05}C = \set{\mean{x} \mid \mean{x} \leq 354.05}, where x\mean{x} is the sample mean of the contents of a random sample of n=12n = 12 bottles.

  1. Find the power function K(μ)K\p{\mu} for this test.

  2. What is the approximate significance level α\alpha of the test?

  3. Use the following 1212 observations to state your conclusion from this test:

    350353354356353352354355357353354355\begin{array}{rrrr} 350 & 353 & 354 & 356 \\ 353 & 352 & 354 & 355 \\ 357 & 353 & 354 & 355 \end{array}
Solution.
  1. Recall that

    K(μ)=P(reject H0|μ).K\p{\mu} = \P\p{\text{reject }H_0 \given \mu}.

    In this problem, we reject H0H_0 if and only if X\mean{X} lands in the critical region, so

    K(μ)=P(X354.05μ).K\p{\mu} = \P\p{\mean{X} \leq 354.05 \mid \mu}.

    To calculate this probability, we need to carefully figure out the distribution of X\mean{X}. Recall that

    Z=Xμσ/n=Xμ2/12N(0,1),Z = \frac{\mean{X} - \mu}{\sigma/\sqrt{n}} = \frac{\mean{X} - \mu}{2/\sqrt{12}} \sim \mathcal{N}\p{0, 1},

    so

    X354.05    Xμ2/12354.05μ2/12.\begin{aligned} \mean{X} \leq 354.05 &\iff \frac{\mean{X} - \mu}{2/\sqrt{12}} \leq \frac{354.05 - \mu}{2/\sqrt{12}}. \end{aligned}

    We get

    K(μ)=P(Xμ2/12354.05μ2/12|μ)=P(N(0,1)354.05μ2/12)=Φ(354.05μ2/12),\begin{aligned} K\p{\mu} &= \P\p{\frac{\mean{X} - \mu}{2/\sqrt{12}} \leq \frac{354.05 - \mu}{2/\sqrt{12}} \given \mu} \\ &= \P\p{\mathcal{N}\p{0, 1} \leq \frac{354.05 - \mu}{2/\sqrt{12}}} \\ &= \boxed{\Phi\p{\frac{354.05 - \mu}{2/\sqrt{12}}}}, \end{aligned}

    where Φ\Phi is the cdf of a standard normal random variable.

  2. We have

    α=P(reject H0|H0)=K(355)=Φ(354.053552/12)=Φ(1.6454)z0.05,\begin{aligned} \alpha &= \P\p{\text{reject }H_0 \given H_0} \\ &= K\p{355} \\ &= \Phi\p{\frac{354.05 - 355}{2/\sqrt{12}}} \\ &= \Phi\p{−1.6454} \\ &\approx -z_{0.05}, \end{aligned}

    so the significance level is roughly α=0.05\alpha = 0.05.

  3. Since the critical region is given to us, we do not use the pp-value to make our conclusion. We just check to see if xC\mean{x} \in C or not.

    x=353.8333354.05,\mean{x} = 353.8333 \leq 354.05,

    so we reject H0H_0.

Problem 3

In a political campaign, one candidate has a poll taken at random from the voting population. The results of poll are that 311311 out of 400400 voters favor the candidate. Let pp be the fraction of the voting population that favors the candidate.

  1. Test H0 ⁣:p=0.8H_0\colon p = 0.8 against H1 ⁣:p<0.8H_1\colon p < 0.8 at significance level α=0.05\alpha = 0.05.
  2. Test H0 ⁣:p=0.8H_0\colon p = 0.8 against H1 ⁣:p<0.8H_1\colon p < 0.8 at significance level α=0.01\alpha = 0.01.
  3. Compute the associated pp-value.
  4. What is the smallest significance level α\alpha for which we can reject H0 ⁣:p=0.8H_0\colon p = 0.8 in favor of H1 ⁣:p<0.8H_1\colon p < 0.8?
Solution.

Recall that for one proportion, we use the null hypothesis when computing the standard error:

Z=Xp0p0(1p0)nN(0,1).Z = \frac{\mean{X} - p_0}{\sqrt{\frac{p_0 \p{1 - p_0}}{n}}} \sim \mathcal{N}\p{0, 1}.

For our given data, we get

z=3114000.80.8(10.8)400=1.125.z = \frac{\frac{311}{400} - 0.8}{\sqrt{\frac{0.8 \p{1 - 0.8}}{400}}} = −1.125.
  1. The critical region is z<z0.05=1.645z < -z_{0.05} = -1.645, so we fail to reject H0H_0.

  2. The critical region is smaller than in part 1, so we still fail to reject H0H_0.

  3. The pp-value is (taking the average of Φ(1.12)\Phi\p{1.12} and Φ(1.13)\Phi\p{1.13} from the zz-table)

    p-value=P(Z1.125)=1P(Z1.125)=10.8697=0.1303.p\text{-value} = \P\p{Z \leq -1.125} = 1 - \P\p{Z \leq 1.125} = 1 - 0.8697 = \boxed{0.1303}.
  4. The smallest significance level for which we can reject H0H_0 in this test is

    α=p-value=0.1303.\alpha = p\text{-value} = \boxed{0.1303}.