I want to perform a proportional hazards model to study if job contracts were affected and became shorter/dismissal was more likely to happen after two labour reforms took place. I understand that the reforms are my independent variables, but I think that they would be time-varying variables since they only start affecting contracts once they are enforced. My time variable would be the duration of the job contract and the failure event would be contract ending. I am not sure how to approach this with Stata.

A bit more info: I have a database that spans from the late 70s to 2019 and where the units of observation are job contracts (so each “subject” . I want to know if two labour reforms that were passed in 2010 and 2012, respectively, and that reduced protection against unfair dismissal, had any effect on the duration of job contracts. The database has data on when each contract started, when it finished and the reason for it to end (ie. dismissal, retirement etc.).

I am thus interested in performing survival analysis on the duration of job contracts. I think that my independent variables, the two labour reforms, are two time varying exposure variables, since before 2010 or 2012 no contract was “exposed” to the effects of any of the reforms, then between 2010-2012 contracts are exposed to the 2010 reform and 2012 they are exposed to the 2012 reform.

I don’t have any control group, as all job contracts that were ongoing after the date the reforms I mentioned were enforced were “exposed” to them (ie. if someone was working after the labour reform was passed, the reform affected him or her, a priori). Job contracts kept starting and finishing during the time period studied (so a contract might start before the labour reform was passed and then be exposed to the reform once it is passed, while another might already start after the reform was enforced or another started and ended before the reform was passed). In addition, some contracts were ongoing when data were gathered, so they would be right-censored (they are coded as “finishing” in 2099).

So in my mind, the two labour reforms of 2010 and 2012 would be time varying variables. My units of observation, job contracts, would have a value of 0 for the variable of labour reform 2010 for most of the time, but when it started to be enforced that value would change to 1. Then, when the 2012 labour reform started to be enforced, the 2010 variable would go back to 0 value and another variable for the 2012 reform would assume a value of 1.

Besides the two labour reforms, I also suspect that the economic crisis that hit the country between 2008 and 2014 might also logically affect contracts becoming shorter or ending, so I thought I would also need to treat this as a time varying covariate that only has a value of 1 for contracts during the timespan of 2008 and 2014.

I already have a variable for the duration of job contracts, and another categorical variable if failure happened (if the contract finished and it wasn’t right censored). I thought about creating two variables for “exposure” to the labour reforms: I created a variale that was the substraction of the date the contract ended and the date the reform started to be enforced. But I don’t know what to do after that. Would really appreciate any help.


1 Answer 1


You can use time-varying covariates in a Cox model for this. For reforms enacted in 2010 and 2012, create binary variables that switch from 0 to 1 at the time each reform is implemented for each contract.

I'm a bit rusty with Stata, but you could try something like this:

Assuming duration is the variable for contract duration, failed indicates if the contract ended, start_date and end_date denote the contract period, and contract_id uniquely identifies each contract:

gen reform2010 = time >= reform2010_date
gen reform2012 = time >= reform2012_date & time < reform2012_date

gen crisis_period = year >= 2008 & year <= 2014

stset duration, failure(failed==1) id(contract_id) enter(start_date) exit(end_date)

stcox reform2010 reform2012 crisis_period, shared(contract_id)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.