1.4 Likelihood ratio test

We are interested in testing the following hypotheses \[ H_0:\theta \in \Theta_0\text{ vs. } H_1:\theta \in \Theta_0^\complement. \]

Here \(\Theta_0\) is some set of parameter values. It could for example be that \(\Theta_0 = (-\infty,\theta_0)\) or simply \(\Theta_0 = \theta_0\).

We define the likelihood ratio as \[ \lambda_{\text{LR}} := 2(l(\hat\theta) - l(\hat\theta_0)), \]

where \[ l(\hat\theta_0) = \sup_{\theta\in\Theta_0}l(\theta) \] and \[ l(\hat\theta) = \sup_{\theta\in\Theta}l(\theta). \] Since \(l(\hat\theta)\geq l(\hat\theta_0)\), we have that \(\lambda_{\text{LR}} \geq 0\) and data agrees well with \(H_0\) if \(\lambda_{\text{LR}}\) is small. Therefore the rejection region will be of the form \(\lambda_{\text{LR}} > k\), where \(k\) is determined to get the correct size of the test. We can not say more in general, the continuation depends on the particular problem and tends to become complicated for anything but simple models.

As before let us say that we have an iid sample from an exponential distribution and wish to test \(H_0:~\lambda = \lambda_0\) against \(H_1:~\lambda \neq \lambda_0\), with \(\lambda_0=0.1\).

We have already seen that \[ l(\lambda) = n(\ln \lambda - \lambda \bar t) \]

and that \(\hat\lambda = 1/\bar t\). Therefore

\[ l(\lambda) = n \left( \ln\lambda - \frac{\lambda}{\hat\lambda} \right). \]

Now, we can write \(l(\hat\lambda) = n\left(\ln\hat\lambda - 1\right)\). The likelihood ratio is then:

\[ \lambda_{\text{LR}} = 2(l(\hat\lambda) - l(\lambda_0)) = 2n\left( \ln\hat\lambda - 1 - \ln \lambda_0 + \frac{\lambda_0}{\hat\lambda} \right) = 2n\left(\ln \frac{\hat\lambda}{\lambda_0} + \frac{\lambda_0-\hat\lambda}{\hat\lambda}\right). \]

Recall that we should reject \(H_0\) if \(\lambda_{\text{LR}}>k\), and that \(k\) is set to get the correct size. But to do this we need to know the distribution of \(\lambda_{\text{LR}}\) and looking at the formula above, this seems difficult. Instead we search for something which is equivalent to \(\lambda_{\text{LR}}>k\), but with a known distribution. Towards this we plot \(\lambda_{LR}(\hat\lambda)\):

Illustration of the likelihood ratio

Figure 1.5: Illustration of the likelihood ratio

We see that \(\lambda_{LR}\) is decreasing for \(\hat\lambda < \lambda_0\) and increasing for \(\hat\lambda > \lambda_0\) with minimum at \(\hat\lambda = \lambda_0\). Therefore \(\lambda_{LR}>k\) is equivalent to \(\hat\lambda < k_L\) or \(\hat\lambda > k_U\), for some choices of \(k_L\) and \(k_U\). These should be determined so that the test gets the correct size.

The size of the test is \[\begin{align} &1- P_{\lambda_0} \left(k_L< \hat\lambda < k_U \right) = 1- P_{\lambda_0} \left(k_L< \frac{1}{\bar t} < k_U \right) = 1- P_{\lambda_0} \left(1/k_U< \bar t < 1/k_L \right)\\ =& 1- P_{\lambda_0} \left(\tilde k_L< \sum_{i=1}^n T_i< \tilde k_U \right), \end{align}\] with \(\tilde k_L := n/k_U\) and similarly for \(\tilde k_U\). This probability can be calculated since we know that \(\sum_{i=1}^n T_i \sim \Gamma(n,\lambda)\). If we let \(\Gamma_{\alpha}(n,\lambda)\) be the \(\alpha\)-quantile of the gamma distribution, i.e. the number such that \[ \alpha = P\left( \Gamma(n,\lambda )> \Gamma_\alpha(n,\lambda) \right), \] we see that the rejection region for a size \(\alpha\) test is \[ \left\{ T_i\mid \sum_{i=1}^n T_i > \Gamma_{\alpha/2}(n,\lambda_0) \text{ or } \sum_{i=1}^n T_i < \Gamma_{1-\alpha/2}(n,\lambda_0) \right\}. \] or equivalently \[ \left\{ \hat \lambda \mid \hat\lambda < \frac{n}{\Gamma_{\alpha/2}(n,\lambda_0)} \text{ or } \hat\lambda > \frac{n}{\Gamma_{1-\alpha/2}(n,\lambda_0)} \right\}. \]

Let us implement this:

alpha <- 0.05
lambda0 <- 0.1
n <- 100

upperCriticalValue <- n / qgamma(alpha/2, shape = n, rate = lambda0)
lowerCriticalValue <- n / qgamma(1-alpha/2, shape = n, rate = lambda0)
upperCriticalValue
## [1] 0.1229045
lowerCriticalValue
## [1] 0.08296762

In this case we had \(\hat\lambda =\) 0.1164 and so we would not reject \(\lambda \neq 0.1\).

Another option is to calculate the p-value. Recall that the p-value is the smallest level for which \(H_0\) is rejected. That is, it is the \(\alpha\) that solves \(\Gamma_{1-\alpha/2}(n,\lambda_0) = n/\hat\lambda\). But, by definition \[ \alpha = 2 P \left( \Gamma(n,\lambda_0) < \Gamma_{1-\alpha/2}) \right) \] and therefore the p-value is \[ 2P\left( \Gamma(n,\lambda_0) < \frac{n}{\hat\lambda} \right). \]

2* pgamma(n/lambdaHat, shape = n, rate = lambda0)
## [1] 0.1471398

Again we see that we would not reject \(H_0\) on the 5%-level.