Announcement

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

  • Adjusting variables with Nelson-Aalen cumulative hazard function

    Dear all!

    I am struggling with the survivor function of the Nelson-Aalen cumulative hazard function. I would like to adjust the graph for age, gender etc. Unfortunately I see that this is not possible in the help window with the adjustfor function. Does anybody has an idea to get the trick done in another way? Help would be very much appreciated!!! Thank you.

    Kind regards,
    Daniel

  • #2
    Any tips are welcome!

    Comment


    • #3
      You're more likely to get answers if you read the FAQ and follow it. Your question is too vague; providing code will help us understand what you're trying to do. Providing data may result in someone providing code to do what you want. Now I'll do my best to try and help.

      Do you want to plot the survivor function or the cumulative hazard function (you mention both)? What command are you using? There are many ways to estimate these functions.

      What do you mean by adjust? Adjust usually implies fitting a model. Even if you (believe you) are using non-parametric estimation of the Kaplan-Meier survival function using -sts graph- you will find that "sts graph, adjustfor()" with by() or strata() will fit a Cox model in the background and predict from the survivor function the fitted Cox model. Without knowing exactly what you want to do, you're most probably better off fitting a model yourself and predicting from it. You then have control over exactly what you're doing.

      You could fit a Cox model and use -predict-, but I've found predicting from a flexible parametric survival model (stpm2 from SSC) is much more powerful.

      After fitting the model you can predict a range of quantities (the -predict- command) including the survivor function and cumulative hazard function. -predict- will give you conditional estimates. If you want marginal estimates you can use -standsurv- (also from SSC).

      Comment


      • #4
        Originally posted by Paul Dickman View Post
        You're more likely to get answers if you read the FAQ and follow it. Your question is too vague; providing code will help us understand what you're trying to do. Providing data may result in someone providing code to do what you want. Now I'll do my best to try and help.

        Do you want to plot the survivor function or the cumulative hazard function (you mention both)? What command are you using? There are many ways to estimate these functions.

        What do you mean by adjust? Adjust usually implies fitting a model. Even if you (believe you) are using non-parametric estimation of the Kaplan-Meier survival function using -sts graph- you will find that "sts graph, adjustfor()" with by() or strata() will fit a Cox model in the background and predict from the survivor function the fitted Cox model. Without knowing exactly what you want to do, you're most probably better off fitting a model yourself and predicting from it. You then have control over exactly what you're doing.

        You could fit a Cox model and use -predict-, but I've found predicting from a flexible parametric survival model (stpm2 from SSC) is much more powerful.

        After fitting the model you can predict a range of quantities (the -predict- command) including the survivor function and cumulative hazard function. -predict- will give you conditional estimates. If you want marginal estimates you can use -standsurv- (also from SSC).
        Thank you for your reply! I will try to make myself more clear:
        I used:
        Code:
        sts graph, cumhaz by(obese)
        to see if obesity has an effect on the cumulative hazard
        but I realized this might be confounded by other factors and there I want to adjust for this and I tried the following code:
        Code:
        sts graph, by(obese) tmax(30) adjustfor(AGE, gender)
        Unfortunately STATA tells me this is not available for the cumhaz function..

        I hope I made myself more clear now! Do you still think I should use the cox model?

        Comment


        • #5
          Yes, I believe you can achieve what you want by explicitly predicting from a Cox model. This will also hopefully make it clearer exactly what Stata is doing (and may lead you to realise that what sts graph with adjustfor() is giving you may be misleading).

          Your last line of code (that doesn't contain a cumhaz option) should work (it will give Kaplan-Meier curves).

          Code:
          sts graph, by(obese) adjustfor(AGE, gender)
          By reproducing that output by fitting a Cox model, we can see exactly what the above code does and then modify the code to give the cumulative hazard instead of the survivor function. I excluded the tmax option for simplicity. If obese is binary (coded as 0 / 1) then the following code should reproduce the output from -sts graph-.

          Code:
          stcox AGE gender if obese==0
          predict s0,  basesurv
          
          stcox AGE gender if obese==1
          predict s1,  basesurv  
           
          twoway (line s0 _t, sort connect(stairstep)) (line s1 _t, sort connect(stairstep))
          You'll possibly need to add observations for time 0 to make the graphs identical.

          You can then replace basesurv with basechazard to get adjusted plots of the cumulative hazard rather than the survival function.

          However, I would encourage you to think about what these plots represent. Here's an extract from the help for sts graph:

          If you specify adjustfor() with by(), sts fits separate Cox regression models for each group, using the adjustfor() variables as covariates. The separately calculated baseline survivor functions are then retrieved.
          This is what we did with stcox followed by predict.

          Let's say your patients are adults; AGE is age in years and sex is coded as 1 for men and 2 for women.

          The predicted Kaplan-Meier curves from the first sts graph command (as well as from the stcox/predict/twoway code) will be the estimated survival curves (1 for obese, 1 for non-obese) for patients aged 0 with sex 0. These won't be representative of any group of patients in your study (sex==0 does not exist in your study and you don't have newborns). The results may be extremely misleading (since you are assuming a linear effect of age and predicting outside the sample values).

          Predicting from a fitted model will give much greater transparency and control over what you are doing. You would possibly want to center AGE at a variable more relevant to your study. I would personally use stpm2 (from SSC) as I think the postestimation commands are much more powerful than for stcox.

          In my original post I erroneously said that -standsurv- was on SSC. At the time of writing it's can be downloaded from https://pclambert.net/software/standsurv/.















          Comment

          Working...
          X