Announcement

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

  • st cox and time varing predictors

    Dear Statalist

    I am trying to run a cox regression model to look at hazard for admission to hospital within 28 days of a positive test for an infection. Please can I ask about how to incorporate time varying predictors in to this model, and if I have done this correctly?

    The exposure I am interested in is vaccination status. Participants may be vaccinated at the start of the follow-up period, or get vaccinated during the follow-up period, so I need to account for this in the model as a time varying predictor

    The follow-up period starts on the day of the positive test, and ends 28 days later. During the 28 days either the outcome of interest can occur (they are admitted) or they get vaccinated.

    The data are long, I have included a mock up of the data below

    Data point is either the start of the follow-up period when the positive test occurred, the date when a vacine was received, the date when the outcome occurred, or the date when the follow-up period ends.
    Time is the number of days from the positive test to each data point
    Outcome of interest is coded 1 if the participant is admitted
    Exposed is coded 1 if the participant is exposed at each data point
    id Data point Outcome_of_interest Exposed Time
    1 Positive test 0 0 0
    1 Vaccine received 0 1 4
    1 End of follow up 0 1 28
    2 Positive test 0 0 0
    2 End of follow up 0 0 28
    3 Positive test 0 1 0
    3 Admitted 1 1 13
    so
    participant 1 is unvaccinated when they test positive, gets vaccinated 4 days later, and then doesnt get admitted during the rest of the follow-up time
    participant 2 is unvaccinated when they test positive, and doesnt get admitted during the rest of the follow up time
    participant 3 is vaccinated when they test positive, and gets admitted 13 days later

    To analyse this

    I first run

    st set time, id(id) failure(outcome_of_interest)

    and then run

    stcox exposed

    And I think this then gives the hazard ratio of admission between exposed vs unexposed participants. Is anyone able to tell me if I'm doing this correctly? Specifically, do I need to add a time observation for each day between each datapoint, or is how I've done it OK?

    Any help would be great - thank you!

    Best Wishes

    Joe

  • #2
    The Cox model will only give meaningful hazard ratios if the proportional hazards assumption holds. Have you tested it? You can do it using Schoenfeld residuals, using stphtest if my memory serves.

    I would also recommend generating nonparametric Kaplan-Meier survival curves, especially given that what you're interested in, vaccination status, can only assume one of two values, so the graph won't be cluttered.

    You can also visually inspect the Kaplan Meier survival curves to see if the proportional hazards assumption seems to hold. If it does not, you will have to resort to parametric estimation, e.g. using streg, or restricted mean survival time methodlogy (see Royston and Parmar, 2013).

    Code:
    stcox
    has a tvc() option for time-varying covariates. This allows you to interact these covariates with a function of time, specified in the texp() option off the top of my head. If the proportional hazards assumption is violated however, I am not sure if this is a valid "circumvention".

    Perhaps an expert on this topic will correct me, my knowledge is far from exhaustive and flawless.

    Comment

    Working...
    X