Announcement

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

  • Fitting a spline curve (or polynomial) after cox regression model

    Hi!

    I would be very grateful with some input on how to fit a spline curve after my data. I am new to using this method so apologies in advance if my question is substandard

    What i would like to do is plot a spline curve where the y axis has the hazard of death modelled after any independent variable (continuous) on the x axis - could anyone recommend anything that i could try in order to generate this curve? I have a large cohort sample


    thank you!
    Last edited by sladmin; 26 Jul 2022, 13:21. Reason: anonymize original poster

  • #2
    Originally posted by Guest
    What i would like to do is plot a spline curve where the y axis has the risk of dying and the x axis age in years - could anyone recommend anything that i could try in order to generate this curve?
    I assume that your variable age is age at the start of the study. Remember that in your model the risk of dying changes over time (just as in real life). So what you want on your y-axis is not a single number for each person, but something that changes over time. So the graph you are looking for is not really possible. In order to make that work have to look at one point in time, e.g. t=0, or t=10, or t=100, or...

    Also the risk of dying at exactly one point in time is very very very very small. If you think time is continuous then that risk is basically 0. Instead we talk about hazards. You can think of that as the risk of dying in a unit of time (e.g. a year). More correctly, but sometimes more confusingly, it is the expected number of times that you die in a unit of time given that you were at risk.

    Also also, the whole point of the Cox model is that it does not model how that hazard changes over time. The idea is that what you don't estimate, cannot be wrong. That is what makes the Cox model robust. So the graph you want is contrary to the very idea behind a Cox model. It does not have to be wrong, but you have to have a very good reason for why you want it that way.

    In short, I would think about why you want that graph. What it's place is in your argument. How it relates to your model. Based on that you can think about what really should be on the y and x axes.

    Also also also, unless otherwise specified, the Cox model assumes that every person shares the same baseline hazard function, that is, the way the risk of dying changes over time. Often I would suspect that that baseline hazard function of a young person is very different from the baseline hazard function of an old person. Not just that the hazard is always higher, but also I expect the shape to be substantially different. There are ways to do that, but than you would no longer have age as an independent variable.

    Last edited by sladmin; 26 Jul 2022, 13:21. Reason: anonymize original poster
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Hi Maarten thank you for your answer! I have updated my question slightly, since I am new to using these curves i just wanted a simple example to get started (hence age - it was maybe not the best example) but my main question is that I want to generate a spline curve that shows hazards on the y axis modelled after a continuous variable on the x axis- what command can i use for this type of curve?
      thank you!

      Comment


      • #4
        The whole point of survival analysis is that the hazard is not constant. So that is logically impossible.
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment

        Working...
        X