This home must be submitted online, much like a lab.

• Like lab, may use this RMarkdown document as a template. You do not need to remove directions. Chunks that require your input have a comment indicating to do so.

# Exercise 1

A track-and-field coach is interested in assessing whether or not a training program is effective. He first records the finishing times for seven 400 meter sprinters in seconds. Much later, after the training program is completed, he records the finishing times of the same seven athletes again. Use the sign test with a significance level of 0.05 to assess whether or not the training regime is effective. That is, test

$H_0\colon \ m_D = m_A - m_B = 0 \quad \text{vs} \quad H_A\colon \ m_D = m_A - m_B \neq 0$

where

• $$m_A$$ is the median finishing time of the 400 meter dash for his athletes after the training program
• $$m_B$$ is the median finishing time of the 400 meter dash for his athletes before the training program

Since it is possible that the training regime makes the runners worse, use a two-sided test.

Pre-Training Finishing Time Post-Training Finishing Time
62 55
72 59
50 48
60 58
62 63
61 59
57 50

For this homework you may use R however you wish. On an exam, you would be given the following code and output:

round(dbinom(x = 0:7, size = 7, prob = 0.5), 3)
##  0.008 0.055 0.164 0.273 0.273 0.164 0.055 0.008

Report:

• The p-value of the test
• A decision when $$\alpha = 0.05$$.
# use this chunk to complete any necessary calculations in R

# Exercise 2

Suppose that a sleep researcher is interested in the effect of exogenous melatonin on total sleep time. The researcher records the amount of sleep that ten individuals obtain on a particular night. A week later, he repeats the recordings on the same ten individuals, this time after administering 10 mg of melatonin one hour before bedtime. The data gathered is:

Sleep, Minutes, Without Melatonin Sleep, Minutes, With Melatonin
440 433
414 444
476 458
439 432
391 417
413 521
461 421
455 469
429 502
455 505

Use the sign test with a significance level of 0.05 to assess whether or not melatonin is effective. That is, test

$H_0\colon \ m_D = m_M - m_N = 0 \quad \text{vs} \quad H_A\colon \ m_D = m_M - m_N \neq 0$

where

• $$m_M$$ is the median sleep time of individuals using melatonin
• $$m_N$$ is the median sleep time of individuals not using melatonin

Since it is possible that the melatonin makes sleep worse, use a two-sided test.

For this homework you may use R however you wish. On an exam, you would be given the following code and output:

round(dbinom(x = 0:10, size = 10, prob = 0.5), 3)
##   0.001 0.010 0.044 0.117 0.205 0.246 0.205 0.117 0.044 0.010 0.001

Report:

• The p-value of the test
• A decision when $$\alpha = 0.05$$.
# use this chunk to complete any necessary calculations in R

# Exercise 3

• $$H_0$$: The distribution of sleep time is the same with and without melatonin
• $$H_A$$: The distribution of sleep time is different with and without melatonin

To do so, use a permutation test that permutes the statistic

$t = \frac{\bar{x}_D}{s_D / \sqrt{n}}$

where $$\bar{x}_D$$ is the sample mean difference, and $$s_D$$ is the standard deviation of the differences. Assume that the distribution of sleep time with and without melatonin has the same shape, but may have different locations. Use at least 10000 permutations.

without   = c(440, 414, 476, 439, 391, 413, 461, 455, 429, 455)
melatonin = c(433, 444, 458, 432, 417, 521, 421, 469, 502, 505)
• Create a histogram that illustrates the distribution of the statistic used.
• Report the p-value of the test.
# use this chunk to complete any necessary permutation calculations
# also calculate statistic on observed data
# use this chunk to create the histogram
# use this chunk to calculate the p-value of the test

# Exercise 4

Students are always interested in the effect of a notes sheet for an exam. A professor teaching two sections (call them, Section A and Section B) of the same course decides to run a (not so nice) experiment. On the midterm exam, she allows Section A to use a notes sheet, however, for the same exam, Section B is not given the chance to use a notes sheet. The following is a sampling of scores from the two sections:

section_a = c(85, 78, 89, 92, 86)
section_b = c(75, 90, 79, 87, 81, 82, 83, 84, 80, 91)

Use a permutation test that permutes the statistic

$t = \frac{(\bar{x} - \bar{y}) - 0}{s_p\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}$

to test

• $$H_0$$: The distribution of exam scores is the same with and without a notes sheet
• $$H_A$$: The distribution of exam scores is different with and without a notes sheet

Assume that the distribution of exam scores with and without notes has the same shape, but may have different locations. Use at least 10000 permutations.

• Create a histogram that illustrates the distribution of the statistic used.
• Report the p-value of the test.
# use this chunk to complete any necessary permutation calculations
# also calculate statistic on observed data
# use this chunk to create the histogram
# use this chunk to calculate the p-value of the test

# Exercise 5

Repeat exercise 4, but use an appropriate test available in the R function wilcox.test().

Report:

• The p-value of the test
• A decision when $$\alpha = 0.05$$.
# use this chunk to complete any necessary calculations in R