Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • why do I get a horizontal line for hazard ratio - using P.Lambert data

    Click image for larger version

Name:	Screenshot 2023-11-12 at 17.15.44.png
Views:	2
Size:	417.2 KB
ID:	1733611

    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")
    Attached Files

  • #2
    Hi I tried again, and still get a horizontal line...


    Code:
    //Trying time varying effect of hormonal treatment since years of diagnosis
    
    clear all
    
    use https://www.pclambert.net/data/rott2b, clear
    stset rf, f(rfi==1) scale(12) exit(time 60)
    generate hormonYES=(hormon==1)
    
    // spline variables for year of diagnosis
    rcsgen year, df(3) gen(yearspl) orthog
    
    stpm2 hormonYES year* age enodes pr_1, scale(hazard) df(4) eform nolog tvc(hormon) dftvc(3)
    
    range temptime 0 10 100
    
    predict hr, hrnumerator(hormonYES 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 (hormonY/hormonNo)") name("hr", replace) ///
    xtitle("Years since surgery")

    Comment

    Working...
    X