Can you use survival analysis on subjects spanning two separate time periods?

I have a dataset where the subjects are job contracts. It spans from the 80s to 2019. Each contract has a start of contract and end of contract date, unless they were still active in 2019 in which case their end of contract date is "2099". I want to use survival analysis for the duration of contracts during different time periods for the contracts: I want to take the duration of contracts during the time period 2004-2008 and then during the time period 2014-2018. Thus, the event would be end of contract.

Is this feasible? If it is a special case of survival analysis, are there any resources I can read on how to proceed, or is it considered just a regular survival analysis and should just follow standard procedure?

My concern is that some job contracts span the two time periods. Does that make any difference? Are data censored only if contracts last longer than 2018, or is there any way I should take into account data as censored for the first time period if they last longer than 2008 (for example, a contract that lasted from 2005 to 2010, as I would only observe its duration from 2005 to 2008)?

Thanks a lot for the help.

This is a particular example of the more general problems that come from binning continuous variables. Instead of starting off by breaking the data into time periods, consider using the contract start date itself as a continuous predictor. I think that will overcome most or all of your problems.

For each contract, set the time = 0 reference to its contract start date. Then the "survival time" for each contract is its actual duration (except for those still in place in 2019 and coded "2099" in your data set; those are right-censored observations). Model the contract start date flexibly, for example with a regression spline.

With that model, you directly evaluate contract duration without having to worry about crossing arbitrary boundaries between time periods. All contracts that have ended would have their exact durations evaluated. After you have the model, you can then contrast any particular start dates to examine differences associated with the calendar date of the contract start.

• If I understand you correctly, I should use the contract duration (date contract ended-date contract started) as the time variable, with those coded 2099 as right censored. Then, if I follow, should I include as failure event the fact that the contract ended between the dates that form my periods of interest? For instance, each contract would be considered to have failure if it ended between 2004 and 2008 or 2014 and 2018, with the rest having censored data. I have never used spline regression, so I'll read about it. Thank so much for your help. Oct 12, 2023 at 11:44
• @Pointed yes, I think that you understand correctly. For each contract that ended, the survival time is the total duration of the contract, with an "event/failure" indicated. For contracts still in effect and coded "2099" the survival time is the duration of the contract through the last observation, with a right-censoring indicator.
– EdM
Oct 12, 2023 at 14:53

You have a 'time varying covariate' in that the 'period' variable changes over time and individual contracts can change within individuals.

The typical way to handle this is to split individuals into separate observations every time their covariate changes, with censoring and delayed entry as appropriate.

So yes your 2005-2010 contract would be replaced with a contract starting at 2005 censored in 2008. Since you're not interested in the period 2008-2010 you can discard that part.

It seems to me you intend to do two separate analyses for the two periods. You probably should look at both period as completely independent.

Deciding whether to consider, in the analysis of the second period, a contract that starts in the first period and ends inside the second period is up to you. It depends on the definition of your study design: time range of follow-up period, criteria of inclusion for each period.

To be clear, let's consider the period 2014-2018, it's reasonable that you decide to include only contracts starting after the beginning of 2014, if you think the contracts starting prior that year are not of interest or that would give wrong results in the analysis.

I agree with @George that you need to look at the problem using time-varying covariate. Here it's a good tutorial in R for time-dependent covariate in survival analysis. The design of study and statistical analysis are not very simple, so if you can find someone who can help you I recommend you ask them!

• I think my issue would be that if I'm considering the period 2014-2018 (or 2004-2008, for that matter) I do want to consider contracts starting before 2014, since I'm interested in knowing if contract became shorter during that period. So if I only include contracts starting after 2014 I'm only including "new" contracts which might give me some bias (a labour reform took place, so maybe new contracts are less protected against redundancy, for instance). I use Stata, do you know anywhere where I can read about time-varying covariates? Thanks a lot! Oct 12, 2023 at 11:48
• In this case, it seems to me you want to include any contract that started up 01/01/2014. Then you want to see if the hazard of a contract concluding is higher in the period 2014-2018, compared to previous periods. It seems an interesting analysis, good luck! The function stcox in Stata should work for you (tutorial) however, remember you need to make sure your data are in the right format. Oct 16, 2023 at 13:43
• I would add that what you are doing looks like a kind difference-in-difference cox analysis. I am not familiar with this type of analysis, but I quickly found this question (here). Oct 16, 2023 at 13:48
• In my opinion and without any specific search, if you want to see if the hazard changes in a specific period you could define a time-varying indicator variable for the period (0=before 2014, 1=2014-2018) and put it your cox model. Your estimated beta would represent the difference in the hazard between periods. Oct 16, 2023 at 13:53
• Yes, I was actually reading about time-varying variables and thought they could be helpful. In fact, as including the two reforms that took place in 2010 and 2012 would make for a finer analysis, I was thinking of including a time-varying variable with 0 before 2010, 1=2010-2012 and 3=after 2012, as to include all contracts and not drop those outside the periods. Do you know any resources where I can learn about time-varying variables? Would a survival curve be able to show the differences? Thanks a lot. Oct 17, 2023 at 18:09