Announcement

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

  • Saving, combining and exporting stphplot graphs to PDF

    Hello,

    I'm new to Stata. I'm working on a Cox regression analysis (also new to this) on quite a large dataset. When I check the PH assumption, I would like to save the graphs for each covariate (age_cat, n_31_0_0, townsend_5 and education), then combine the graphs together and export as a pdf. Is that possible? and if so, how would I go about it? I've had a look at other posts on this site but cannot get my head around them.

    For example, after I enter the below, I would like to combine the graphs and export:
    Code:
    stset censoroesoph, failure(inc_oesoph) id(n_eid) scale(365.25) origin(ts_53_0_0)
    * Model 1
    stcox i.n_23074_0_0 i.age_cat i.n_31_0_0 i.townsend_5 i.education,base
    * Check PH assumption
    stphtest, detail
    estat phtest  
    stphplot, by(age_cat)
    graph save oesoph1age_cat
    stphplot, by(n_31_0_0)
    graph save oesoph1sex
    stphplot, by(townsend_5)
    graph save oesoph1townsend_5
    stphplot, by(education)
    graph save oesoph1education
    However, when I try to use the graph combine command, this is what I get:
    Code:
    graph combine oesoph1age_cat.gph oesoph1sex.gph oesoph1townsend_5.gph oesoph1education.gph
    file oesoph1age_cat.gph not found
    Any help would be much appreciated, thank you.

  • #2
    Try using name()

    Example:

    Code:
    clear all
    
    webuse leukemia
    stset weeks, failure(relapse) noshow
    
    // Check proportional-hazards assumption for treatment1 using stphplot
    stphplot, by(treatment1) name(plt1, replace)
    
    // Same as above, but adjust for white-blood-cell count
    stphplot, by(treatment1) adjustfor(i.wbc3cat) name(plt2, replace)
    
    graph combine plt1 plt2
    graph export combined.pdf, replace
    
    exit
    Click image for larger version

Name:	combined.png
Views:	1
Size:	384.4 KB
ID:	1586251

    Last edited by Justin Niakamal; 16 Dec 2020, 08:24.

    Comment


    • #3
      It worked, thank you so much!

      Comment

      Working...
      X