Statistical Inference Quiz 4

1. A pharmaceutical company is interested in testing a potential blood pressure lowering medication. Their first examination considers only subjects that received the medication at baseline then two weeks later. Consider testing the hypothesis that there was a mean reduction in blood pressure? Give the P-value for the associated two sided T test.

dt <- read.table("SI_quiz4.txt",header=TRUE)
dt
##   Subject Baseline Week2
## 1       1      140   132
## 2       2      138   135
## 3       3      150   151
## 4       4      148   146
## 5       5      135   130
t<- t.test(x=dt$Baseline, y=dt$Week2, paired=TRUE)
t$p.value
## [1] 0.08652278

2. A sample of 9 men yielded a sample average brain volume of 1100cc and a standard deviation of 30cc. What is the complete set of values of mu0 that a test of H0:mu=mu0 would fail to reject the null hypothesis in a two sided 5% Students t-test?

n <- 9
mean <- 1100
sd <- 30

p <- .95+(1-.95)/2
error <- qt(p,df=n-1)*sd/sqrt(n)
ci_low <- mean - error
ci_high <- mean + error

ci_low
## [1] 1076.94
ci_high
## [1] 1123.06

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.

# Ha: Coke is preferred to Pepsi (p>0.5)
binom.test(c(3,1),p=0.5, alt="greater")$p.value
## [1] 0.3125

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 1787 person days at risk. About what is the one sided P-value for the relevant test of whether the hospital is below the standard?

pbar <- 10/1787   # sample proportion
p0 <- 1/100       # hypothesized value
n <- 1787         # sample size
z <- (pbar-p0)/sqrt(p0*(1-p0)/n)

pval <- pnorm(z, lower.tail=TRUE) 
pval
## [1] 0.03066625

5. Suppose that 18 obese subjects were randomized, 9 each, to a new diet pill and a placebo. Subjects’s 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 (followup - baseline) was -3 kg/m2 for the treated group and 1 kg/m2 for the placebo group. The corresponding standard deviations of the differences was 1.5 kg/m2 for the treatment group and 1.8 kg/m2 for the placebo group. Does the change in BMI appear to differ between the treated and placebo groups? Assuming normality of the underlying data and a common population variance, give a pvalue for a two sided t test.

# treatment
x1 <- -3            
s1 <- 1.5
n1 <- 9

# placebo
x2 <- 1
s2 <- 1.8
n2 <- 9

# weighted sd 
sp <- sqrt(((n1-1)*s1**2+(n2-1)*s2**2)/(n1+n2-2))
t <- (x1-x2)/(sp*sqrt(1/n1+1/n2))
pval <- 2*pt(t,df=n1+n2-1)
pval
## [1] 8.50523e-05

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

mu = 1078 falls in 1077- 1123 range, so you wouldn’t reject the H0.

7. Researchers would like to conduct a study of 100 healthy adults to detect a four year mean brain volume loss of .01 mm3. Assume that the standard deviation of four year volume loss in this population is .04 mm3. 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
mua <- 0.01
s <- 0.04
alpha <- 0.05
mu0 <- 0              # no brain volum loss

power.t.test(n=n, delta=mua-mu0, sd=s, type="one.sample", alt="one.sided", sig.level=alpha)$power
## [1] 0.7989855

8. Researchers would like to conduct a study of n healthy adults to detect a four year mean brain volume loss of .01 mm3. Assume that the standard deviation of four year volume loss in this population is .04 mm3. About what would be the value of n needed for 90% power of type one error rate of 5% one sided test versus a null hypothesis of no volume loss?

mua <- 0.01
s <- 0.04
power <- 0.9
alpha <- 0.05
mu0 <- 0

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

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

Power increases as you increase alpha.