* Get LLM
use https://www3.nd.edu/~rwilliam/statafiles/logist.dta, clear
logit grade gpa tuce psi
* Compute probability that y = 1
predict prob1
* If y = 1, pi = probability y = 1
gen pi = prob1 if grade == 1
* If y = 0, replace pi with probability y = 0
replace pi = (1 - prob1) if grade == 0
* compute log of pi
gen lnpi = ln(pi)
list grade gpa tuce psi prob1 pi lnpi, sep(8)
total lnpi
* Repeat the process to get LL0
use https://www3.nd.edu/~rwilliam/statafiles/logist.dta, clear
logit grade
* Compute probability that y = 1
predict prob1
* If y = 1, pi = probability y = 1
gen pi = prob1 if grade == 1
* If y = 0, replace pi with probability y = 0
replace pi = (1 - prob1) if grade == 0
* compute log of pi
gen lnpi = ln(pi)
list grade gpa tuce psi prob1 pi lnpi, sep(8)
total lnpi