Say we have the following: we have data \(X_1,..,X_n \sim N(0, 1)\) and \(Y_1,..,Y_m \sim N(\mu, 1)\). We wish to test

\[H_0:\mu=0\text{ vs. }H_a:\mu>0\]

In R this can be done with the command

t.test(x, y, alternative = "less")$p.value

For example

x <- rnorm(10)
y <- rnorm(13, 0)
t.test(x, y, alternative = "less")$p.value
## [1] 0.2919114
y <- rnorm(13, 2)
t.test(x, y, alternative = "less")$p.value
## [1] 0.0004251926

In this homework treat the t.test command as a black box, that is donโ€™t make any use of the two-sample t test method other that running the command.

Problem 1

Verify that this test has the correct type I error for the case \(n=m=10\), \(\alpha=0.01, 0.05, 0.10\).

Problem 2

What is the power of this test if \(n=m=10\), \(\mu=1.1,\alpha=0.05\)?

Problem 3

How large does \(\mu\) have to be so that the power is \(95\%\) for the case \(n=m=10\) if the test is done with \(\alpha=0.05\)?

Problem 4

How large does \(\mu\) have to be so that the power is \(95\%\) for the case \(n=m=10\) if the test is done with \(\alpha=0.01\)?

Problem 5

What sample size \(n=m\) is needed so the test has a power of \(95\%\) if \(\mu=0.5\) and \(\alpha=0.05\)?

Problem 6

If \(n=10\), is there an \(m\) so that the test has a power of \(95\%\) if \(\mu=0.5\) and \(\alpha=0.05\)?

All of these questions should be answered via simulation in R. Your solution should include the R code. I recommend that you use RMarkdown.