I am learning how to use Stata to fit discrete-time hazard models with the book "Applied Longitudinal Data Analysis: Modeling Change and Event Occurrence" (Judy D. Singer & John B. Willet; Oxford University Press, 2003). I can't use the Stata code at https://stats.oarc.ucla.edu/stata/ex...-hazard-model/
to reproduce the graph in the attached as expected.
The dataset and the code are listed below for reference.
use https://stats.idre.ucla.edu/stat/sta.../data/firstsex, clear
clear stset time, failure(event)
sts generate s = s, by(pt)
sts generate h = h,by(pt)
sort time
graph twoway (line h time if pt == 1) (line h time if pt == 0), legend(pos(5) ring(0) lab(1 "PT=1") lab(2 "PT=0")) xtitle("Grade") /// ytitle("Estimated Hazard Probability")

Thanks for your help!
to reproduce the graph in the attached as expected.
The dataset and the code are listed below for reference.
use https://stats.idre.ucla.edu/stat/sta.../data/firstsex, clear
clear stset time, failure(event)
sts generate s = s, by(pt)
sts generate h = h,by(pt)
sort time
graph twoway (line h time if pt == 1) (line h time if pt == 0), legend(pos(5) ring(0) lab(1 "PT=1") lab(2 "PT=0")) xtitle("Grade") /// ytitle("Estimated Hazard Probability")
Thanks for your help!
Comment