Taking derivatives, we obtain
@lnLðbÞ
@bj
¼~
k
Yk
P^ðXkÞ
1 Yk
1 P^ðXkÞ
()
^PðXkÞ
ð 1 P^ðXkÞÞXjk;
which can be rewritten as
@lnLðbÞ
@bj
¼~
k
Ykð 1 P^ðXkÞÞð 1 YkÞ^PðXkÞ
no
Xjk
and further simplied to
@lnLðbÞ
@bj
¼~
k
ðYkP^ðXkÞÞXjk:
We can then write
~
j
bj
@lnLðbÞ
@bj
¼~
k
Yk^PðXkÞ
~
j
bjXjk
¼~
k
Yk^PðXkÞ
ln
^PðXkÞ
1 P^ðXkÞ
!
¼~
k
Yk^PðXkÞ
logitP^ðXkÞ:
Since@lnLð
b^Þ
@bj ¼^0 for the ML estimate
b^,we
can write~
k
ðYk^PðXkÞÞlogitP^ðXkÞ¼ 0.
It then follows that ~
k
Yklogitð^PðXkÞÞ¼
~
k
P^ðXkÞlogitð^PðXkÞkÞ.
We then replace ~
k
YklogitðP^ðXkÞÞ by
~
k
^PðXkÞlogitðP^ðXkÞÞ in the above simplified
formula for the deviance to obtain
DevSSðb^Þ¼ 2 ~
n
k¼ 1
^
PðXkÞlogitðP^ðXkÞÞ
þlnð 1 P^ðXkÞÞ
:
328 9. Assessing Goodness of Fit for Logistic Regression