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? Assuming underlying data is iid gaussian
\(\frac{\bar X - µ}{S / \sqrt{n}}\)
follows Gosset’s \(t\) distibution with \(n-1\) degrees of freedom
Interval \(\bar X \pm t_{n-1} S / \sqrt{n}\), where \(t_{n-1}\) is the relevant quantile 1,100±2.306×309v=[1,077,1,123]
n <- 9
µ <- 1100
s <- 30
quantile = 0.975 # is 95% with 2.5% on both sides of the range
confidenceInterval = µ + c(-1, 1) * qt(quantile, df=n-1) * s / sqrt(n)
confidenceInterval
## [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? Interval \(CI_{up} = \bar X + t_{n-1} S / \sqrt{n}\), where \(t_{n-1}\) is the relevant quantile
Rewritten, to get standard deviation: \(S = \frac{CI_{up} - \bar X * \sqrt{n}}{t_{n-1}}\) t8,.975=2.31 Then set -2+2.31×S/3=0˜2.60 Solve for S to get around 2.60.
n <- 9
averageDifference <- -2
quantile = 0.975 # is 95% with 2.5% on both sides of the range
ci_up = 0
s = (ci_up - averageDifference * sqrt(n))/qt(quantile, df=n-1)
round(s, 2)
## [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).
ndependent group T intervals
A \((1 - a) \times 100%\) confidence interval for \(µ_y - µ_x\) is
\(\bar Y - \bar X \pm t_{n_x + n_y - 2, 1 - a/2} S_p\left(\frac{1}{n_x} + \frac{1}{n_y}\right)^{1/2}\)
The pooled variance estimator is:
\(S_p^2 = \{(n_x - 1) S_x^2 + (n_y - 1) S_y^2\}/(n_x + n_y - 2)\)
Rewritten for available variables:
\(S_p = \sqrt{\{(n_x - 1) var_x + (n_y - 1) var_y\}/(n_x + n_y - 2)}\)
quantile = 0.975 # is 95% with 2.5% on both sides of the range
n_y <- 10 # nights new system
n_x <- 10 # nights old system
var_y <- 0.60 # variance new (sqrt of s)
var_x <- 0.68 # variance old (sqrt of s)
µ_y <- 3# average hours new system
µ_x <- 5# average hours old system
# calculate pooled standard deviation
s_p <- sqrt(((n_x - 1) * var_x + (n_y - 1) * var_y)/(n_x + n_y - 2))
confidenceInterval <- µ_y - µ_x + c(-1, 1) * qt(quantile, df=n_y+n_x-2) * s_p * (1 / n_x + 1 / n_y)^.5
round(confidenceInterval,2)
## [1] -2.75 -1.25
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 sides of the range
n_y <- 100 # nights new system
n_x <- 100 # nights old system
s_y <- 0.50# s new
s_x <- 2# s old
µ_y <- 4# average hours new system
µ_x <- 6# average hours old system
# calculate pooled standard deviation
s_p <- sqrt(((n_x - 1) * s_x^2 + (n_y - 1) * s_y^2)/(n_x + n_y - 2))
confidenceInterval <- µ_x - µ_y + c(-1, 1) * qnorm(quantile) * s_p * (1 / n_x + 1 / n_y)^.5
round(confidenceInterval,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
quantile = 0.95 # is 90% with 5% on both sides of the range
n_y <- 9 # subjects treated
n_x <- 9 # subjects placebo
s_y <- 1.5# kg/m2 std.dev. treated
s_x <- 1.8# kg/m2 std.dev. placebo
µ_y <- -3# kg/m2 average difference treated
µ_x <- 1# kg/m2 average difference placebo
# calculate pooled standard deviation
s_p <- sqrt(((n_x - 1) * s_x^2 + (n_y - 1) * s_y^2)/(n_x + n_y - 2))
confidenceInterval <- µ_y - µ_x + c(-1, 1) * qt(quantile, df=n_y+n_x-2) * s_p * (1 / n_x + 1 / n_y)^.5
round(confidenceInterval,3)
## [1] -5.364 -2.636