# NOT RUN {
#Simulated data
alpha = 0.5
d = simulate_CR_data(n=4,m=50,alpha=alpha,beta1=c(0.7,-0.7,-0.5)*1/alpha,
beta2=c(0.5,-0.5,1),betaC=c(2,-2,1)*1/alpha,lambdaC=0.59)
#Note: Since est.t=TRUE, model1 through model4 below will also output the
#estimates of cumulative baseline hazard, adjusted probabilities and predicted
#probabilities along with their standard errors.
#Stratified Model for the main cause and stratified model for censoring
model1 <- crrscCOX(times=d[,1],causes=d[,2],covariates=d[,4:5],cencovariates=d[,4:5],
treatment=d[,3],clusters=d[,6],treatmentC=d[,3],stratified.model=TRUE,
est.t=TRUE,stratified.model.cens=TRUE,pre.t=sort(d$time[d$cause==1]),Z0=c(0.5,0.5))
#Unstratified Model for the main cause and stratified model for censoring
model2 <- crrscCOX(times=d[,1],causes=d[,2],covariates=d[,4:5],cencovariates=d[,4:5],
treatment=d[,3],clusters=d[,6],treatmentC=d[,3],stratified.model=FALSE,
stratified.model.cens=TRUE,est.t=TRUE,pre.t=sort(d$time[d$cause==1]),Z0=c(0.5,0.5))
#Stratified Model for the main cause and unstratified model for censoring
model3 <- crrscCOX(times=d[,1],causes=d[,2],covariates=d[,4:5],cencovariates=d[,4:5],
treatment=d[,3],clusters=d[,6],stratified.model=TRUE,
est.t=TRUE,stratified.model.cens=FALSE,pre.t=sort(d$time[d$cause==1]),Z0=c(0.5,0.5))
#Unstratified Model for the main cause and unstratified model for censoring
model4 <- crrscCOX(times=d[,1],causes=d[,2],covariates=d[,4:5],cencovariates=d[,4:5],
treatment=d[,3],clusters=d[,6],stratified.model=FALSE,
stratified.model.cens=FALSE,est.t=TRUE,pre.t=sort(d$time[d$cause==1]),Z0=c(0.5,0.5))
#Now set est.t=FALSE which means the cumulative baseline hazard estimate, adjusted
#probabilities and predicted cumulative incidence are not returned.
#Assume only continuous covariates are available for main cause and censoring.
#In this case both stratified.model and stratified.model.cens need to be FALSE.
model5 <- crrscCOX(times=d[,1],causes=d[,2],covariates=d[,4:5],cencovariates=d[,4:5],
clusters=d[,6],stratified.model=FALSE,stratified.model.cens=FALSE,est.t=FALSE)
# }
Run the code above in your browser using DataLab