Announcement

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

  • Calculating and plotting graph on relative risk of death over time

    Hello all,

    I am trying to analyze patient survival (outcome variable: DEATH) of patients who received kidney transplant compared to patients who remained on dialysis (treatment variable: TRANSPLANT).

    KM curve is below. As you can see that transplanted patients appear to have worse survival initially. The benefit of transplant started to show around more than a year from transplant.

    Click image for larger version

Name:	Pt-Survival-75YO.jpg
Views:	2
Size:	134.8 KB
ID:	1742054

    Next, what I would like to do is to look at relative risk of death at time intervals (0-3 months, 3 months-1year, 1-2 years, 2-3 years, 3-5 years, and more than 5 years).

    I would like to get a graph that looks similar to this (see below, I cropped this from a paper I find online).

    Click image for larger version

Name:	relative-risk-death-example.png
Views:	1
Size:	613.2 KB
ID:	1742055

    I don't really know who to perform relative risk of death. I spent a lot of time on here trying to figure it out. What I have done so far was that I did stssplit like this (see below).

    Click image for larger version

Name:	timeband.png
Views:	1
Size:	161.9 KB
ID:	1742056

    Am I doing it the right way? So if this is the right way, does it mean that the benefit of transplant only started to show after 3 years post-transplant? And how do I plot a graph that look like the graph above?

    Thank you so much!

    NL
    Attached Files

  • #2
    Well, I'm not sure exactly what you want, as the language gets a bit confusing. People often use the terms hazard ratio and relative risk as if they are the same thing, but they are not. And I can't tell how you are using the terms.

    Strictly speaking, the relative risk of death at, say, 730 days would be calculated by looking at all the people who enter the cohort at time 0, determining the proportion of those who died up to time 730 days in each arm (the risk), and calculating the ratio of those two risks. Similarly for the other time points.

    The Cox proportional hazards analysis does not give you relative risks. It gives you hazard ratios, which are different. The hazard ratio at 730 days looks at all the people who survived up to day 730, then calculates the proportion of those in each arm who died exactly at time 730, or, for practical purposes, within a very short time after time 730 (the hazard), and calculating the ratio of those two hazards.

    In general the numbers are different, often very different. Notice that the numerator and the denominator of the hazard are both different from the numerator and denominator of the risk. So the ways of calculating them are different, as would be the results.

    So you need to clarify which you want: relative risk or hazard ratio.

    Comment


    • #3
      Apologies for the confusion. I guess I did not know what I wanted, and thank you for pointing that out. Papers that I have found seem to use relative risk and hazard ratios interchangeably, which make me even more confused.

      I think what I am looking for is hazard ration. Here is another sample for a different paper that I found. They compared patient survival and then looked at adjusted HR over time.

      Click image for larger version

Name:	Bree-1.png
Views:	2
Size:	715.5 KB
ID:	1742077 Click image for larger version

Name:	Bree-2.png
Views:	1
Size:	618.5 KB
ID:	1742078

      In the method section, it says, "Stratified Cox regression model was used to compare hazards by the following time periods post- transplant: 0 to <3 months, 3 to <12 months, 1 to <5 years, and 5 years."

      So basically, what I am asking for is how to perform stratified cox regression and how to plot the graph. I am fairly new to biostatistics, so thank you so much for your patience.
      Attached Files

      Comment


      • #4
        In the method section, it says, "Stratified Cox regression model was used to compare hazards by the following time periods post- transplant: 0 to <3 months, 3 to <12 months, 1 to <5 years, and 5 years."
        Still more confusing language! In a true stratified Cox regression model it is mathematically impossible to compare the group hazards at different time periods. That's because in a stratified Cox regression model, the differences between the group is all attributed to different baseline hazard functions and the hazards are assumed to be the same in the groups. I think what they meant was that they made the group variable into a time-varying covariate, which is precisely what you did in what you show in #1. It is also, I would say, the right way to approach this.

        So what you need now is some code to get you from that Cox regression output to the time-specific group hazard ratios, and to make a graph of them.
        Code:
        frame create results int time float hr
        
        foreach t of numlist 0 90 365 730 1095 1825 {
            lincom 1.TRANSPLANT#`t'.timeband - 0.TRANSPLANT#`t'.timeband, eform
            frame post results (`t') (`r(estimate)')
        }
        
        frame results: graph twoway line hr line, sort
        Note: As no example data was provided, this code is untested and may contain errors.

        Comment


        • #5
          OMG. I worked! You are a life saver! I am so grateful for your help.

          Comment


          • #6
            Sir,

            I am not sure how to interpret the results.

            Code:
            frame create results int time float hr
            
            
            foreach t of numlist 0 90 180 365 730 1095 1825 2555 {
                lincom 1.TRANSPLANT#`t'.timeband - 0.TRANSPLANT#`t'.timeband, eform
                frame post results (`t') (`r(estimate)')
            }
            
            
             ( 1)  - 0b.TRANSPLANT#0b.timeband + 1.TRANSPLANT#0b.timeband = 0
            
            ------------------------------------------------------------------------------
                      _t |     exp(b)   Std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     (1) |   1.858652   .4801445     2.40   0.016     1.120231    3.083816
            ------------------------------------------------------------------------------
            
             ( 1)  - 0b.TRANSPLANT#90.timeband + 1.TRANSPLANT#90.timeband = 0
            
            ------------------------------------------------------------------------------
                      _t |     exp(b)   Std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     (1) |   1.254299   .4469706     0.64   0.525     .6238423    2.521898
            ------------------------------------------------------------------------------
            
             ( 1)  - 0b.TRANSPLANT#180.timeband + 1.TRANSPLANT#180.timeband = 0
            
            ------------------------------------------------------------------------------
                      _t |     exp(b)   Std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     (1) |   .7504125    .176492    -1.22   0.222     .4732637    1.189863
            ------------------------------------------------------------------------------
            
             ( 1)  - 0b.TRANSPLANT#365.timeband + 1.TRANSPLANT#365.timeband = 0
            
            ------------------------------------------------------------------------------
                      _t |     exp(b)   Std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     (1) |   .4833205    .090499    -3.88   0.000     .3348517    .6976183
            ------------------------------------------------------------------------------
            
             ( 1)  - 0b.TRANSPLANT#730.timeband + 1.TRANSPLANT#730.timeband = 0
            
            ------------------------------------------------------------------------------
                      _t |     exp(b)   Std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     (1) |   .7178118   .1495201    -1.59   0.111     .4772054    1.079732
            ------------------------------------------------------------------------------
            
             ( 1)  - 0b.TRANSPLANT#1095.timeband + 1.TRANSPLANT#1095.timeband = 0
            
            ------------------------------------------------------------------------------
                      _t |     exp(b)   Std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     (1) |   .7547792   .1495668    -1.42   0.156      .511854    1.112996
            ------------------------------------------------------------------------------
            
             ( 1)  - 0b.TRANSPLANT#1825.timeband + 1.TRANSPLANT#1825.timeband = 0
            
            ------------------------------------------------------------------------------
                      _t |     exp(b)   Std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     (1) |   .5921839   .1834338    -1.69   0.091     .3226934    1.086734
            ------------------------------------------------------------------------------
            
             ( 1)  - 0b.TRANSPLANT#2555.timeband + 1.TRANSPLANT#2555.timeband = 0
            
            ------------------------------------------------------------------------------
                      _t |     exp(b)   Std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     (1) |   .4218264   .2526088    -1.44   0.149     .1304355    1.364181
            ------------------------------------------------------------------------------
            
            frame results: graph twoway line hr time, sort
            Does this mean hazard ratio = 1.858652 at time 0? Or does it mean hazard ratio is 1.858652 from the period of 0 to 3 months?

            Then, hazard ratio =n1.254299 at 3-month mark, or it means hazard ratio of 1.254299 from the period of 3 to 6 months?
            Click image for larger version

Name:	Graph-relative-death.jpg
Views:	1
Size:	93.5 KB
ID:	1742805

            Comment


            • #7
              It depends on how the variable timeband was defined. If timeband itself corresponds to a single point in time, then the same is true of the hazard ratios you are working with here. If timeband is a variable that defines an interval , then the hazard ratios also refer to that interval.
              Last edited by Clyde Schechter; 10 Feb 2024, 22:46.

              Comment


              • #8
                Code:
                stset PATIENT_FU_TIME_NEW, failure(DEATH) id(WL_ID_CODE)
                
                stsplit timeband, at(0 90 180 365 730 1095 1825 2555) 
                
                
                stcox TRANSPLANT#i.timeband, strata(timeband)
                I used stsplit to create timeband. So this means what I've got are time intervals and not single points, correct?

                Comment


                • #9
                  Yes, the variable -stsplit- creates defines intervals.

                  Comment

                  Working...
                  X