跳至主要内容

Likelihood Ratio Test(LRT)

Recall: L(θ;x~)=f(x~;θ)L(\theta;\utilde{x})=f(\utilde{x};\theta) a function of θ\theta given x~\utilde{x}. 在 θ\theta 下出現當前樣本的機率。

Note: MP test rejects H0=θ=θ0H_0=\theta=\theta_0 if

f(x~;θ1)>cf(x~;θ0)    L(θ1;x~)>cL(θ0;x~)    L(θ0;x~)L(θ1;x~)<1c=c    L(θ0;x~)max{L(θ0;x~),L(θ1;x~)}<ksome k[0,1]={L(θ0;x~)L(θ1;x~)if L(θ1;x~)L(θ0;x~)1if L(θ1;x~)<L(θ0;x~)    supθω0L(θ;x~)supθΩL(θ;x~)<kΩ=ω0ω1 and ω0={θ0},ω1={θ1}\begin{align*} &f(\utilde{x};\theta_1)>c\cdot f(\utilde{x};\theta_0)\\ \iff &L(\theta_1;\utilde{x})>c\cdot L(\theta_0;\utilde{x})\\ \iff &\frac{L(\theta_0;\utilde{x})}{L(\theta_1;\utilde{x})}<\frac{1}{c}=c'\\ \iff &\frac{L(\theta_0;\utilde{x})}{\max\set{L(\theta_0;\utilde{x}), L(\theta_1;\utilde{x})}}<k\quad\text{some } k\in[0,1]\\ &=\begin{cases} \frac{L(\theta_0;\utilde{x})}{L(\theta_1;\utilde{x})} &\text{if } L(\theta_1;\utilde{x}) \ge L(\theta_0;\utilde{x})\\ 1 &\text{if } L(\theta_1;\utilde{x})<L(\theta_0;\utilde{x}) \end{cases}\\ \iff &\frac{\sup_{\theta\in\omega_0 L(\theta;\utilde{x})}}{\sup_{\theta\in\Omega L(\theta;\utilde{x})}}<k \quad \Omega=\omega_0\cup\omega_1\text{ and } \omega_0=\set{\theta_0}, \omega_1=\set{\theta_1} \end{align*}
Definition
  1. For testing H0:θω0H_0:\theta\in\omega_0 v.s. H1:θω1H_1:\theta\in\omega_1, a LRT is a test which ϕ\phi rejects H0H_0 if λ(x~)<k\lambda(\utilde{x})<k with k[0,1] and λ(x~)=supθω0L(θ;x~)supθΩL(θ;x~) where Ω=ω0ω1\text{with }k\in[0,1]\text{ and }\lambda(\utilde{x})=\frac{\sup_{\theta\in\omega_0}L(\theta;\utilde{x})}{\sup_{\theta\in\Omega}L(\theta;\utilde{x})}\text{ where }\Omega=\omega_0\cup\omega_1
  2. A level α\alpha LRT     \implies k is determined by supθω0Eθϕ(x~)=α\sup_{\theta\in\omega_0}E_\theta\phi(\utilde{x})=\alpha

EX Xf(x;θ)X\sim f(x;\theta)

H0:θ{θ1,θ2} v.s. H1:θ{θ3,θ4}H_0:\theta\in\set{\theta_1,\theta_2} \text{ v.s. }H_1:\theta\in\set{\theta_3,\theta_4}

with level 0.05

x23456789101112
θ1\theta_1(0.01)(0.01)(0.01)(0.01)(0.01)(0.01)(0.01)(0.01)(0.01)(0.01)0.90
θ2\theta_2(0.01)0.0090.0080.0070.0060.0050.0060.0070.0080.009[(0.925)]
θ3\theta_30.20[0.10][0.09]0.080.060.05[0.07]0.050.05[0.05]0.20
θ4\theta_4[0.26][0.10][0.09][0.11][0.07][0.08][0.07][0.06][0.06][0.05]0.05
λ=\lambda=126\frac{1}{26}110\frac{1}{10}19\frac{1}{9}111\frac{1}{11}17\frac{1}{7}18\frac{1}{8}17\frac{1}{7}16\frac{1}{6}16\frac{1}{6}15\frac{1}{5}11
λ(x)=supθω0L(θ;x)supθΩL(θ;x)<k    k=17i.e. x=2,3,4,5,7\lambda(x)=\frac{\sup_{\theta\in\omega_0}L(\theta;x)}{\sup_{\theta\in\Omega}L(\theta;x)}<k\implies k=\frac{1}{7}\quad\text{i.e. }x=2,3,4,5,7 Pθ1(x=2 or 3 or 4 or 5 or 7)=0.05P_{\theta_1}(x=2\text{ or }3\text{ or }4\text{ or }5\text{ or }7)=0.05

Note:

  1. Let θΩ^=argsupθΩL(θ;x~),θω0^=argsupθω0L(θ;x~)\widehat{\theta_\Omega}=\arg\sup_{\theta\in\Omega}L(\theta;\utilde{x}), \widehat{\theta_{\omega_0}}=\arg\sup_{\theta\in\omega_0}L(\theta;\utilde{x})

        λ(x~)=supθω0L(θ;x)supθΩL(θ;x)=L(θω0^;x~)L(θΩ^;x~)\implies\lambda(\utilde{x})=\frac{\sup_{\theta\in\omega_0}L(\theta;x)}{\sup_{\theta\in\Omega}L(\theta;x)}=\frac{L(\widehat{\theta_{\omega_0}};\utilde{x})}{L(\widehat{\theta_\Omega};\utilde{x})}
  2. T=T(X~)T=T(\utilde{X}) is sufficient for θ\theta     f(x~;θ)=g(t;θ)h(x~)\implies f(\utilde{x};\theta)=g(t;\theta)h(\utilde{x})

    如果最大值發生在 ω0\omega_0,那麼 λ(x~)=1\lambda(\utilde{x})=1;如果最大值發生在 ω1\omega_1,那麼 ω0\omega_0 的最大值會發生在邊界 (ω0)\partial(\omega_0) 上。

    λ(x~)=g(t;θω0^)g(t;θΩ^)={1if θΩ^ω0g(t;(ω0))g(t;θΩ^)if θΩ^ω1 \begin{align*} \lambda(\utilde{x})&=\frac{g(t;\widehat{\theta_{\omega_0}})}{g(t;\widehat{\theta_\Omega})}\\ &=\begin{cases} 1 &\text{if } \widehat{\theta_\Omega}\in\omega_0\\ \frac{g(t;\partial(\omega_0))}{g(t;\widehat{\theta_\Omega})} &\text{if } \widehat{\theta_\Omega}\in\omega_1 \end{cases} \end{align*}

EX: X1,,XniidN(θ,σ02)X_1, \cdots, X_n\overset{\text{iid}}{\sim} N(\theta, \sigma^2_0), to test

H0:θ=θ0 v.s. H1:θθ0H_0:\theta=\theta_0\quad\text{ v.s. }\quad H_1:\theta\ne\theta_0

note that ω0={θ0}    θω0^=θ0\omega_0=\set{\theta_0}\implies\widehat{\theta_{\omega_0}}=\theta_0 and Ω={θ0}{θ:θθ}=R    θΩ^=xˉ\Omega=\set{\theta_0}\cup\set{\theta:\theta\neq\theta}=\R\implies\widehat{\theta_\Omega}=\bar{x} 因為 xˉ\bar{x} 是平均的 MLE。

    \implies reject H0H_0

    λ(x~)=L(θ0;x~)L(xˉ;x~)<k    exp(n(xˉθ0)22σ02)<k    n(xˉθ0)22σ02<lnk    n(xˉθ0)22σ02>C    n(xˉθ0)σ0>D\begin{align*} \iff &\lambda(\utilde{x})=\frac{L(\theta_0;\utilde{x})}{L(\bar{x};\utilde{x})}<k\\ \iff&\exp\left(-\frac{n(\bar{x}-\theta_0)^2}{2\sigma^2_0}\right)<k'\\ \iff&-\frac{n(\bar{x}-\theta_0)^2}{2\sigma^2_0}<\ln k'\\ \iff&\frac{n(\bar{x}-\theta_0)^2}{2\sigma^2_0}>C\\ \iff& \left|\frac{\sqrt{n}(\bar{x}-\theta_0)}{\sigma_0}\right|>D \end{align*}

and

α=Pθ0(n(xˉθ0)σ0>D)=P(Z>D)\alpha=P_{\theta_0}\left(\left|\frac{\sqrt{n}(\bar{x}-\theta_0)}{\sigma_0}\right|>D\right)=P(|Z|>D)

I.e., A level α\alpha LRT is reject H0H_0 if n(xˉθ0)σ0>Zα/2|\frac{\sqrt{n}(\bar{x}-\theta_0)}{\sigma_0}|>Z_{\alpha/2}


EX: X1,,XniidN(θ,σ2)X_1, \cdots, X_n\overset{\text{iid}}{\sim}N(\theta, \sigma^2) with θ,σ2\theta, \sigma^2 are both unknown.

To testH0:θ=θ0H_0:\theta=\theta_0 v.s. H1:θθ0H_1:\theta\neq\theta_0

ω0={(θ,σ2):θ=θ0,σ2>0}    θω0^=θ0,σω02^=1ni=1n(xiθ0)2\omega_0=\set{(\theta, \sigma^2):\theta=\theta_0, \sigma^2>0}\implies \widehat{\theta_{\omega_0}}=\theta_0, \widehat{\sigma^2_{\omega_0}}=\frac{1}{n}\sum_{i=1}^n(x_i-\theta_0)^2 Ω={(θ,σ2):θθ0,σ2>0}    θΩ^=xˉ,σΩ2^=1ni=1n(xixˉ)2\Omega=\set{(\theta, \sigma^2):\theta\neq\theta_0, \sigma^2>0}\implies \widehat{\theta_\Omega}=\bar{x}, \widehat{\sigma^2_\Omega}=\frac{1}{n}\sum_{i=1}^n(x_i-\bar{x})^2 L(θω0^,σω02^;x~)=(12πσω02^)n/2exp(12σω02^i=1n(xiθ0)2)=(12π)n/2(1σω02^)n/2exp(n2)L(θΩ^,σΩ2^;x~)=(12πσΩ2^)n/2exp(12σΩ2^i=1n(xixˉ)2)=(12π)n/2(1σΩ2^)n/2exp(n2)\begin{align*} &\begin{align*} L(\widehat{\theta_{\omega_0}}, \widehat{\sigma^2_{\omega_0}};\utilde{x})&=\left(\frac{1}{2\pi\widehat{\sigma^2_{\omega_0}}}\right)^{n/2}\exp\left(-\frac{1}{2\widehat{\sigma^2_{\omega_0}}}\sum_{i=1}^n(x_i-\theta_0)^2\right)\\ &=\left(\frac{1}{2\pi}\right)^{n/2}\left(\frac{1}{\widehat{\sigma^2_{\omega_0}}}\right)^{n/2}\exp\left(-\frac{n}{2}\right) \end{align*}\\ &\begin{align*} L(\widehat{\theta_\Omega}, \widehat{\sigma^2_\Omega};\utilde{x})&=\left(\frac{1}{2\pi\widehat{\sigma^2_\Omega}}\right)^{n/2}\exp\left(-\frac{1}{2\widehat{\sigma^2_\Omega}}\sum_{i=1}^n(x_i-\bar{x})^2\right)\\ &=\left(\frac{1}{2\pi}\right)^{n/2}\left(\frac{1}{\widehat{\sigma^2_\Omega}}\right)^{n/2}\exp\left(-\frac{n}{2}\right) \end{align*} \end{align*} reject H0    λ(x~)=L(θω0^,σω02^;x~)L(θΩ^,σΩ2^;x~)=(σΩ2^σω02^)n/2<k    (i=1n(xixˉ)2i=1n(xiθ0)2)n/2<k    (xixˉ)2(xixˉ+xˉθ0)2=(xixˉ)2(xixˉ)2+n(xˉθ0)2=11+n(xˉθ0)2(xixˉ)2<k    n(xˉθ0)2(xixˉ)2n1>C    n(xˉθ0)2s2>CXˉN(θ,σ2/n)(n1)S2σ2χn12    n(xˉθ0)s>Dn(xˉθ0)stn1\begin{align*} \text{reject }H_0&\iff\lambda(\utilde{x})=\frac{L(\widehat{\theta_{\omega_0}}, \widehat{\sigma^2_{\omega_0}};\utilde{x})}{L(\widehat{\theta_\Omega}, \widehat{\sigma^2_\Omega};\utilde{x})}=\left(\frac{\widehat{\sigma^2_\Omega}}{\widehat{\sigma^2_{\omega_0}}}\right)^{n/2}<k\\ &\iff\left(\frac{\sum_{i=1}^n(x_i-\bar{x})^2}{\sum_{i=1}^n(x_i-\theta_0)^2}\right)^{n/2}<k\\ &\iff\frac{\sum(x_i-\bar{x})^2}{\sum(x_i-\bar{x}+\bar{x}-\theta_0)^2}=\frac{\sum(x_i-\bar{x})^2}{\sum(x_i-\bar{x})^2+n(\bar{x}-\theta_0)^2}=\frac{1}{1+\frac{n(\bar{x}-\theta_0)^2}{\sum(x_i-\bar{x})^2}}<k'\\ &\iff\frac{n(\bar{x}-\theta_0)^2}{\frac{\sum(x_i-\bar{x})^2}{n-1}}>C\\ &\iff\frac{n(\bar{x}-\theta_0)^2}{s^2}>C\qquad \bar{X}\sim N(\theta, \sigma^2/n)\perp \frac{(n-1)S^2}{\sigma^2}\sim\chi^2_{n-1}\\ &\iff\left|\frac{\sqrt{n}(\bar{x}-\theta_0)}{s}\right|>D \qquad \left|\frac{\sqrt{n}(\bar{x}-\theta_0)}{s}\right| \sim t_{n-1} \end{align*}

I.e. a level α\alpha LRT is reject H0H_0 if n(xˉθ0)s>tn1,α/2|\frac{\sqrt{n}(\bar{x}-\theta_0)}{s}|>t_{n-1,\alpha/2}


EX: X1,,Xniidf(x;θ)=e(xθ),xθX_1, \cdots, X_n\overset{\text{iid}}{\sim}f(x;\theta)=e^{-(x-\theta)}, x\ge\theta

A level α\alpha for H0:θθ0H_0:\theta\le\theta_0 v.s. H1:θ>θ0H_1:\theta>\theta_0

Note L(θ;x~)=i=1n(e(xiθ)I(xiθ))=exienθI(x(1)θ)L(\theta;\utilde{x})=\prod_{i=1}^n\left(e^{-(x_i-\theta)}I(x_i\ge\theta)\right)=e^{-\sum x_i}e^{n\theta}I(x_{(1)}\ge\theta).

θx(1)\theta\le x_{(1)} 時,L(θ;x~)L(\theta;\utilde{x}) 是沿著 θ\theta 遞增的,而在 θ>x(1)\theta>x_{(1)} 時,L(θ;x~)=0L(\theta;\utilde{x})=0。如果 θ0>x1\theta_0>x_{1},那麼在 θ<θ0\theta<\theta_0 的範圍內,L(θ=x(1),x~)L(\theta=x_{(1)},\utilde{x}) 會是最大值。如果 θ0x(1)\theta_0\le x_{(1)},那麼 L(θ0,x~)L(\theta_0,\utilde{x}) 會是最大值。

    supθθ0L(θ;x~)={exienx(1)if θ0>x(1)exienθ0if θ0x(1)    supθΩL(θ;x~)=exienx(1)\begin{align*} &\implies\sup_{\theta\le\theta_0}L(\theta;\utilde{x})=\begin{cases} e^{-\sum x_i}e^{nx_{(1)}} &\text{if }\theta_0 > x_{(1)}\\ e^{-\sum x_i}e^{n\theta_0} &\text{if }\theta_0\le x_{(1)} \end{cases}\\ &\implies\sup_{\theta\in\Omega}L(\theta;\utilde{x})=e^{-\sum x_i}e^{nx_{(1)}}\\ \end{align*}

    \implies LRT is reject H0H_0 if

λ(x~)=supθθ0L(θ;x~)supθΩL(θ;x~)={1if θ0>x(1)en(θ0x(1))if θ0x(1)<k(0,1)    en(θ0x(1))<kand θ0x(1)    θ0c<x(1)\begin{align*} &\lambda(\utilde{x})=\frac{\sup_{\theta\le\theta_0}L(\theta;\utilde{x})}{\sup_{\theta\in\Omega}L(\theta;\utilde{x})}=\begin{cases} 1 &\text{if }\theta_0>x_{(1)}\\ e^{n(\theta_0-x_{(1)})} &\text{if }\theta_0\le x_{(1)} \end{cases}<k\in(0,1)\\ \iff & e^{n(\theta_0-x_{(1)})}<k\quad\text{and }\theta_0\le x_{(1)}\\ \iff & \theta_0\le c < x_{(1)} \end{align*} α=Pθ0(X(1)>c)=(Pθ0(X1>c))n=(ce(xθ0)dx)n=(e(cθ0))n=en(θ0c)\begin{align*} \alpha&=P_{\theta_0}(X_(1)>c)\\ &=\left(P_{\theta_0}(X_1>c)\right)^n\\ &=\left(\int_c^\infty e^{-(x-\theta_0)}dx\right)^n\\ &=\left(e^{-(c-\theta_0)}\right)^n\\ &=e^{n(\theta_0-c)}\\ \end{align*}     c=θ0lnαn>θ0\implies c = \theta_0-\frac{\ln\alpha}{n} > \theta_0

這與我們用 MLR 得到的 UMP test 是一樣的。


EX:

<X1,,Xniidθ1eθ1x,x>0Y1,,Ymiidθ2eθ2y,y>0\perp\Big < \begin{align*} X_1, \cdots, X_n\overset{\text{iid}}{\sim}\theta_1e^{-\theta_1x}, x>0\\ Y_1, \cdots, Y_m\overset{\text{iid}}{\sim}\theta_2e^{-\theta_2y}, y>0 \end{align*} L(θ1,θ2;x~,y~)=fX~(x~;θ1)fY~(y~;θ2)=θ1neθ1xiθ2meθ2yiL(\theta_1, \theta_2;\utilde{x}, \utilde{y})=f_{\utilde{X}}(\utilde{x};\theta_1)\cdot f_{\utilde{Y}}(\utilde{y};\theta_2)=\theta_1^ne^{-\theta_1\sum x_i}\cdot\theta_2^me^{-\theta_2\sum y_i} ω0={(θ1,θ2);θ1=θ2>0}Ω={(θ1,θ2);θ1>0,θ2>0}\omega_0=\set{(\theta_1, \theta_2);\theta_1=\theta_2>0}\qquad\Omega=\set{(\theta_1, \theta_2);\theta_1>0, \theta_2>0}

Note

WθkeθwilnWklnθθwi    θ(klnθθwi)=0    kθwi=0    θ=kwi=1Wˉ\begin{align*} &W\sim\theta^ke^{-\theta \sum w_i}\qquad\ln W\sim k\ln\theta-\theta\sum w_i\\ \implies&\frac{\partial}{\partial\theta}(k\ln\theta-\theta\sum w_i)=0\implies\frac{k}{\theta}-\sum w_i=0\implies\theta=\frac{k}{\sum w_i}=\frac{1}{\bar{W}} \end{align*}

ω0\omega_0

L(θ1,θ2,x~,y~)=L(θ,θ;x~,y~)=θn+meθ(xi+yi)    θω0^=n+mi=1nxi+i=1myi    L(θω0^,θω0^;x~,y~)=(n+mi=1nxi+i=1myi)n+me(n+m)\begin{align*} &L(\theta_1, \theta_2, \utilde{x}, \utilde{y})=L(\theta, \theta;\utilde{x}, \utilde{y})=\theta^{n+m}e^{-\theta(\sum x_i+\sum y_i)}\\ \implies&\widehat{\theta_{\omega_0}}=\frac{n+m}{\sum_{i=1}^{n}x_i+\sum_{i=1}^{m}y_i}\\ \implies&L(\widehat{\theta_{\omega_0}}, \widehat{\theta_{\omega_0}};\utilde{x}, \utilde{y})=\left(\frac{n+m}{\sum_{i=1}^{n}x_i+\sum_{i=1}^{m}y_i}\right)^{n+m}e^{-(n+m)}\\ \end{align*}

Ω\Omega

L(θΩ^,θΩ^;x~,y~)=(ni=1nxi)n(mi=1myi)menemL(\widehat{\theta_{\Omega}}, \widehat{\theta_{\Omega}};\utilde{x}, \utilde{y})=\left(\frac{n}{\sum_{i=1}^{n}x_i}\right)^n\left(\frac{m}{\sum_{i=1}^{m}y_i}\right)^me^{-n}e^{-m}

    \implies LRT is reject H0H_0 if

k>λ(x~,y~)=L(θω0^,θω0^;x~,y~)L(θΩ^,θΩ^;x~,y~)=(n+mxi+yi)n+m(xin)n(yim)men+m=(xixi+yi=T(0,1))n(yixi+yi=1T)m(n+m)n+m1nn1mm    Tn(1T)m<c    T<k1 or T>k2\begin{align*} &\begin{align*} k>\lambda(\utilde{x}, \utilde{y})&=\frac{L(\widehat{\theta_{\omega_0}}, \widehat{\theta_{\omega_0}};\utilde{x}, \utilde{y})}{L(\widehat{\theta_{\Omega}}, \widehat{\theta_{\Omega}};\utilde{x}, \utilde{y})}\\ &=\left(\frac{n+m}{\sum x_i+\sum y_i}\right)^{n+m}\left(\frac{\sum x_i}{n}\right)^n\left(\frac{\sum y_i}{m}\right)^me^{n+m}\\ &=\left(\underbrace{\frac{\sum x_i}{\sum x_i+\sum y_i}}_{=T\in(0,1)}\right)^n\left(\underbrace{\frac{\sum y_i}{\sum x_i+\sum y_i}}_{=1-T}\right)^m(n+m)^{n+m}\frac{1}{n^n}\frac{1}{m^m}\\ \end{align*}\\ \iff& T^n(1-T)^m<c\\ \iff& T<k_1\text{ or }T>k_2 \end{align*}

Note Xexp(θ1)=dGamma(1,1θ1)    nxiG(n,1θ1)    2θ1nxiG(n,2)=dχ2n2X\sim \exp(\theta_1)\xlongequal{\text{d}}\text{Gamma}(1, \frac{1}{\theta_1})\implies\sum^n x_i\sim \text{G}(n,\frac{1}{\theta_1})\implies 2\theta_1\sum^n x_i\sim\text{G}(n,2)\xlongequal{\text{d}}\chi^2_{2n}

T=xixi+yi=2θxi2θxi+2θyi=11+2θmy/2m2θnx/2nmnwhere 2θmy/2m2θnx/2n=dχ2m2/2mχ2n2/2nF2m,2n\begin{align*} T&=\frac{\sum x_i}{\sum x_i+\sum y_i}=\frac{2\theta\sum x_i}{2\theta\sum x_i+2\theta\sum y_i}\\ &=\frac{1}{1+\frac{2\theta\sum^m y/2m}{2\theta\sum^n x/2n}\frac{m}{n}}\quad\text{where }\frac{2\theta\sum^m y/2m}{2\theta\sum^n x/2n}\xlongequal{\text{d}}\frac{\chi^2_{2m}/2m}{\chi^2_{2n}/2n}\sim F_{2m, 2n} \end{align*}     T<k1 or T>k2    YˉXˉ<C1 or YˉXˉ>C2\implies T<k_1\text{ or }T>k_2\iff \frac{\bar{Y}}{\bar{X}}<C_1 \text{ or }\frac{\bar{Y}}{\bar{X}}>C_2

I.e. LRT is reject H_0 at level α\alpha if YˉXˉ<F2m,2n,1α/2\frac{\bar{Y}}{\bar{X}}<F_{2m,2n,1-\alpha/2} or YˉXˉ>F2m,2n,α/2\frac{\bar{Y}}{\bar{X}}>F_{2m,2n,\alpha/2}