In a population of interest, a sample of 9 men yielded a sample average brain volume of 1,100cc and a standard deviation of 30cc. What is a 95% Student’s T confidence interval for the mean brain volume in this new population?
mu<-1100
SD<-30
n<-9
#95% confidence interval is equivalent to 2.5% on each side
#hence we need to take the 97.5th quantile .95+(1-.95)/2=.975
quantile<-0.975
mu+ c(-1,1)*qt(quantile,n-1)*SD/sqrt(n)
## [1] 1076.94 1123.06
A diet pill is given to 9 subjects over six weeks. The average difference in weight (follow up - baseline) is -2 pounds. What would the standard deviation of the difference in weight have to be for the upper endpoint of the 95% T confidence interval to touch 0?
meanDiff<--2 #average difference
upperLim<-0 #upper endpoint
n<-9
#95% confidence interval is equivalent to 2.5% on each side
#hence we need to take the 97.5th quantile
quantile<-0.975
#SD is iven by upperLim - diferenceAverage * sqrt(n) / quantile, n-1)
SD<- upperLim - meanDiff * sqrt(n)/qt(quantile, df=n-1)
SD
## [1] 2.601903
#In order to verify our result we can compute the upperLim
#by meanDiff + qt(quantile,n-1)*SD/sqrt(n)
In an effort to improve running performance, 5 runners were either given a protein supplement or placebo. Then, after a suitable washout period, they were given the opposite treatment. Their mile times were recorded under both the treatment and placebo, yielding 10 measurements with 2 per subject. The researchers intend to use a T test and interval to investigate the treatment. Should they use a paired or independent group T test and interval?
A paired interval
It’s necessary to use both
Independent groups, since all subjects were seen under both systems
You could use either
In a study of emergency room waiting times, investigators consider a new and the standard triage systems. To test the systems, administrators selected 20 nights and randomly assigned the new triage system to be used on 10 nights and the standard system on the remaining 10 nights. They calculated the nightly median waiting time (MWT) to see a physician. The average MWT for the new system was 3 hours with a variance of 0.60 while the average MWT for the old system was 5 hours with a variance of 0.68. Consider the 95% confidence interval estimate for the differences of the mean MWT associated with the new system. Assume a constant variance. What is the interval? Subtract in this order (New System - Old System).
#see module 8_03 for more details
nOld<-10 #nb of nights tested for the old system
nNew<-10 #nb of nights tested for the new system
meanOld<-5 #mean waiting time in old system
meanNew<-3 #mean waiting time in new system
varOld<-0.68 #waiting time variance in old system
varNew<-0.60 #waiting time variance in new system
quantile <- 0.975 # is 95% with 2.5% on both tails
# Compute pooled standard deviation
pooledSD<-sqrt(((nOld - 1) * varOld + (nNew - 1) * varNew)/(nOld + nNew - 2))
# Confidence Interval
CI <- meanOld - meanNew + c(-1, 1) * qt(quantile, df=nOld+nNew-2) * pooledSD * (1 / nOld + 1 / nNew)^0.5
round(CI,2)
## [1] 1.25 2.75
Suppose that you create a 95% T confidence interval. You then create a 90% interval using the same data. What can be said about the 90% interval with respect to the 95% interval?
The interval will be wider
The interval will be narrower.
The interval will be the same width, but shifted.
It is impossible to tell.
The interval will always become narrower as the confidence interval decreases
To further test the hospital triage system, administrators selected 200 nights and randomly assigned a new triage system to be used on 100 nights and a standard system on the remaining 100 nights. They calculated the nightly median waiting time (MWT) to see a physician. The average MWT for the new system was 4 hours with a standard deviation of 0.5 hours while the average MWT for the old system was 6 hours with a standard deviation of 2 hours. Consider the hypothesis of a decrease in the mean MWT associated with the new treatment.
What does the 95% independent group confidence interval with unequal variances suggest vis a vis this hypothesis? (Because there’s so many observations per group, just use the Z quantile instead of the T.)
nOld<-100 #nb of nights tested for the old system
nNew<-100 #nb of nights tested for the new system
meanOld<-6 #mean waiting time in old system
meanNew<-4 #mean waiting time in new system
sdOld<-2 #SD waiting time in old system
sdNew<-0.5 #SD waiting time in new system
quantile <- 0.975
#Here the instruction tells us to use z quantile instead of t quantile
#qt returns quantiles of the t-distribution while qnorm returns quantiles of the standard normal distribution
#Thumb rule is for nn greater than 30, we can assume normality but that might not always be true
# calculate pooled standard deviation
#we need to square the SD to get the variance
pooledSD<-sqrt(((nOld - 1) * sdOld^2 + (nNew - 1) * sdNew^2)/(nOld + nNew - 2))
#? qnorm
CI <- meanOld - meanNew + c(-1, 1) * qnorm(quantile) * pooledSD * (1 / nOld + 1 / nNew)^0.5
round(CI,2)
## [1] 1.6 2.4
Suppose that 18 obese subjects were randomized, 9 each, to a new diet pill and a placebo. Subjects’ 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 over the four week period appear to differ between the treated and placebo groups? Assuming normality of the underlying data and a common population variance, calculate the relevant 90%t confidence interval. Subtract in the order of (Treated - Placebo) with the smaller (more negative) number first.
nPlacebo<-9
nTreated<-9
muPlacebo<-1 #The average difference from follow-up to the baseline (followup - baseline) Placebo
muTreated<--3 #The average difference from follow-up to the baseline (followup - baseline) real Treatment
sdPlacebo<-1.8 #The corresponding standard deviations of the differences Placebo
sdTreated<-1.5 #The corresponding standard deviations of the differences Treatment
quantile<- 0.95
#get t-score as it is a t-dstribution
tscore<-qt(quantile, (nPlacebo+nTreated-2))
# calculate pooled standard deviation
pooledSD <- sqrt(((nPlacebo-1) * sdPlacebo^2 + (nTreated-1) * sdTreated^2)/(nPlacebo + nTreated - 2))
#Subtract in the order of (Treated - Placebo) with the smaller (more negative) number first.
CI <- muTreated - muPlacebo + c(-1, 1) * tscore * pooledSD * (1/nPlacebo + 1/nTreated)^0.5
round(CI,2)
## [1] -5.36 -2.64