Hypothesis testing
A hypothesis is an assumption about the distribution of the data $X$.
A simple hypothesis specifies the distribution of $X$ completely (e.g. parameter is a fixed value), and otherwise it is composite.
-
A test for a null hypothesis $H_0$ against an alternative hypothesis $H_1$ is a binary-valued statistic $T(X) \in \set{0,1}$, where
-
$T(X) = 1$ means we reject $H_0$ as the data contains enough evidence against $H_0$; and
-
$T(X) = 0$ means we do not reject $H_0$ as the data contains not enough evidence against $H_0$.
-
-
The power function of the test is $β(T; θ) = \prob_θ(T(X) = 1)$, the probability of rejection under $θ$.
-
The type I error rate is $β(T; θ)$ for $θ\in Θ_0$, the rate of "false rejection".
-
The type II error rate is $1-β(T; θ)$ for $θ\in Θ_1$, the rate of "false acceptance".
-
The size of the test is $\sup_{θ\in Θ_0} β(T; θ)$, the largest type I error rate.
A test $T: \mathcal{X}\to \set{0,1}$ is said to be the uniformly most powerful (UMP) size $α$ test for testing $H_0: θ\in Θ_0$ against $H_1: θ\in Θ_1$ if
-
it has size $α$, i.e. $\sup_{θ\in Θ_0} β(T, θ) = α$; and
-
for any other test $\tilde T$ with size at most $α$, we have $β(T, θ) \geq β(\tilde T, θ)$ for all $θ\in Θ_1$.
Suppose the data $X$ follows $p(x; θ)$ where $θ$ is unknown. Let $H_0$$: θ = θ_0$ and $H_1$$: θ = θ_1$ be simple hypotheses.
The likelihood ratio statistic is $$ \begin{align*} Λ(X) = \frac{L_X(θ_1)}{L_X(θ_0)} = \frac{p(X; θ_1)}{p(X; θ_0)} \end{align*} $$ where $L_X$ is the likelihood function.
A likelihood ratio test is a test of the form $$T(X) = 1_{\set{Λ(X) > c}}.$$
Suppose the data $X$ follows $p(x; θ)$ where $θ$ is unknown. Let $H_0$$: θ = θ_0$ and $H_1$$: θ = θ_1$ be simple hypotheses.
Assume $p(x; θ_0)$ and $p(x; θ_1)$ have the same support, i.e. are non-zero on the same set. Suppose there exists $c>0$ such that the likelihood ratio test $T^\ast(X) = 1_{\set{Λ(X) > c}}$ has size exactly $α$.
Then $T^\ast$ is uniformly most powerful, i.e. $T^\ast$ maximises $β(T; θ_1)$ subject to $β(T; θ_0)\leq α$.
Suppose the data $X$ follows $p(x; θ)$ where $θ$ is unknown. Let $H_0$$: θ \in Θ_0$ and $H_1$$: θ \in Θ_1$ be hypotheses.
The generalised likelihood ratio statistic is $$ \begin{align*} Λ(X) = \frac{\sup_{θ\in Θ_0 \cup Θ_1} L_X(θ)}{\sup_{θ\in Θ_0} L_X(θ)} = \frac{\sup_{θ\in Θ_0\cup Θ_1} p(X; θ)}{\sup_{θ\in Θ_0} p(X; θ)}. \end{align*} $$
A generalised likelihood ratio test is a test of the form $$ \begin{align*} T(X) = 1_{\set{Λ(X) > c}}. \end{align*} $$
Suppose $Θ_0\subseteq Θ_1$, and let $Λ(X)$ be the generalised likelihood ratio test for testing $H_0: θ\in Θ_0$ against $H_1: θ\in Θ_1\setminus Θ_0$.
Under regularity conditions, we have $$ \begin{align*} 2\log Λ(X) \xrightarrow{d} χ_{d_1-d_0}^2 \quad \text{as $n\to \infty$ under $H_0$} \end{align*} $$ where $d_1, d_0$ are the degrees of freedom (number of free parameters) of $H_1$ and $H_0$.
Let $T(X) = 1_{\set{Λ(X) > c}}$ be a test for testing $H_0: θ\in Θ_0$ against $H_1: θ\in Θ_1$.
The p-value statistic is defined as $$ \begin{align*} P = \sup_{θ\in Θ_0} \prob_θ(Λ(\tilde X) > Λ(X) \mid X) \end{align*} $$ where $\tilde X$ is an iid copy of $X$ (i.e. $\tilde X\sim p(x; θ)$ and independent of $X$).
-
If $T$ has size $α$, then $T = 1_{\set{P \leq α}}$. (Derivation)
Suppose $X\sim p(x; θ)$ where $θ\in Θ$ is unknown. Consider $T: Θ\times \mathcal{X}\to \set{0,1}$ and $I: \mathcal{X}\to \mathcal{P}(Θ)$ satisfying $$ \begin{align*} I(X) = \sb{θ\in Θ}{T(θ, X) = 0} \end{align*} $$ or equivalently $$ \begin{align*} T(θ, X) = \mathbb{1}_{\set{θ\not\in I(X)}}. \end{align*} $$
The following are equivalent:
-
$T(θ_0, X)$ is a size $α$ test for $H: θ=θ_0$ for all $θ_0\in Θ$.
-
$I(X)$ is a $(1-α)$-confidence set for $θ$.
Often for $Λ$ the generalised likelihood ratio statistic, we obtain $$ \begin{align*} 2\log Λ = 2\sum_{i} O_i \log \frac{O_i}{E_i} \end{align*} $$ where $O_i$ and $E_i$ are the observed and expected counts of $i$, satisfying $\sum_{i} O_i = \sum_{i} E_i$.
Pearson's chi-squared statistic is the approximation $$ \begin{align*} 2\log Λ \approx \sum_{i} \frac{(O_i - E_i)^2}{E_i} \end{align*} $$ valid when $(O_i - E_i)/E_i \approx 0$. (Derivation)
By Wilks' theorem, $2\log Λ \xrightarrow{d} χ^2_d$ under $H_0$ with a certain degree of freedom $d$. So the size $α$ Pearson's chi-squared test rejects $H_0$ if $$ \begin{align*} \sum_{i} \frac{(O_i - E_i)^2}{E_i} > χ^2_d(α). \end{align*} $$
Suppose $(N_1, \ldots, N_k) \sim \mathrm{Multinomial}(n; p_1, \ldots, p_k)$. Test $H_0: p=p_0(θ)$ for some $θ$ against $H_1: p_i$ unrestricted (but still $p_i\geq 0$ and $\sum_{i} p_i=1$), excluding $H_0$.
Apply Pearson's chi-squared test with $$ \begin{align*} O_i = N_i, \qquad E_i = np_{0i}(\hat θ_{\text{MLE}}), \qquad d = k-1-\op{df}(H_0). \end{align*} $$ where $\hat θ_{\text{MLE}}$ is the maximum likelihood estimator for $θ$ under $H_0$ and $\op{df}(H_0)$ is the degree of freedom of $H_0$. (Derivation)
Suppose $(X_1, Y_1), \ldots, (X_n, Y_n) \sim P$ iid, with $X_1\in (1,2,\ldots,r)$ and $Y_1\in (1,2,\ldots,c)$. Test $H_0: X_1$ and $Y_1$ are independent.
Summarise data by a contingency table with entries $N_{xy} = \sum_{i=1}^{n} \mathbb{1}_{\set{X_i = x, Y_i = y}}$. Model as $$ \begin{align*} (N_{11}, \ldots, N_{1c}, \ldots, N_{r1}, \ldots, N_{rc}) \sim \mathrm{Multinomial}(n; p_{11}, \ldots, p_{1c}, \ldots, p_{r 1}, \ldots, p_{rc}). \end{align*} $$ Now
-
$H_0$: $p_{xy} = p_{x+} p_{+y}$ where $p_{x+}, p_{+y}\geq 0$, $\sum_{x} p_{x+} = 1 = \sum_{y} p_{+y}$
-
$H_1$: $p_{xy}$ unrestricted (but still $p_{xy} \geq 0$, $\sum_{x,y} p_{xy} = 1$), excluding $H_0$.
Apply Pearson's chi-squared test with $$ \begin{align*} O_{xy} = N_{xy}, \qquad E_{xy} = \frac{N_{x+} N_{+y}}{n}, \qquad d=(r-1)(c-1). \end{align*} $$ (Derivation)
Now for each row $x$, we make a fixed number $n_x$ of samples. Model as $$ \begin{align*} (N_{x1}, \ldots, N_{xc}) \sim \mathrm{Multinomial}(n_x; p_{1\mid x}, \ldots, p_{c\mid x}). \end{align*} $$ Test $H_0:p_{y\mid x}$ does not depend on $x$ against $H_1: p_{y\mid x}$ unrestricted (but still $p_{y\mid x}\geq 0$ and $\sum_{y} p_{y\mid x} = 1$), excluding $H_0$.
The test is the same as the test for independence. (Derivation)