Announcement

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

  • Time-varying covariates in the Cox Model

    I have a dataset regarding patients who might have a hospitalization during the study period ( 5 years). I divided the study period into three phases and created a label variable, called Period, to identify in which phase the hospitalization occurred. I have to implement a cox model using these covariates: age, Period and sex. The study's aim is to estimate the risk of hospitalization over the different phases.
    I have one question:
    2) The phases have different lasts and change over time, how I can include this in the model?

    For more clarity:
    ID Sex Age Period Hosp(0/1)
    1 F 22 First 1
    1 F 23 Third 0
    2 M 34 First 1
    2 M 34 Second 0
    2 M 35 Third 1
    Last edited by Giuseppina Affinito; 28 Feb 2023, 08:50.

  • #2
    I'm hesitant to give advice, because there appear to be some non-standard features in your data (see later) that could complicate matters, but I'll try and steer you in the right direction. Your study aim, study design, and data structure and not perfectly clear to me so I could be giving bad advice if I've misunderstood.

    The approach is that once you have chosen a timescale (I am assuming it's age for you) then for each observation you need the time at start of the observation and time at the end of the observation. So if age is the timescale, you would need variables for age at start and age at end of each period (you'll need higher resolution than completed years). You then use:

    stset age_exit, fail() enter(age_start)

    It's not clear to me what your timescale is; it could be calendar time in which case you would use date at start and date at exit to index the intervals.

    One aspect that potentially complicates your analysis is that it looks like you have recurrent events (ID 2 has two events and ID 1 is still at risk after having an event). You'll need to use appropriate methods for recurrent events. I notice also that patient ID 1 appears to contribute person-time to periods 1 and 3 but not period 2; it's not clear to me why that's the case and what implications it may have.

    Comment


    • #3
      I have something like this:
      D Sex Age Period Hosp(0/1) Start_Therapy_Date End_Therapy_Date Time
      1 F 22 First 1 1/1/2020 5/5/2020 4/1/2020
      1 F 23 Third 0 1/1/2021 5/6/2021 5/6/2021
      2 M 34 First 1 5/1/2020 8/7/2020 6/1/2020
      2 M 34 Second 0 8/8/2020 12/31/2020 12/31/2020
      2 M 35 Third 1 1/1/2021 7/8/2021 6/2/2021
      The time variable is the date of the event if it happened and the date of therapy end if the event didn't happen.
      The phases ( first, second and so on) have different duration.
      I use this code:

      stset Time, fail(Hosp) Origin(date of first therapy) time0(Start therapy date) exit(end date of last therapy)

      stcox Age i.sex i.Period, tvc(Age Period)

      Are these code lines correct? I don't understand if Age and Period are time-varying variables .

      Comment

      Working...
      X