mean <- 1100
sd <- 30
n <- 9
# Since there are two tails of the Student t distribution, the 95% confidence level would imply the 97.5th percentile of the Student t distribution at the upper tail.
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
n <- 9
mean <- -2
ci_high <- 0
p <- .95+(1-.95)/2
sd <- (ci_high - mean) *sqrt(n) / qt(p, df=n-1)
sd
## [1] 2.601903
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
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).
n1 <- 10
m1 <- 3
v1 <- 0.6
n2 <- 10
m2 <- 5
v2 <- 0.68
p <- .95+(1-.95)/2
t <- qt(p,df=n1+n2-2)
md <- m1-m2
mse <- (v1+v2)/2
n <- n1 # since n1=n2
se <- sqrt(2*mse/n)
ci_low <- md - t* se
ci_high <- md + t* se
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 narrower.
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.)
n1 <- 100
m1 <- 4
s1 <- 0.5
n2 <- 100
m2 <- 6
s2 <- 2
p <- .95+(1-.95)/2
# t <- qt(p,df=n1+n2-2)
z <- qnorm(p)
md <- m2-m1
mse <- (s1**2+s2**2)/2
n <- n1 # since n1=n2
se <- sqrt(2*mse/n)
ci_low <- md - z* se
ci_high <- md + z* se
ci_low
## [1] 1.595943
ci_high
## [1] 2.404057
n1 <- 9
m1 <- -3
s1 <- 1.5
n2 <- 9
m2 <- 1
s2 <- 1.8
p <- .90+(1-.90)/2
t <- qt(p,df=n1+n2-2)
md <- m1-m2
mse <- (s1**2+s2**2)/2
n <- n1 # since n1=n2
se <- sqrt(2*mse/n)
ci_low <- md - t* se
ci_high <- md + t* se
ci_low
## [1] -5.363579
ci_high
## [1] -2.636421