Hello , I'm trying to test, modelling effect of patients on hormone treatment (yes or no) on time using p.lambert data instead of p.dickman's data
(I find trying out with other datasets helps me understand the concept better
1. Why do I get a horizontal line in hazard ratio ?
My tVC is pr_1
2. Does it matter how many degrees of freedom to pick? I picked 5 because they used 5.
Code:
clear all
use https://www.pclambert.net/data/rott2b, clear
stset rf, f(rfi==1) scale(12) exit(time 60)
//Model effect of age on survival
***** WHY DID THEY CHOOSE 60 ???
rcsgen age, df(3) gen(agercs) center(60)
//Model effect over 5 year survival
//Create spline for year of diagnosis
rcsgen year, df(3) gen(yearspl) orthog
stpm2 hormon yearspl* age pr_1, scale(h) df(5) eform
estimates store m1
stpm2 pr_1 hormon yearspl* age, scale(h) df(5) eform tvc(pr_1) dftvc(3)
estimates store m2
//the same time varying vs non time varying
estimates table m1 m2, eform equations(1) ///
b(%9.6f) modelwidth(12) keep(pr_1 hormon yearspl* age)
//model used
stpm2 pr_1 hormon yearspl* age, scale(h) df(5) eform tvc(pr_1) dftvc(3)
//Prediction hazard ratio as hormone vs non hormon since years of diagnosis
range temptime 0 10 51
predict hr, hrnumerator(hormon 1) ci timevar(temptime)
twoway (rarea hr_lci hr_uci temptime, color(red%25)) ///
(line hr temptime, sort lcolor(red)) ///
, legend(off) ysize(8) xsize(11) ///
ytitle("Hazard ratio (hormon/not on hormon)") name("hr", replace) ///
xtitle("Years since diagnosis")

Comment