I'm new to Cox regression analysis and have been following helpful advice from Therneau, Crowson and Atkinson.
I have learnt that time dependent covariates persist and that their value can be changed over time. I am dealing with a time dependent covariate that is only positive during an interval (ie. hospitalisation - where there is a specific time where this covariate starts and stops). Obviously I have entered the time of hospitalisation, but is it acceptable to enter the time the patient leaves into the model? Thus a patient's covariate for hospitalisation will be 1 for the time period of hospitalisation, and 0 before and after.
My outcome is mortality and I am looking at the effect of fever on it. Hospitalisation is entered into the model to adjust for confounding.
I am using the survival libary in R. The code for this is
df2 <- tmerge(data1 = df1, data2 = df2, id = id, hospital = tdc(hospital_start)) df2 <- tmerge(data1 = df1, data2 = df2, id = id, hospital = tdc(hospital_finish, rep(0, dim(df1)))) fit.coxph <- coxph(Surv(df2$tstart, df2$tstop, df2$death) ~ fever + hospital, data = df2)
Is this analysis appropriate, or should I only be entering the time of hospitalisation?