Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Programming
- /
- More than one time-dependent variable in a time-dependent Cox regressi...

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

☑ This topic is **solved**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 3 weeks ago
(559 views)

Hello, everyone

It is not uncommon that we have to control more than one time-dependent variable in a Cox regression model. A SAS support PDF document teaches two methods to code for a time-dependent Cox model, but, with only one time-dependent variable adjusted (link: https://support.sas.com/resources/papers/proceedings12/168-2012.pdf).

The first method involves constructing a special data set for the time-dependent variable data and the example is for only one time-dependent variable. It does not teach what to do if there is more than one such variable.

The second method is more advanced, termed "programming statment method". It has only one record for each individual, compared with the first method which has multiple records for each individual.

I wonder how to code for the Cox model if there are 2 or more time-dependent variables, by both method 1 and 2. Thank you very much.

Tom

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@TomHsiung wrote:

Thank you for your suggestion. (...) If there is an individual who was followed for 14 days, for whom the A changed on day 7 from 0 to 1. In addition, the B changed on day 4 from 1 to 0. According to my understanding of your idea, there should be three rows for this individual in the overall table and they are:

row one: A=0, B=1, start=0, stop=4

row two: A=0, B=0, start=4, stop=7

row three A=1, B=0, start=7, stop=14

You're welcome.

In a situation with discrete (integer) times *t _{1}*,

So, if you know that "B changed * on* day 4 from 1 to 0," (

start stop A B 0 3 0 1 3 6 0 0 6 14 1 0

If the event or censoring time of that individual was day 7, the third observation would have stop=7 (and the corresponding value of the variable indicating event or censoring, not shown above). Thus, the model would take the potential impact of A=1 on the occurrence probability of the event into account since start=6<7=stop.

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hello @TomHsiung,

I would think of the two or more time-dependent explanatory variables as *one vector-valued* variable and then use either of the two methods from the paper (or even both, for validation purposes) to build the model.

With counting process style of input: Create an input dataset with one observation per individual *and* time interval (start, stop] where the *combination* of all time-dependent explanatory variables (i.e., the "vector") is constant, until one or more of the components of the vector change or a change of status (event or censoring) occurs.

Using programming statements: Assign each component of the vector its time-dependent value (using one or more arrays or IF-THEN/ELSE statements or whatever is appropriate).

Which of the two methods is more convenient, depends on the structure and other characteristics of your data.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi, @FreelanceReinh

Thank you for your suggestion. Hmmm, it's a great idea to deal with multiple time-dependent variables. Please let me reproduce your idea.

First, via the counting process method. Say, we have two time-varying variables named A and B, and there are other fixed variables which is represented in union by U. If there is an individual who was followed for 14 days, for whom the A changed on day 7 from 0 to 1. In addition, the B changed on day 4 from 1 to 0. According to my understanding of your idea, there should be three rows for this individual in the overall table and they are:

row one: A=0, B=1, start=0, stop=4

row two: A=0, B=0, start=4, stop=7

row three A=1, B=0, start=7, stop=14

Therefore, every change in the time-varying variable produces an extra row for the individual, given that the time-varying variables do not change on the same day (i.e., tie).

I have not yet thought about the programming method and if I have ideas about it I would update this post. Again, thank you for your feedback.

Tom

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@TomHsiung wrote:

Thank you for your suggestion. (...) If there is an individual who was followed for 14 days, for whom the A changed on day 7 from 0 to 1. In addition, the B changed on day 4 from 1 to 0. According to my understanding of your idea, there should be three rows for this individual in the overall table and they are:

row one: A=0, B=1, start=0, stop=4

row two: A=0, B=0, start=4, stop=7

row three A=1, B=0, start=7, stop=14

You're welcome.

In a situation with discrete (integer) times *t _{1}*,

So, if you know that "B changed * on* day 4 from 1 to 0," (

start stop A B 0 3 0 1 3 6 0 0 6 14 1 0

If the event or censoring time of that individual was day 7, the third observation would have stop=7 (and the corresponding value of the variable indicating event or censoring, not shown above). Thus, the model would take the potential impact of A=1 on the occurrence probability of the event into account since start=6<7=stop.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks for the notice, @FreelanceReinh

Great! And I have one more question. If the two time-varying variables change on the same day (tie), how do we count them? Only two rows with a same start and stop time? Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@TomHsiung wrote:

If the two time-varying variables change on the same day (tie), how do we count them? Only two rows with a same start and stop time?

The general pattern is always the same: Each row represents a semiclosed time interval (start, stop] in which the time-varying variables are constant. If in the previous example not only B changed * on* day 4 from 1 to 0, but also A from 0 to 1 (and remained constant thereafter), we would specify:

start stop A B 0 3 0 1 3 14 1 0

So, up to and including day 3 the "vector" (A, B)=(0, 1), whereas after day 3, i.e., on days 4, 5, ..., 14, (A, B)=(1, 0).

**Available on demand!**

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.