sim.weibull.intcox.rfc <-function (N=200,beta.0=0.1,beta.cov=c(0.5,-0.5,0.5,0.5),alpha=0.75,p.cov=c(0.5,0.75),grid=10)
{
x.design<-cbind(rbinom(N,1,p.cov[1]),rbinom(N,1,p.cov[2]),runif(N,-1,1),rnorm(N,0,1))
colnames(x.design)<-paste("x.",1:4,sep="")
lambda<-exp(beta.0+x.design%*%matrix(beta.cov,ncol=1))
scale<-(1/lambda)^(1/alpha)
t.true<-rweibull(N,alpha,scale)
T.max<-max(qweibull(0.9,alpha,median(scale)))
t.left<-NULL
t.right<-NULL
for (i in 1:N) {
tt<-unique(c(0,sort(runif(grid,0,T.max)),T.max))
if (t.true[i]>=T.max) {
x.left<-T.max
x.right<-NA
} else {
x.left<-max(tt[t.true[i]>tt])
x.right<-min(tt[t.true[i]<tt])
}
t.left<-c(t.left,x.left)
t.right<-c(t.right,x.right)
}
return(data.frame(ID=1:N,left=t.left,right=t.right,x.design))
}
data(intcox.example)
Run the code above in your browser using DataLab