Announcement

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

  • Interaction graph after Cox proportional hazards model

    Hello,
    I am examining a sample of firms over an 8 year period. I am using the Cox proportional hazard model to study whether 'manage' (a binary variable), moderated by growth and risk, impacts firms' hazard rate of termination.
    I am running
    Code:
    stcox i.manage##c.growth risk x, vce(cluster industry) nohr
    After this, I would like to create an interaction graph to examine how the hazard rate varies when manage=1 versus manage=0, for all feasible values of growth (and, after similarly running a model with the risk interaction, for risk).
    What is the best way to do this?
    I tried using margins, but am getting unusually high values on the vertical axis. I also read in another thread that margins may not be the best way to generate this graph based on what one wishes to achieve, but am unsure how else to do so.

    I would be grateful for any help, thank you very much!

  • #2
    This is how I would do this:

    Code:
    clear
    sysuse cancer
    stcox i.drug##c.age, hr
    
    predictnl other = _b[2.drug]+age*_b[2.drug#c.age], ///
         ci(o_lb o_ub)
    predictnl na = _b[3.drug]+age*_b[3.drug#c.age], ///
         ci(n_lb n_ub)
    
    replace other = exp(other)
    replace o_lb = exp(o_lb)
    replace o_ub = exp(o_ub)
    replace na = exp(na)
    replace n_lb = exp(n_lb)
    replace n_ub = exp(n_ub)     
    sort age    
     
    twoway rarea o_lb o_ub age, astyle(ci) acolor(%50) || ///
           rarea n_lb n_ub age, astyle(ci2) acolor(%50) || ///
           line other na age, ///
           legend(order( - "other " 3 "" 1 "" ///
                         - " " -  "NA" 4 "" 2 "" )) ///
           ytitle(hazard ratio)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	92.5 KB
ID:	1786291
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thank you so much for your reply!

      Comment

      Working...
      X