Hello, I have a sample dataset here, and for ease of illustrating my question, I made a little bit of change on it.
if prsnperd module is never installed, please type the commands below,
net describe dthaz, from(https://alexisdinno.com/stata)
net install dthaz.pkg
net get dthaz.pkg
use http://www.stata-press.com/data/cgm3r/hip2,clear
gen time=time1-time0
bys id: egen t=max(time)
drop _* time* gap
order id t
prsnperd id t fracture
drop if _period==3|_period==4|_period==11
drop if _period==14
drop if _period==15
drop if _period==16
drop if _period==21
drop if _period==22
drop if _period==23
drop if _period==9
drop if _period==12
drop if _period==1
drop if _period==2
bys id: gen time=_n
drop _* t
order id time fracture-age
stset time, failure (fracture)
The discrete-time survival model that I did is as follows,
logit fracture c.age i.protect c.age#c.age c.age#i.protect c.age#c.age#i.protect,or
I want to create a plot of estimated hazard curve regarding the squared term of patient's age multiplied with "protective measures" interacted with time.
The X axis is time, and Y axis is the estimated hazard rate.
I saw a graph on a dissertation, which was graphed with Excel sheet, and it is placed in the attached picture. I think it is similar to what I want.
I don't know if someone can help me to solve this problem with Stata code.
By the way, before I decided to post my question here, I asked my classmate and they said it seemed that I could use "predict" or "margin" to solve this problem.
I have no idea about it.
if prsnperd module is never installed, please type the commands below,
net describe dthaz, from(https://alexisdinno.com/stata)
net install dthaz.pkg
net get dthaz.pkg
use http://www.stata-press.com/data/cgm3r/hip2,clear
gen time=time1-time0
bys id: egen t=max(time)
drop _* time* gap
order id t
prsnperd id t fracture
drop if _period==3|_period==4|_period==11
drop if _period==14
drop if _period==15
drop if _period==16
drop if _period==21
drop if _period==22
drop if _period==23
drop if _period==9
drop if _period==12
drop if _period==1
drop if _period==2
bys id: gen time=_n
drop _* t
order id time fracture-age
stset time, failure (fracture)
The discrete-time survival model that I did is as follows,
logit fracture c.age i.protect c.age#c.age c.age#i.protect c.age#c.age#i.protect,or
I want to create a plot of estimated hazard curve regarding the squared term of patient's age multiplied with "protective measures" interacted with time.
The X axis is time, and Y axis is the estimated hazard rate.
I saw a graph on a dissertation, which was graphed with Excel sheet, and it is placed in the attached picture. I think it is similar to what I want.
I don't know if someone can help me to solve this problem with Stata code.
By the way, before I decided to post my question here, I asked my classmate and they said it seemed that I could use "predict" or "margin" to solve this problem.
I have no idea about it.

Comment