# Comparing coefficient across datasets - Cox Proportional Hazard model

I am doing a study of credit risk in europe for the period of 2006 - 2016 by using the Cox Proportional Hazard Model (time costant edition) in R (coxph). I have succesfully implemented the model for the whole period with 8 independent variables.

Now I want to make 2 subgroups (2006 - 2010 and 2011 - 2016) in order to compare the coefficients between the two subgroups. I have created a dataset of the sub groups by with a dummy variable (Subgroup) so that 2006 - 2010 = 0 and 2011 - 2016 = 1.

What is the next step in the analysis in order to compare the coefficients in the two sub groups?

I dont know if i have done it correctly in the code below?

R takes care of creating dummy variables. You just need to include qualitative predictor in formula inside coxph.

E.g. if X and Y are quantitative and Z is qualitative,

coxph(Surv(time, status) ~ X + Y + Z)


should work.

You may also add interactions to check if Z affects coefficients of X and y:

coxph(Surv(time, status) ~ X + Y + Z + X:Z + Y:Z)

• Thank you @Łukasz - could you please be a bit more specific? The following is from my model covering the whole period (2006 - 2016): cox.FINAL<-coxph(Surv(N, Konkurs) ~ ROA+GDP+LIBOR+PCL.TA+VIX+DEPTA,data=CoxData) – Oliver Langkilde Sonne Jun 23 '17 at 12:52
• I assume that in CoxDatayou have a variable called YEAR or somthing similar. First, you have to cut it to get subgroups (2006 - 2010 and 2011 - 2016) : CoxData$YEARCUT<-cut(CoxData$YEAR, c(2006,2010,2016), include.lowest=T and then use it in coxph: coxph(Surv(N, Konkurs) ~ ROA+GDP+LIBOR+PCL.TA+VIX+DEPTA+YEARCUT,data=CoxData) – Łukasz Deryło Jun 23 '17 at 12:57
• This solution doesn't work for me. The variable N in my cox model is the time to event / censoring. I have constructed my dataset in excel and imported to R afterwards. So i dont have the "years" variable. I have created the sub datasets manually - how do i compare coefficients now? Thank you in advance ! – Oliver Langkilde Sonne Jun 23 '17 at 13:47
• Add YEAR variable to your Excel – Łukasz Deryło Jun 23 '17 at 14:20
• I am sorry, but is not possible to make a clear cut like that. Constructing a dataset for this purpose must be constructed in a speciale manner. The time to event variable must be present. But i have found another solution on how to implement the dummy variable. Could you please help me with the comparison of coefficients? – Oliver Langkilde Sonne Jun 23 '17 at 14:31