1.11 Confidence intervals

We have derived a number of different tests. In principle all of them can be turned into confidence intervals since there is a correspondence between hypothesis tests and confidence intervals. Let us first examine how we can use the Wald test to construct confidence intervals.

The Wald test is based on that for large \(n\): \[ \frac{\hat\theta- \theta}{\textrm{Sd}(\hat\theta)} \overset{asym.}{\sim} \mathsf{N}(0,1), \] Therefore we can write \[ 1-\alpha = P\left( -z_{\alpha/2} < \frac{\hat\theta- \theta}{\textrm{Sd}(\hat\theta)} \leq z_{\alpha/2} \right) = P\left( \hat\theta -\textrm{Sd}(\hat\theta) z_{\alpha/2}\leq \theta \leq \hat\theta + \textrm{Sd}(\hat\theta) z_{\alpha/2}\right). \] Which means that \(\left[\hat\theta -\textrm{Sd}(\hat\theta) z_{\alpha/2}, \hat\theta +\textrm{Sd}(\hat\theta) z_{\alpha/2}\right]\) is a \(1-\alpha\) confidence interval for \(\theta\).

Let us derive the same CI in a slightly different way. In the Wald test we would accept \(H_0: \theta=\theta_0\) if \(\left| \hat\theta - \theta_0 \right|/Sd(\hat\theta)<z_{\alpha/2}\). Solving this for \(\theta_0\) gives \[ \hat\theta -\textrm{Sd}(\hat\theta) z_{\alpha/2}\leq \theta_0 \leq \hat\theta + \textrm{Sd}(\hat\theta) z_{\alpha/2}. \] If we replace \(\theta_0\) with \(\theta\) we obtain the CI above. Therefore we may think of the CI as being the set of \(\theta_0\) that we would accept in a hypothesis test.

The same principle can be applied to convert any hypothesis test to a corresponding CI. For example the score test accepts \(H_0\) if

\[ \frac{\left| l'_n(\theta_0)\right |}{\sqrt{I_n(\theta_0)}}< z_{\alpha/2}, \]

and so solving this for \(\theta_0\) gives a CI. However, in most cases it is not possible to obtain a closed form solution and we have solve it numerically. Let us as an example do it for the exponential distribution:

\[\begin{align} l'_n(\lambda) &= n\left( \frac{1}{\lambda} - \frac{1}{\hat\lambda} \right),\\ I_n(\lambda) &= - l''_n(\lambda) = \frac{n}{\lambda^2}. \end{align}\]

We plot the score statistic as a function of \(\lambda\):

Score statistic and confidence intervall

Figure 1.7: Score statistic and confidence intervall

To find the CI we need to solve \[ \frac{\left| l'_n(\lambda)\right |}{\sqrt{I_n(\lambda)}} = z_{\alpha/2}, \] in terms of \(\lambda\). Looking at the figure, this has two solutions, one for \(\lambda > \hat\lambda\) and one for \(\lambda < \hat\lambda\). These will be the left and right endpoints of the CI.

alpha = 0.05
scoreStatistic <- function(lambda){
  abs( n*(1/lambda - 1/lambdaHat) ) / sqrt( n/lambda^2 )
}

f <- function(lambda){
  scoreStatistic(lambda) - qnorm(1-alpha/2)
}

rootResults <- uniroot(f, interval = c(lambdaHat-0.05,lambdaHat))
leftCILimit <- rootResults$root

rootResults <- uniroot(f, interval = c(lambdaHat+0.05,lambdaHat))
rightCILimit <- rootResults$root

leftCILimit
## [1] 0.09360885
rightCILimit
## [1] 0.1392479

We can compare this to the Wald based CI:

alpha = 0.05
z = qnorm(1-alpha/2)

leftCILimit <- lambdaHat - qnorm(1-alpha/2)*lambdaHat/sqrt(n)
rightCILimit <- lambdaHat + qnorm(1-alpha/2)*lambdaHat/sqrt(n)

leftCILimit
## [1] 0.09360885
rightCILimit
## [1] 0.1392479

Again, in this particular example, the two intervals are the same.