jkropko / coxed

Duration-Based Quantities of Interest and Simulation Methods for the Cox Proportional Hazards Model
23 stars 6 forks source link

Generated survival curve does not match the KM estimate #17

Open IyarLin opened 2 years ago

IyarLin commented 2 years ago

Hi,

Thanks for writing this package - it looks very promising. I have encountered a weird behavior though: It would seem that the observations generated by sim.survdata function do not align with the baseline survival underlying it.

Below is an example:

library(survival)
library(coxed)
set.seet(1)
X <- matrix(rep(0, N), ncol = 1) # no covariates
simdata <- sim.survdata(N=10000, T=30, num.data.frames=1, X = X)
est_surv <- survfit(Surv(y,failed) ~ 1, data = simdata$data)

plot(est_surv)
points(1:length(simdata$baseline$survivor), simdata$baseline$survivor, col = "red")

image

The underlying survival seems to be somewhat lower than the actual survival of the units generated by the procedure. I would appreciate your input as to what I'm missing here.

Many thanks,

Iyar