axjack's blog

### axjack is said to be an abbreviation for An eXistent JApanese Cool Klutz ###

統計学実践ワークブック 第12章 一般の分布に関する検定法 p.92 の尤度比検定を用いる場合の棄却域 を導出する

母比率の検定に関する話題で統計学実践ワークブックp.91は二項分布から話が始まる。そしてp.92にて尤度比検定の話となるが、導出過程は書いていなかったので自力で導出してみることにした。なお以下、二項分布ではなくベルヌーイ分布を用いるのは計算のしやすさとわかりやすさからである。

ベルヌーイ分布に従うn個の確率変数から最尤推定量を求める

尤度関数を立式する

 \displaystyle  X_1,\cdots, X_n は独立にベルヌーイ分布 Bern(\theta) に従う確率変数であるとする。X_iは確率θで1を確率1-θで0の値を取る。このとき尤度関数は\displaystyle L(\theta) = P(X_1) P(X_2) \cdots P(X_n) となる但し\displaystyle P(X_i ) = \theta^{X_i}(1-\theta)^{1-X_i} である。

尤度関数を変形すると、

\displaystyle L(\theta) = P(X_1) P(X_2) \cdots P(X_n)

\displaystyle =  \theta^{X_1}(1-\theta)^{1-X_1}  \theta^{X_2}(1-\theta)^{1-X_2}  \cdots \theta^{X_n}(1-\theta)^{1-X_n}

\displaystyle =  \theta^{X_1 + X_2 + \cdots + X_n} (1-\theta)^{n - ( X_1 + X_2 + \cdots + X_n)  }

\displaystyle =  \theta^{n \bar{X} } (1-\theta)^{n - n\bar{X} }

が得られる(\displaystyle  \bar{X}  = \frac{1}{n} \sum X_i )。

最尤推定量を求める

さてここで最尤推定量を求めたいので、

  • 尤度関数の対数すなわち対数尤度関数 logL(\theta)
  • \theta偏微分
  • それを0とおいたものを\thetaについて解く

という手順を踏もう。

対数尤度関数

\displaystyle log L(\theta) =  log \Big(   \theta^{n \bar{X} } (1-\theta)^{n - n\bar{X} } \Big)

\displaystyle  =  log \Big(   \theta^{n \bar{X} }   \Big)  + log \Big(   (1-\theta)^{n - n\bar{X} }   \Big)

\displaystyle  =   n \bar{X}  \ log(\theta)   +  (  {n - n\bar{X} }  )  \ log (1-\theta)

対数尤度関数をθで偏微分

\displaystyle  \frac{\partial }{\partial \theta } log L(\theta)=    \frac{\partial }{\partial \theta }  \Big(  n \bar{X}  \ log(\theta)   +  (  {n - n\bar{X} }  )  \ log (1-\theta)  \Big)

\displaystyle  =   n \bar{X}  \frac{1}{\theta}   +  (  {n - n\bar{X} }  )  \frac{-1}{1 - \theta}

対数尤度関数をθで偏微分 = 0 をθについて解く

\displaystyle   \frac{\partial}{\partial \theta} log L(\theta) = 0

 \displaystyle \iff  n \bar{X}  \frac{1}{\theta}   +  (  {n - n\bar{X} }  )  \frac{-1}{1 - \theta} = 0

 \displaystyle \iff  n \bar{X}  (1 - \theta)  +  (  n\bar{X}  - n   )  \theta  = 0

 \displaystyle \iff  n \bar{X}  - n \bar{X}  \theta  +   n\bar{X} \theta  - n \theta   = 0

 \displaystyle \iff  n \bar{X}   - n \theta   = 0

 \displaystyle \iff  \theta   =  \bar{X}  \ ( = \hat{  \theta  }  )

となって、最尤推定 \displaystyle \hat{\theta}  = \bar{X}  を得る。

尤度比のお気持ち

今回のポイントはここである。

f:id:axjack:20220317214013j:plain

尤度比は

  •  max \ L(\theta; H_0)帰無仮説のもとでの尤度関数の最大値
  •  max \ L(\theta; H_1) :対立仮説のもとでの尤度関数の最大値

を使って、

 \displaystyle \lambda(X) = \frac{max \ L(\theta; H_1)}{max \ L(\theta; H_0)}

と表される統計量である。正確性を『超』度外視すれば*1

  •  max \ L(\theta; H_0)帰無仮説のもとでの尤度関数の最大値
    • ⇒ 尤度関数の \theta 帰無仮説で与えられている \theta_0を代入したもの
  •  max \ L(\theta; H_1) :対立仮説のもとでの尤度関数の最大値
    • ⇒ 尤度関数の \theta最尤推定 \hat{ \theta }を代入したもの

を使って、

\displaystyle \lambda(X) = \frac{L( \theta = \hat{\theta} )}{ L( \theta = \theta_0 )}

となる。

実際に尤度比を求めてみる

\displaystyle \lambda(X) = \frac{L( \theta = \hat{\theta} )}{ L( \theta = \theta_0 )}

 \displaystyle  =
  \frac{    \hat{\theta}^{n \bar{X}}(1-\hat{\theta})^{n - n\bar{X} }}
          {    {\theta_0}^{n \bar{X}}(1-{\theta_0})^{n - n\bar{X} }}

尤度比から対数尤度比の2倍(逸脱度)を求める

対数尤度比の2倍: 2 log \lambda(X) 逸脱度*2 という名前がついているらしい。では以下にて逸脱度を計算すると、

 \displaystyle 2 log \lambda(X)  =  2 log \Big(  \frac{    \hat{\theta}^{n \bar{X}}(1-\hat{\theta})^{n - n\bar{X} }}   {    {\theta_0}^{n \bar{X}}(1-{\theta_0})^{n - n\bar{X} }}  \Big)

 \displaystyle  =  2 log \Big(    \Big(  \frac{ \hat{\theta} }{\theta_0}\Big)  ^{n \bar{X}}    \Big( \frac{(1-\hat{\theta})}{(1-\theta_0)}\Big)^{n - n\bar{X}} \Big)

 \displaystyle  =  2 n\Big(  \bar{X} log \Big(  \frac{ \hat{\theta} }{\theta_0}\Big)   +  (1-\bar{X})log\Big( \frac{1-\hat{\theta}}{1-\theta_0}  \Big)     \Big)

ここで、 \hat{\theta}  = \bar{X} より

 \displaystyle  =  2 n\Big(  \hat{\theta}  log \Big(  \frac{ \hat{\theta} }{\theta_0}\Big)   +  (1- \hat{\theta} )log\Big( \frac{1-\hat{\theta}}{1-\theta_0}  \Big)     \Big)

となってp.92 の尤度比検定を用いる場合の棄却域を得ることができた。

*1: (言い訳)勉強中ゆえ自信がないため

*2:統計学実践ワークブック、平均・分散から始める一般化線形モデル入門、一般化線形モデル入門などを参照

axjack is said to be an abbreviation for An eXistent JApanese Cool Klutz.