coxed
coxed copied to clipboard
simulation issue
Dear Dr. Kropko,
I recently used the “sim.survdata” function in “coxed” package written by you and got a problem. If you could help me with it that would be great.
I did 2k simulations using “sim.survdata” with one covariate and coefficient = 1. Each time I fitted a Cox regression and recorded the estimated beta and 95% CI. However the mean(betahat) doesn't equal to 1, and CIs do not cover 1 at 95% times. Please see the codes I used below. Thank you very much in advance.
bhat=NULL
lb=NULL
ub=NULL
for(i in 1:2000){
set.seed(20110312+i)
simdata <- sim.survdata(N=2633, T=200, xvars=1, censor=.85, num.data.frames = 1, beta = 1)
simdata$data$event=as.numeric(simdata$data$failed)
fit=coxph(Surv(y,event==1)~X,data=simdata$data)
bhat=c(bhat,summary(fit)$coefficients[1])
lb=c(lb,log(summary(fit)$conf.int[3]))
ub=c(ub,log(summary(fit)$conf.int[4]))
}
mean(bhat)
[1] 0.9408025
mean(lb<=1 & ub>=1)
[1] 0.904