Announcement

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

  • How to add external time varying covariates in Cox ph model?

    I have a data set which includes begin and end dates of local restaurants since 2000 to 2017.
    I like to examine whether a mega sport event of the local area which occurred in 2010 has any impacts on hazard of restaurant closure ever after.
    I intuitively know that I need to add a dummy variable representing the occurrence of the mega event (gen dmega=(date>=2010).
    I can do this by adding "dmega" which is based on calendar time after "stsplit. at(failure)".
    Is this right approach? I heard that time varying covariate only should depend on _t rather than calendar time.
    In this case, I created a dummy variable using calendar time rather than _t.
    Also I want to add monthly or year tourist volume as time varying covariate. Is it right approach to add volume based on calendar time after "stsplit. at(failure)"?
    Thanks in advance for any kinds of suggestions.

  • #2
    Welcome to Statalist, Chul!

    Be sure to read all the FAQ, especially FAQ 12 on how to ask good questions. All code, results, and data listing should be put between CODE delimiters, explained in the FAQ for example:
    [CODE]
    tab year
    [/CODE]
    will appear as
    Code:
    tab year
    All events, including the occurrence of the mega-event should be in Stata date variables. So define the start (entry) and end (exit) variables and the megadate variable ("2010" is not a valid Stata date). Stata will create the _t variable. An example for the megadate if the event took place on June 12, 2010
    Code:
    gen dmega = mdy(6,12,2010)
    format dmega %td
    See the help and Manual entry for datetime.

    You can add an external covariate as long as it is measured prior to each failure event . So, you cannot use tourist volume in the year of the failures, as that is known only at the end of the year or later. If there is a seasonal pattern for closings, you might have to use month (1-12) as a categorical predictor (i.month).

    If you post again, please show us
    1) a sample of the your data, with datex, described in FAQ 12
    2) your stset statement and the results ot stdes , all between CODE delimiters.




    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment

    Working...
    X