## Exercise 1 (Using a Wald Test)
(**LW** 10.7) In 1861, 10 essays appeared in the *New Orleans Daily Crescent*. They were signed "Quintus Curtius Snodgrass" and some people suspected they were actually written by Mark Twain. To investigate this, we will consider the proportion of three letter words found in an author's work.
From eight Twain essays we have:
```{r}
twain = c(0.225, 0.262, 0.217, 0.240, 0.230, 0.229, 0.235, 0.217)
```
From 10 Snodgrass essays we have:
```{r}
snod = c(0.209, 0.205, 0.196, 0.210, 0.202, 0.207, 0.224, 0.223, 0.220, 0.201)
```
Perform a Wald test for equality of the means. Use the nonparametric plug-in estimator. Report the p-value and an approximate 95 percent confidence interval for the difference of means. What do you conclude?
## Exercise 2 (Using a Permutation Test)
(**LW** 10.7) In 1861, 10 essays appeared in the *New Orleans Daily Crescent*. They were signed "Quintus Curtius Snodgrass" and some people suspected they were actually written by Mark Twain. To investigate this, we will consider the proportion of three letter words found in an author's work.
From eight Twain essays we have:
```
twain = c(0.225, 0.262, 0.217, 0.240, 0.230, 0.229, 0.235, 0.217)
```
From 10 Snodgrass essays we have:
```
snod = c(0.209, 0.205, 0.196, 0.210, 0.202, 0.207, 0.224, 0.223, 0.220, 0.201)
```
Perform a permutation test to test for equality of the means. Report the p-value. What is your conclusion?
## Exercise 3 (Power and Size)
(**LW** 10.5) Let $X_1, \ldots ,X_n \sim \text{Uniform}(0, \theta)$ and define $Y_n = \text{max}\{X_1, \ldots ,X_n\}$. We want to test
$$
H_0: \theta = 0.5 \quad \text{versus} \quad H_1: \theta > 0.5.
$$
The Wald test is not appropriate since $Y$ does not converge to a Normal. So, suppose we decide to test this hypothesis by rejecting $H_0$ when $Y > c$.
- Find the power function.
- What choice of c will make the size of the test $0.05$?
- In a sample of size $n = 20$ with $Y = 0.48$ what is the p-value? What conclusion about $H_0$ would you make?
- In a sample of size $n = 20$ with $Y = 0.52$ what is the p-value? What conclusion about $H_0$ would you make?
## Exercise 4 (Two Simple Hypotheses)
(**LW** 10.8) Let $X_1, \ldots ,X_n \sim N(\theta, 1)$. Consider testing
$$
H_0: \theta = 0 \quad \text{versus} \quad H_1: \theta = 1.
$$
Let the rejection region be $R = \{x^n: T(x^n) > c\}$ where $T(x^n) = \frac{1}{n}\sum_{i = 1}^{n} X_i$.
- Find $c$ so that the test has size $\alpha$.
- Find the power under $H_1$, that is, find, $\beta(1)$.
- Show that, $\beta(1) \to 1$ as $n \to \infty$.
## Exercise 5 (Testing for a Normal Mean)
(**LW** 10.13) Let $X_1, \ldots ,X_n \sim N(\mu, \sigma^2)$. Construct the likelihood ratio test for
$$
H_0: \mu = \mu_0 \quad \text{versus} \quad H_1: \mu \neq \mu_0.
$$
Compare to the Wald test.
## Exercise 6 (Testing for a Binomial Proportion)
(**LW** 10.13) Let $X \sim \text{Binomial}(n, p)$. Construct the likelihood ratio test for
$$
H_0: p = p_0 \quad \text{versus} \quad H_1: p \neq p_0.
$$
Compare to the Wald test.
## Exercise 7 (Comparing Power)
(**CB** 8.13) Let $X_1, X_2 \sim \text{Uniform}(\theta, \theta + 1)$. Consider two tests for
$$
H_0: \theta = 0 \quad \text{versus} \quad H_1: \theta > 0.
$$
1. $\phi_1(X_1)$: Reject $H_0$ is $X_1 > 0.95$.
2. $\phi_2(X_1, X_2)$: Reject $H_0$ is $X_1 + X_2 > c$.
With these two tests...
- Find the value of $c$ that makes $\phi_2$ have the same size as $\phi_1$.
- Calculate and plot the power of each test.
## Exercise 8 (Using Neyman-Pearson)
(**CB** 8.20) Let $X$ be a random variable whose pmf under $H_0$ and $H_1$ is given by
| x | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|-----------------|------|------|------|------|------|------|------|
| $f(x \mid H_0)$ | 0.01 | 0.01 | 0.01 | 0.01 | 0.01 | 0.01 | 0.94 |
| $f(x \mid H_1)$ | 0.06 | 0.05 | 0.04 | 0.03 | 0.02 | 0.01 | 0.79 |
Use the Neyman-Pearson Lemma to find the most powerful test for $H_0$ versus $H_1$ with size $\alpha = 0.04$. Compute the probability of a Type II Error for this test.
## Exercise 9 (Multiple Testing)
(**LW** 10.11) A randomized, double-blind experiment was conducted to assess the effectiveness of several drugs for reducing postoperative nausea. The data are as follows.
| Treatment | Number of Patients | Incidence of Nausea |
|------------------------|--------------------|---------------------|
| Placebo | 80 | 45 |
| Chlorpromazine | 75 | 26 |
| Dimenhydrinate | 85 | 52 |
| Pentobarbital (100 mg) | 67 | 35 |
| Pentobarbital (150 mg) | 85 | 37 |
Test each drug versus the placebo at the 5% level with a two-sided test. Report the p-value for each test. Also report Bonferroni corrected p-values.
## Exercise 10 (Verifying Size)
(**LW** 10.12) Let $X_1, \ldots ,X_n \sim \text{Poisson}(\lambda)$. Let $\lambda_0 > 0$. Find the size $\alpha$ Wald test for
$$
H_0: \lambda = \lambda_0 \quad \text{versus} \quad H_1: \lambda \neq \lambda_0.
$$
Set $\lambda_0 = 1$, $n = 20$, and $\alpha = 0.05$. Simulate from the null distribution and perform the Wald test. Repeat many times and count how often you reject the null. How close is this result to $\alpha = 0.05$.
## Exercise 11 (Simulating Power)
Use the setup from Exercise 10 and perform a simulation study that is informative about the power of the test.