Announcement

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

  • Survival plots with not all categorical plots - adding plots

    Hi, statalists! I hope you all are well and safe.
    I have a doubt; it is making me lose my sleep. I am drawing a survival analysis graph plot.
    Stata allows drawing two or more plots, according to categorical data. I can make, for example, a survival plot respecting my definitions of failure and time. The software will return the plot with the survival proportion across time. Let's say I want to draw two plots: one for male and other for female. I need to tick the box "make separate calculations by group," then select the categorical variable (gender, in this case). It is easy.
    Is it possible to include the overall survival plot, in the same graph of both the male and female plot? A more difficult task: Is it possible to include the whole survival plot with JUST ONE of the subgroup plot (for example, only overall and male)???
    The reason is that I need to draw survival plots for eyes if they reach a given intraocular pressure (example, > 21 mmHg = failure), AND are on medical eyedrops or not. It is easy to create two groups: WITH and WITHOUT medications, and treat as a categorical variable. However, the literature usually considers that complete success happens to eyes with NO MEDICATION, and qualified success in all the eyes, WITH or WITHOUT medication. For me, qualified success means the overall survival plot. I'll have to draw an overall plot, and another with only no medication eyes, in the same graph.
    Any suggestions? I will appreciate any help.
    Thank you, guys!
    Marcos Balbino

  • #2
    Would this approach, essentially duplicating all observations in the dataset to make an "overall" category, work for you?

    Code:
    use http://www.stata-press.com/data/r13/drug2
    count
    expand 2
    replace drug = 3 in 49/l
    sts graph, by(drug) legend(order(1 "Female" 2 "Male" 3 "Overall"))
    sts graph if inlist(drug, 0, 3), by(drug) legend(order(1 "Female"  2 "Overall"))
    David Radwin
    Senior Researcher, California Competes
    californiacompetes.org
    Pronouns: He/Him

    Comment


    • #3
      For maximum flexibility, you can save the Kaplan-Meier estimates to a variable and then use standard graph commands. This reproduces David's example (or it would if I added an observation for time zero).

      Code:
      clear
      use http://www.stata-press.com/data/r13/drug2
      sts gen km=s 
      sts gen km_plac=s if drug==0
      
      twoway (line km _t , sort connect(stairstep)) ///
      (line km_plac _t , sort connect(stairstep) legend(order(1 "Placebo"  2 "Overall")))

      Comment


      • #4
        Thank you, David! That's exactly what I was looking for. I am not sure if I applied correctly, but Paul's code did not work... Maybe I did not understand the sequence...

        Comment

        Working...
        X