[1] 276
[1] 0.04865865
[1] 0.05515271
\[\phi(\mathbf{y}) = \left\{\begin{array} {ll} 1 & \mathbf{y} \in RR \\ 0 & \mathbf{y} \notin RR\\ \end{array}\right.\]
\[H_0: \theta = \theta_0\] \[H_a: \theta = \theta_a\]
Define \(\phi(\mathbf{y})= 1\) when:
\[\frac{L(\theta_a)}{L(\theta_0)} = \frac{f(\mathbf{y};\theta_a)}{f(\mathbf{y};\theta_0)}> c,\]
and \(\phi(\mathbf{y})= 0\) when:
\[\frac{L(\theta_a)}{L(\theta_0)} = \frac{f(\mathbf{y};\theta_a)}{f(\mathbf{y};\theta_0)}< c,\]
for some \(c\) chosen such that \(P_{\theta_0}(\phi(\mathbf{y})=1) =\alpha\).
Intuition: reject \(H_0\) if the data are “convincingly more likely” under \(\theta_a\) than they are under \(\theta_0\).
Then, for any other test \(\phi'(\mathbf{y})\) that satisfies:
\[\alpha = P_{\theta_0}(\phi'(\mathbf{y})=1) = P_{\theta_0}(\phi(\mathbf{y})=1),\]
the power of \(\phi(\mathbf{y})\) (the likelihood ratio test) is at least as large as the power of \(\phi'(\mathbf{y})\); that is:
\[P_{\theta_a}(\phi(\mathbf{y})=1) \geq P_{\theta_a}(\phi'(\mathbf{y})=1).\]
\[P_\theta(\phi(\mathbf{y})=1) = 1\cdot P_\theta(\phi(\mathbf{y})=1) + 0\cdot P_\theta(\phi(\mathbf{y})=0)\]
\[ = E_\theta(\phi(\mathbf{y})) = \int \phi(\mathbf{y})\cdot f(\mathbf{y};\theta) d\mathbf{y}\]
Implications:
\[P_\theta(\phi'(\mathbf{y})=1) = E_\theta(\phi'(\mathbf{y}))\]
\[\frac{L(\theta_a)}{L(\theta_0)} = \frac{f(\mathbf{y};\theta_a)}{f(\mathbf{y};\theta_0)}> c.\]
\[f(\mathbf{y};\theta_a) - cf(\mathbf{y};\theta_0) > 0.\]
Define:
\[\delta(\mathbf{y}) = (\phi(\mathbf{y}) - \phi'(\mathbf{y}))(f(\mathbf{y};\theta_a)-cf(\mathbf{y};\theta_0))\]
Note that both \(\phi(\mathbf{y})\) and \(\phi'(\mathbf{y})\) are always either 1 or 0. We know the conditions under which \(\phi(\mathbf{y})\) takes on each value:
\[f(\mathbf{y};\theta_a)-cf(\mathbf{y};\theta_0) > 0 \Rightarrow \phi(\mathbf{y})=1 \Rightarrow (\phi(\mathbf{y}) - \phi'(\mathbf{y}))\ge 0 \Rightarrow \delta(\mathbf{y}) \ge 0\]
\[f(\mathbf{y};\theta_a)-cf(\mathbf{y};\theta_0) < 0 \Rightarrow \phi(\mathbf{y})=0\Rightarrow (\phi(\mathbf{y}) - \phi'(\mathbf{y})) \le 0 \Rightarrow \delta(\mathbf{y}) \ge 0\]
\[f(\mathbf{y};\theta_a)-cf(\mathbf{y};\theta_0)= 0 \Rightarrow \delta(\mathbf{y}) = 0\]
Implication: \(\delta(\mathbf{y})\ge 0\) always.
Since \(\delta(\mathbf{y})\ge 0\) always:
\[0 \le \int \delta(\mathbf{y}) d\mathbf{y} = \int(\phi(\mathbf{y}) - \phi'(\mathbf{y}))(f(\mathbf{y};\theta_a)-cf(\mathbf{y};\theta_0)) d\mathbf{y}\]
\[= \int(\phi(\mathbf{y}) - \phi'(\mathbf{y}))f(\mathbf{y};\theta_a) d\mathbf{y} - c\int(\phi(\mathbf{y}) - \phi'(\mathbf{y}))f(\mathbf{y};\theta_0) d\mathbf{y}\]
\[= E_{\theta_a}(\phi(\mathbf{y})) - E_{\theta_a}(\phi'(\mathbf{y})) - c\left[\underbrace{E_{\theta_0}(\phi(\mathbf{y})) - E_{\theta_0}(\phi'(\mathbf{y}))}_{\alpha - \alpha} \right]\]
\[= E_{\theta_a}(\phi(\mathbf{y})) - E_{\theta_a}(\phi'(\mathbf{y})) \]
\[ \therefore E_{\theta_a}(\phi'(\mathbf{y})) \le E_{\theta_a}(\phi(\mathbf{y})) \]
\[H_0: \theta = \theta_0\]
\[H_a: \theta \in \Omega_a\]
A test \(\phi(\mathbf{y})\) is said to be a uniformly most powerful (UMP) size-\(\alpha\) test if for all \(\theta \in \Omega_a\):
\[P(\phi(\mathbf{y})=1 | \theta \in \Omega_a) \geq P(\phi'(\mathbf{y})=1 | \theta \in \Omega_a),\]
for any other size-\(\alpha\) test \(\phi'(\mathbf{y})\).
\[H_0: \theta = \theta_0\] \[H_a: \theta > \theta_0,\]
or:
\[H_0: \theta = \theta_0\] \[H_a: \theta < \theta_0.\]
\[H_0: \lambda = \lambda_0\] \[H_a: \lambda > \lambda_0\]
For a value \(\lambda_a > \lambda_0\), N-P lemma says to reject when:
\[\frac{L(\lambda_a)}{L(\lambda_0)} = \frac{e^{-n\lambda_a }\lambda_a^{\sum_i y_i}/ \prod_i y_i !}{e^{-n\lambda_0 }\lambda_0^{\sum_i y_i}/ \prod_i y_i !}> c,\]
\[ \mbox{ i.e. when } e^{n(\lambda_0 - \lambda_a) }\left(\frac{\lambda_a}{\lambda_0}\right)^{\sum_i y_i}> c, \]
\[\mbox{ i.e. when }\left(\frac{\lambda_a}{\lambda_0}\right)^{\sum_i y_i}> c', \]
\[\mbox{ i.e. when }\sum_i y_i \underbrace{[\log(\lambda_a) -\log(\lambda_0)]}_{> 0}> c'', \]
\[\mbox{ i.e. when }\sum_i y_i > c'''.\]
\[\mbox{Reject the null when } \sum_i y_i \mbox{ is large}\]
depended not on the specific \(\lambda_a\) chosen, only on the fact that \(\lambda_a > \lambda_0\).
\[P_{\lambda =5}(T>c)\approx \alpha\]
Distribution of \(T \sim POI(50\cdot \lambda_0) = POI(250)\) with rejection region of 277 or larger; note mean of 250:
\[H_0: p = p_0\] \[H_a: p > p_0\]
For a specified value of \(p_a > p_0\), N-P lemma says to reject when:
\[\frac{L(p_a)}{L(p_0)} = \frac{p_a^n(1-p_a)^{\sum_i y_i}}{p_0^n(1-p_0)^{\sum_i y_i}}> c,\]
\[ \mbox{ i.e. when } \left(\frac{p_a}{p_0}\right)^n \left(\frac{1-p_a}{1-p_0}\right)^{\sum_i y_i}> c, \]
\[\mbox{ i.e. when } \left(\frac{1-p_a}{1-p_0}\right)^{\sum_i y_i}> c', \]
\[\mbox{ i.e. when }\sum_i y_i \cdot\underbrace{\log\left(\underbrace{\frac{1-p_a}{1-p_0}}_{<1}\right)}_{<0}> c'', \]
\[\mbox{ i.e. when }\sum_i y_i < c'''.\]
\[\mbox{Reject the null when } \sum_i y_i \mbox{ is small}\]
depended not on the specific \(p_a\) chosen, only on the fact that \(p_a > p_0\).
\[P_{p =5}(T<c)\approx \alpha\]
Distribution of \(T \sim NB(50, p_0)\) with rejection region of 34 or smaller:
\[H_0: \lambda = 1/5\] \[H_a: \lambda < 1/5.\]
For a specified value of \(\lambda_a < \lambda_0\), N-P lemma says to reject when:
\[\frac{L(\lambda_a)}{L(\lambda_0)} = \frac{\lambda_a^n e^{-\lambda_a\sum_i y_i}}{\lambda_0^ne^{-\lambda_0\sum_i y_i}}> c,\]
\[ \mbox{ i.e. when } e^{\underbrace{(\lambda_0-\lambda_a)}_{>0}\sum_i y_i}> c', \]
\[\mbox{ i.e. when } \sum_i y_i \mbox{ is large}. \]
Since the form of this test depended not on the specific \(\lambda_a\) chosen, only on the fact that \(\lambda_a < \lambda_0\), it is UMP for alternatives of the form \(H_a: \lambda < \lambda_0\).
cv <- qgamma(0.95, shape = n, rate = 1/5); has size exactly \(\alpha= 0.05\).1-pgamma(cv, shape = n, rate = lambda_a)Code for finding the analytic rejection probabilities for these two tests:
library(purrrfect)
library(tidyverse)
lambda_0 = 1/5
(two_rate_tests <- parameters(~lambda_true, ~n,
seq(0.001, 0.2, l=100), c(10, 20, 40, 80))
%>% mutate(crit_value_min = qexp(0.95, rate = n*lambda_0),
crit_value_sum = qgamma(0.95, shape = n, rate = lambda_0),
prob_min_rejects = 1-pexp(crit_value_min, rate = n*lambda_true),
prob_sum_rejects = 1-pgamma(crit_value_sum, shape = n, rate = lambda_true)
)
) %>% head # A tibble: 6 × 6
lambda_true n crit_value_min crit_value_sum prob_min_rejects prob_sum_rejects
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 0.001 10 1.50 78.5 0.985 1
2 0.001 20 0.749 139. 0.985 1
3 0.001 40 0.374 255. 0.985 1
4 0.001 80 0.187 476. 0.985 1
5 0.00301 10 1.50 78.5 0.956 1.000
6 0.00301 20 0.749 139. 0.956 1
ggplot(data = two_rate_tests) +
geom_line(aes(x = lambda_true, y = prob_min_rejects, col = 'Test based on min')) +
geom_line(aes(x = lambda_true, y = prob_sum_rejects, col = 'Test based on sum')) +
facet_wrap(~n, labeller = label_both)+
scale_y_continuous(breaks = c(0.05, seq(0.25, 1, by = 0.25)))+
geom_hline(aes(yintercept= 0.05), linetype = 2) +
theme_classic() +
labs(x=expression(lambda[true]),
y='P(reject null)', color='')