一个一元二分类Logistic回归参数解析解的推导
极大似然函数为
\[L(\alpha,\beta) = (\dfrac{\exp(\alpha+\beta)}{1+\exp(\alpha+\beta)})^a(\dfrac{\exp(\alpha)}{1+\exp(\alpha)})^b(\dfrac{\,1\,}{1+\exp(\alpha+\beta)})^c(\dfrac{\,1\,}{1+\exp(\alpha)})^d\quad(1)
\]
取自然对数为
\[\ln L(\alpha,\beta) = a(\alpha+\beta-\ln(1+\exp(\alpha+\beta)))+b(\alpha-\ln(1+\exp(\alpha)))-c\ln(1+\exp(\alpha+\beta))-d\ln(1+\exp(\alpha))^d\quad(2)
\]
分别关于 \(\alpha,\beta\) 求偏导,得对数似然方程组
\[\begin{cases}
\dfrac{\text{d}\ln L}{\text{d}\alpha} = a-a\dfrac{\exp(\alpha+\beta)}{1+\exp(\alpha+\beta)}+b-b\dfrac{\exp(\alpha)}{1+\exp(\alpha)}-c\dfrac{\exp(\alpha+\beta)}{1+\exp(\alpha+\beta)}-d\dfrac{\exp(\alpha)}{1+\exp(\alpha)}=0 \quad (3.1)\\
\dfrac{\text{d}\ln L}{\text{d}\beta} = a-a\dfrac{\exp(\alpha+\beta)}{1+\exp(\alpha+\beta)}-c\dfrac{\exp(\alpha+\beta)}{1+\exp(\alpha+\beta)}=0\quad (3.2)\\
\end{cases}\]
由 \((3.2)\) 可得$$\dfrac{\exp(\alpha+\beta)}{1+\exp(\alpha+\beta)}=\dfrac{a}{a+c},\quad(4)$$
代入 \((3.1)\) 可得
\[a-a\dfrac{a}{a+c}+b-b\dfrac{\exp(\alpha)}{1+\exp(\alpha)}-c\dfrac{a}{a+c}-d\dfrac{\exp(\alpha)}{1+\exp(\alpha)}=0
\]
整理可得$$\dfrac{\exp(\alpha)}{1+\exp(\alpha)} = \dfrac{b}{b+d}\quad(5)$$
即
\[b+b\exp(\alpha) = b\exp(\alpha)+d\exp(\alpha),
\]
亦即 $$\exp(\alpha) = \dfrac{,b,}{d},\quad(6)$$
故$$\alpha = \ln(\dfrac{b}{d}).$$
由 \((4)\) 可得$$a\exp(\alpha+\beta)+c\exp(\alpha+\beta) = a+a \exp(\alpha+\beta),$$
整理得 $$\exp(\alpha+\beta) = \dfrac{a}{c},$$
从而$$\beta = \ln(\dfrac{a}{c})-\alpha =\ln(\dfrac{a}{c})- \ln(\dfrac{b}{d}) = \ln(\dfrac{ad}{bc}).$$