# Changing the baseline hazard ratio at each event in a PWP Cox model

I am performing a PWP (conditional) recurrent cox regression analysis over medical records. For each individual, events are indicated by dates in their medical record. It is, therefore very easy to generate the correct data structure for gap-time in R. The units are in days, and the tstart and tstop structure follows the same layout as Anderson-Gill Cox.

It is my understanding that any formulation of a Cox model (recurrent or otherwise, PWP, AG, etc) is to estimate the effect of covariates on the baseline hazard function, and that the baseline hazard function is consistent across time after being obtained from the start when all covariates are set to zero.

In my model, I have a few constant covariates e.g., gender, and time-dependent covariates e.g., age. I can structure the data and layout the model accordingly.

However this is the difficult part: I would like the baseline hazard ratio to be recalculated for every event. I have a probability function that calculates the probability of remission given the number of days between events i.e., the gap-time in the cox model. The outcome of this probability function per event should have an effect on the baseline hazard ratio.

Unfortunately, I have no idea how to do this! Many thanks

As i understand it strata in the survival package will let you fit separate baseline hazards for the levels of the object being stratified. So, in this case, if you have a column recording how many events there are, then strata(numberofevents) will fit a new baseline hazard between each event.
   model<- coxph(Surv(tstart,tstop,status)~IVs+strata(numberofevents)+ cluster(id),data=df)