BookmarkSubscribeRSS Feed
rdemass
Fluorite | Level 6

I am fitting a Cox PH model and have identified I need to allow my predictor group (1/0 indicator) effect to vary over time. I first tried, in general syntax:

 

proc phreg data = data;
model time*status(0) = groupt;
groupt = group*time;
run;

 

However, I do not think that is flexible enough. I would like to further allow the slope given by group*time to change at say time=25. I would call this a 'knot'.

What is the appropriate syntax and code to use to make this happen?

 

I understand I could make a piecewise function, but conceptually this would have the effect of group be the same in a time period, and then change to a different, static effect in a different time period. I am wanting the effect of group to change over time at rate 'a' in time period 'a', and then the effect of group to change over time at rate 'b' in time period 'b'.

3 REPLIES 3
Season
Lapis Lazuli | Level 10

There is an issue regarding your code that I would like to point out: as is the case in many other Cox models with time-dependent variables, the functional form you employed in your code is the product of the independent variable whose effect is something you are interested in and the variable of time, a structure similar to that of an interaction term. But you left out the "main effects" in the Cox model. I do not think this practice a good choice.

As for the very question you raised, I would like to say that fitting piecewise linear models is an interesting idea. But could you please provide us with existing studies demonstrating the plausibility of adopting the very approach you mentioned? In addition, how would you find the position of the turning point of the slope of the time-dependent variable, or in your words, the "knot"?

rdemass
Fluorite | Level 6

I am still looking for a good reference on including plausibility of the approach. As an informal reference, consider pg.23 of timedep.pdf (r-project.org) where there is a model fitted with a time-dependent coefficient and knots included for time. This is what I am trying to do, but implementing this approach in SAS (whereas the linked is in R). In terms of finding the position of the knot, one idea would be considering a plot of log(time) vs log(cumulative hazard) and finding a point where the lines strongly deviate from parallelism. Or maybe looking at a Schoenfeld residual plot to inform (also discussed in linked vignette).

Season
Lapis Lazuli | Level 10

Hello. I am personally working on time-dependent variables in Cox models as well and have happened to read papers involving the functional form of time-dependent variables. It has been stated in Multiple imputation in Cox regression when there are time‐varying effects of covariates - Keogh - 20... that functional forms as flexible as restricted cubic splines can be used for time-dependent variables in Cox models. The functional form you mentioned is in nature piecewise linear, so I think it is also plausible to adopt.

There is another issue I would like to mention: I think that in your case, starting from splines instead of adopting a piecewise linear functional form directly is a better choice. This can convince readers of your research results of the underlying rationale with respect to your selection of functional form. Even if you try splines and eventually decide to adopt the piecewise linear functional form you wished to employ in the first place, the results generated from splines could be of great help in the selection of the number and position of knot(s).

By the way, the paper I mentioned concerns dealing with time-dependent variables in the presence of missing data, an issue hardly mentioned in the statistical literature. If missing values are present in your data, then it is also of use in helping you dealing with them.

A last note before I end my reply: I am sorry that I do not know the exact SAS code to realize piecewise linear time-dependent variables, but the paper I cited contains the authors' links of R codes for utilizing restricted cubic spline as the functional form of time-dependent variable. Maybe you can reference their code.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 415 views
  • 0 likes
  • 2 in conversation