Confidence intervals


The Chi-squared distribution


Confidence interval for the variance

Note that if \( \chi^2_{n-1, \alpha} \) is the \( \alpha \) quantile of the Chi-squared distribution then

\[ \begin{eqnarray*} 1 - \alpha & = & P \left( \chi^2_{n-1, \alpha/2} \leq \frac{(n - 1) S^2}{\sigma^2} \leq \chi^2_{n-1,1 - \alpha/2} \right) \\ \\ & = & P\left(\frac{(n-1)S^2}{\chi^2_{n-1,1-\alpha/2}} \leq \sigma^2 \leq \frac{(n-1)S^2}{\chi^2_{n-1,\alpha/2}} \right) \\ \end{eqnarray*} \] So that \[ \left[\frac{(n-1)S^2}{\chi^2_{n-1,1-\alpha/2}}, \frac{(n-1)S^2}{\chi^2_{n-1,\alpha/2}}\right] \] is a \( 100(1-\alpha)\% \) confidence interval for \( \sigma^2 \)


Notes about this interval


Example

Confidence interval for the standard deviation of sons' heights from Galton's data

library(UsingR)
## Loading required package: MASS
data(father.son)
x <- father.son$sheight
s <- sd(x)
n <- length(x)
round(sqrt((n - 1) * s^2/qchisq(c(0.975, 0.025), n - 1)), 3)
## [1] 2.701 2.939

Gosset's \( t \) distribution


Result


Confidence intervals for the mean


Note's about the \( t \) interval


Sleep data

In R typing data(sleep) brings up the sleep data originally analyzed in Gosset's Biometrika paper, which shows the increase in hours for 10 patients on two soporific drugs. R treats the data as two groups rather than paired.


The data

data(sleep)
head(sleep)
##   extra group ID
## 1   0.7     1  1
## 2  -1.6     1  2
## 3  -0.2     1  3
## 4  -1.2     1  4
## 5  -0.1     1  5
## 6   3.4     1  6

g1 <- sleep$extra[1:10]
g2 <- sleep$extra[11:20]
difference <- g2 - g1
mn <- mean(difference)
s <- sd(difference)
n <- 10
mn + c(-1, 1) * qt(0.975, n - 1) * s/sqrt(n)
## [1] 0.7001 2.4599
t.test(difference)$conf.int
## [1] 0.7001 2.4599
## attr(,"conf.level")
## [1] 0.95