Question 1

A pharmaceutical company is interested in tesing a potential blood pressure lowering medication. Their first examination considers only subjects that received the medication at baseline then two weeks later. The data are as follows:

baseline <- c(140, 138, 150, 148, 135)
week_2 <- c(132, 135, 151, 146, 130)

Consider testing the hypothesis that there was a mean reduction in blood pressure? Give the P-value for the associated two sided T test.

t.test(week_2, baseline, paired = TRUE)$p.value
## [1] 0.08652278

===============================================================================

Question 2

The sample of 9 men yielded a sample average brain volume of 1,100cc and a standard deviation of 30cc. What is the complete set of values of mu_0 that a test of H_0: mu = mu_0 would fail to reject the null hypothesis in a two sided 5% Student t-test

n <- 9
mu <- 1100
sd <- 30
alpha <- .05

mu + c(-1, 1) * qt((1 - alpha/2), n - 1) * sd / sqrt(n)
## [1] 1076.94 1123.06

==============================================================================

Question 3

Researchers conducted a blind taste test of Coke versus Pepsi. Each of four people was asked which of two blinded drinks given in random order that they preferred. The data was such that 3 of the 4 people chose Coke. Assuming that this sample is representative, report a P-value for a test of the hypothesis that Coke is preferred to Pepsi using a one-sided exact test.

q <- 2 ## pbinom assumes > or <=, so must set q equal = 2 for 3 or more
size <- 4
prob <- 0.5

pbinom(q, size, prob, lower.tail = FALSE)
## [1] 0.3125

==============================================================================

Question 4

Infection rates at a hospital above 1 infection per 100 person days at risk are believed to be too high and are used as a benchmark. A hospital that had previously been above the benchmark recently had 10 infections over the last 1,787 person days at risk. About what is the one sided P-value for the relevant test of whether the hospital is ’below the standard?

q <- 10
lambda <- (1 / 100) * 1787

ppois(q, lambda)
## [1] 0.03237153

=============================================================================

Question 5

Suppose that 18 obese subjects were ramdomized, 9 each, to a new diet pill and a placebo. Subjests’ body mass indices (BMIs) were measured at a baseline and again after having received the treatment or placebo for four weeks. The average difference from follow-up to the baseline was -3 km/m^2 for the treated group and 1 kg/m^2 for the placebo group. The corresponding standard deviations of the differences was 1.5 kg/m^2 for the treatment group and 1.8 kg/m^2 for the placebo group. Does the change in BMI appear to differ between the treated and the placebo groups? Assuming narmality of the underlying data and a common population variance, give a pvalue for a two-side t test.

Let’s identify the summary stats we know (t=treated, p=placebo):

n_t <- 9
n_p<- 9

diff_t <- -3
diff_p <- 1

sd_t <- 1.5
sd_p <- 1.8

df <- n_t + n_p - 2 ## degrees of freedom

Let’s calculate the p value by calculating the effect size first then evaluating with n_t + n_p - 2 degrees of freedom.

## pooled standard deviation
sd_pool <- sqrt(((n_t - 1) * sd_t^2 + (n_p - 1) * sd_p^2) / (df))
## standard error
SE <- sd_pool * sqrt(1/n_t + 1/n_p)
## effect size
eff_size <- (diff_t - diff_p) / SE

pt(eff_size, df) * 2 ## multiple by 2 for 2-sided test
## [1] 0.0001025174

==============================================================================

Question 6

Brain volumes for 9 men yielded a 90% confidence interval of 1,077cc to 1,123cc. Would you reject in a two-sided 5% hypothesis test of: H_0: mu = 1.078

mu_a <- (1077 + 1123) / 2  ## mu_a will be average of high/low confidence bands
low_ci <- 1077
SE_a <- (mu_a - low_ci) / qt(.95, 8)  ## calculates SE of the alternative

## new confidence interval
mu_a + c(-1, 1) * qt(.975, 8) * SE_a
## [1] 1071.478 1128.522

You would fail to reject since it falls inside the confidence interval. More simply, since it fell inside the 90% CI, it would also fall inside the 95% CI

==============================================================================

Question 7

Researchers would like to conduct a study of 100 healthy adults to detect a four year mean brain volume loss of 0.01 mm^3. Assume the standard deviation of four year volume loss in this population is 0.04 mm^3. About what would be the power of the study for a 5% one sided test versus a null hypothesis of no volume loss?

n <- 100
delta <- 0.01
sd <- 0.04

power.t.test(n = n, delta = delta, sd = sd, type = "one.sample", 
             alt = "one.sided")$power
## [1] 0.7989855

==============================================================================

Question 8

Researchers would like to conduct a study of n healthy adults to detect a four year mean brain volume loss of 0.1 mm^3. Assume the standard deviation of four year volume loss in this population is 0.04 mm^3. About what would be the value of n needed for 90% power of type one error rate of 5% one sied test versus a null hypothesis of no volume loss.

delta <- 0.01
sd <- 0.04
power <- 0.90
sig.level <- 0.05

power.t.test(delta = delta, sd = sd, power = power, sig.level = sig.level,
             type = "one.sample", alt = "one.sided")$n
## [1] 138.3856

==============================================================================

Question 9

As you increase the type one error rate, alpha, what happens to power?

For visual help:

library(ggplot2)
ggplot(data.frame(mu = c(-5,5)), aes (x = mu)) +
     stat_function(fun = dnorm, geom = "line",
                   args = list(mean = 0, sd = 1),
                   size = 2, col = "red") +
     stat_function(fun = dnorm, geom = "line",
                   args = list(mean = 2, sd = 1),
                   size = 2, col = "blue") +
     geom_vline(xintercept = qnorm(1 - .05), size = 3)

Alpha = area to the right of the vertical line under the red distribution
Power = area to the right of the vetical line under the blue distribution

Answer: You will get larger power.