Announcement

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

  • Simple Question about Survival Curves

    Hi All,

    Sorry for the simple question, I feel it could be answered by a google search but I am not able to phrase it in a concise manner.

    I am analysing survival data from a study and wish to generate two survival curves on the same plot for Group A and Group B. However, I wish to only use Group A and Group B data from another category of a different variable.

    As an example, if I wanted to create survival curves for people with coronary disease and without coronary disease but only for those with hypertension, how would I go about doing this? If I was running a regression I would use the if hypertension==yes command.

    I hope I explained that articulately. Thanks for your help.

  • #2
    Rahul:
    welcome to the list.
    What follows migh be useful:
    Code:
    . use http://www.stata-press.com/data/r14/drugtr.dta
    (Patient Survival in Drug Trial)
    
    . stcox i.drug age
    
             failure _d:  died
       analysis time _t:  studytime
    
    Iteration 0:   log likelihood = -99.911448
    Iteration 1:   log likelihood = -83.551879
    Iteration 2:   log likelihood = -83.324009
    Iteration 3:   log likelihood = -83.323546
    Refining estimates:
    Iteration 0:   log likelihood = -83.323546
    
    Cox regression -- Breslow method for ties
    
    No. of subjects =           48                  Number of obs    =          48
    No. of failures =           31
    Time at risk    =          744
                                                    LR chi2(2)       =       33.18
    Log likelihood  =   -83.323546                  Prob > chi2      =      0.0000
    
    ------------------------------------------------------------------------------
              _t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          1.drug |   .1048772   .0477017    -4.96   0.000     .0430057    .2557622
             age |   1.120325   .0417711     3.05   0.002     1.041375     1.20526
    ------------------------------------------------------------------------------
    
    . sts graph if drug!=3, hazard by(drug)
    
             failure _d:  died
       analysis time _t:  studytime
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Welcome to Statalist.

      If you look at help regress you will see
      Code:
      Title
      
          [R] regress -- Linear regression
      
      
      Syntax
      
              regress depvar [indepvars] [if] [in] [weight] [, options]
      and the syntax includes [if] which means you can include the if clause (not command) to restrict your data to a subset, for example
      Code:
      regress y x1 x2 x3 if z==1
      Now look at the help output for the command you are using to analyze your survival data and see if that also includes [if] which means you can similarly add an if clause to the command you are using.

      The basic documentation for the if clause is found in help if.

      Comment


      • #4
        Carlo and William provided insightful examples.

        I jush wish to add that, if by "survival curves" you mean the graph obtained by KM survival estimates, you may also try the example below:

        Code:
        . use http://www.stata-press.com/data/r14/stan3.dta
        (Heart transplant data)
        
        . */ let's say we wish the survival curves for the treatment group (transplant), only for people with "no surgery"
        
        . sts graph if surgery ==0, by(transplant) note("Note: estimation for individuals who did not undertake a surgical procedure")
        
                 failure _d:  died
           analysis time _t:  t1
                         id:  id
        Click image for larger version

Name:	Graph_KM.png
Views:	1
Size:	12.7 KB
ID:	1381316



        Hopefully that helps.
        Best regards,

        Marcos

        Comment


        • #5
          Hi Guys,

          Thanks for the warm welcome and the advice. I must have been putting the if== command in the wrong spot for the sts graph command. That's very helpful.

          Cheers!

          Comment


          • #6
            Regarding the dataset "stan3.dta" about survival after heart transplant or not.

            Can someone explain to me why you can't use the variable 'transplant' (instead of 'posttran') to analyse the survival effect of the heart transplant when you have informed STATA that it is multiple-record survival data (with 'posttran' to mark before and after a heart transplant for those who get a transplant)?

            \stan3.dta"
            (Heart transplant data)

            . stset t1, id(id) failure(died) scale(1)

            Survival-time data settings

            ID variable: id
            Failure event: died!=0 & died<.
            Observed time interval: (t1[_n-1], t1]
            Exit on or before: failure
            --------------------------------------------------------------------------
            172 total observations
            0 exclusions
            --------------------------------------------------------------------------
            172 observations remaining, representing
            103 subjects
            75 failures in single-failure-per-subject data
            31,938.1 total analysis time at risk and under observation
            At risk from t = 0
            Earliest observed entry t = 0
            Last observed exit t = 1,799

            . stcox year age surgery transplant

            Failure _d: died
            Analysis time _t: t1
            ID variable: id

            Cox regression with Breslow method for ties

            No. of subjects = 103 Number of obs = 172
            No. of failures = 75
            Time at risk = 31,938.1
            LR chi2(4) = 49.42
            Log likelihood = -273.60569 Prob > chi2 = 0.0000

            ------------------------------------------------------------------------------
            _t | Haz. ratio Std. err. z P>|z| [95% conf. interval]
            -------------+----------------------------------------------------------------
            year | .9135805 .0603106 -1.37 0.171 .8027017 1.039775
            age | 1.059357 .0155334 3.93 0.000 1.029346 1.090244
            surgery | .5195865 .2325112 -1.46 0.143 .216148 1.249006
            transplant | .1939431 .0541827 -5.87 0.000 .1121684 .3353345
            ------------------------------------------------------------------------------

            . stcox year age surgery posttran

            Failure _d: died
            Analysis time _t: t1
            ID variable: id

            Cox regression with Breslow method for ties

            No. of subjects = 103 Number of obs = 172
            No. of failures = 75
            Time at risk = 31,938.1
            LR chi2(4) = 17.56
            Log likelihood = -289.53378 Prob > chi2 = 0.0015

            ------------------------------------------------------------------------------
            _t | Haz. ratio Std. err. z P>|z| [95% conf. interval]
            -------------+----------------------------------------------------------------
            year | .8873107 .059808 -1.77 0.076 .7775022 1.012628
            age | 1.030224 .0143201 2.14 0.032 1.002536 1.058677
            surgery | .3738278 .163204 -2.25 0.024 .1588759 .8796
            posttran | .9787243 .3032597 -0.07 0.945 .5332291 1.796416
            ------------------------------------------------------------------------------


            Comment

            Working...
            X