Announcement

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

  • why include spline variable? in P Dickman stpm2 modelling effect

    Hi I'm following from p. dickman's website

    Just wondering why does he recommend using a spline variable for the year of diagnosis?
    I know splines are used for non-linear trends, but I don't understand why he recommends splitting it into a spline

    My aim is to plot a graph to model hazard comparing males: females for a treatment = 1 over time
    The problem isn't coding but the logic of why a spline was introduced



    Code:
    clear all 
    use https://pauldickman.com/data/melanoma.dta
    
    rename surv_mm survivalt
    stset survivalt, failure(status==1) exit(time 60.5) scale(12)
    
    //create dummy variable - treament
    gen treatment = 0 
    replace treatment = 1 if stage == 1 
     
    stpm2 treatment age stage sex, scale(hazard) df(4) eform nolog tvc(treatment sex) dftvc(3)
    
    
    //Graph 3: model hazard in terms of male : Female for treatment ==1  over time
    //Creating dummy variables for modelling 
    gen female = sex==2
    gen male= sex==1
    
    //spline variables for year of diagnosis 
    rename yydx opdate
    rcsgen opdate, df(3) gen(yearspl) orthog   //look up df , orthog ****pending 
    range temptime 0 10 51 
    
    //refit model with spline in year - WHY IS THIS DONE? 
    stpm2 treatment age yearspl* stage sex, scale(hazard) df(5) tvc(treatment sex) dftvc(3)
    
    //Time varying effect of gender and specific for treatment = 1
    //Males treatment = 1 
    
    predict hr6, hrnumerator (sex 1 treatment 1) hrdenominator (sex 2 treatment 1) ci timevar(temptime)

Working...
X