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?
CI<-1100 + c(-1, 1) * qt(0.975, df=9-1) * 30 / sqrt(9)
#rounds the values the specified number of significant digits.
signif(CI,4)
## [1] 1077 1123
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?
## [1] 2.6
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).
quantile <- 0.975 # is 95% with 2.5% on both tails
Nightsold<-10#number of nights old system was tested
NightsNew<-10#number of nights new system was tested
NewWaitingTime<-3#mean time patiants waited in new system
OldWaitingTime<-5#mean time patiants waited in old system
VarianceNew<-0.60#variance of time patiants waited in new system
VarianceOld<-0.68#variance of time patiants waited in old system
tscore<-qt(quantile, (Nightsold+NightsNew-2))#T score quantile (.975) and df
# calculate pooled standard deviation
sp <- sqrt(((Nightsold-1) * VarianceNew + (Nightsold-1) * VarianceOld)/(Nightsold + NightsNew - 2))
#sqrt gets from variance to sd. Then you pool the variance divided by their sample size minus one for each sample size which gives us a waited avarage.
confidenceInterval <- round(NewWaitingTime - OldWaitingTime + c(-1, 1) * tscore * sp * (1/NightsNew + 1/Nightsold)^0.5,2)
#round to two numbers first. The put the higher number first and subtract the lower number from it. then add and subtract. Then multiple by the t-score times the pooled standard deviation time 1 divided by sample size of each group raised to the half power.
confidenceInterval
## [1] -2.75 -1.25
#Print the Confidence interval
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.)
quantile <- 0.975 # is 95% with 2.5% on both tails
Nightsold<-100#number of nights old system was tested
NightsNew<-100#number of nights new system was tested
NewWaitingTime<-4#mean time patiants waited in new system
OldWaitingTime<-6#mean time patiants waited in old system
SDNew<-0.50#SD of time patiants waited in new system
SDOld<-2#SD of time patiants waited in old system
zscore<-qnorm(quantile)#Z score quantile (.975)
# calculate pooled standard deviation
sp <- sqrt(((Nightsold - 1) * SDOld^2 + (NightsNew - 1) * SDNew^2)/(Nightsold + NightsNew - 2))
confidenceInterval <- round(OldWaitingTime - NewWaitingTime + c(-1, 1) * zscore * sp * (1/NightsNew + 1/Nightsold)^0.5,2)
confidenceInterval
## [1] 1.6 2.4
When subtracting (old - new) the interval is entirely above zero. The new system does not appear to be effective. When subtracting (old - new) the interval contains 0. There is not evidence suggesting that the new system is effective. When subtracting (old - new) the interval is entirely above zero. The new system appears to be effective. When subtracting (old - new) the interval contains 0. The new system appears to be effective.
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.
quantile <- 0.95 # is 95% with 2.5% on both tails
control<-9#size of control group
treatment<-9#size of treatment group
meantreatment<--3#average difference from follow-up to the baseline (followup - baseline) treatment
meancontrol<-1#average difference from follow-up to the baseline (followup - baseline) control
SDtreatment<-1.5
SDcontrol<-1.8
tscore<-qt(quantile, (control+treatment-2))#T score quantile (.95) and df
# calculate pooled standard deviation
sp <- sqrt(((treatment-1) * SDtreatment^2 + (control-1) * SDcontrol^2)/(control + treatment - 2))
#sqrt gets from variance to sd. Then you pool the variance divided by their sample size minus one for each sample size which gives us a waited avarage.
confidenceInterval <- round(meantreatment - meancontrol + c(-1, 1) * tscore * sp * (1/control + 1/treatment)^0.5,3)
#round to two numbers first. The put the higher number first and subtract the lower number from it. then add and subtract. Then multiple by the t-score times the pooled standard deviation time 1 divided by sample size of each group raised to the half power.
confidenceInterval
## [1] -5.364 -2.636
#Print the Confidence interval