# NOT RUN {
# }
# NOT RUN {
library(OptimalTiming)
##################################
## Example 1: This example shows how to calculate confidence
## intervals for different treatment strategies
## read data
data(SimCml)
## fit multistate model with treatment not equals NULL
fit=optim.fit(data=SimCml,
transM=matrix(c(0,1,0,0,0,1,0,0,0,1,0,1,1,1,0,0,0,1,1,1,1,
0,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0),7,byrow=TRUE),
nstate=7,state_label=c("diagnose","cp1","ap","cp2","bc","sct","death"),
event_label=c("cp1.s","ap.s","cp2.s","bc.s","sct.s","death.s"),
treatment=c("sct","sct.s"),absorb=c("death","death.s"),
cov=c("age"),cov_value=c(0))
## compare different treatment strategies
conf.MTL(obj=fit,nsim=1000,L=120)
##################################
## Example 2: This example shows how to calculate confidence
## intervals for a given state
## read data
data(SimCml)
## delete the information of transplant time
data=SimCml[SimCml$sct.s==0,]
del=which(names(SimCml)%in%c("sct","sct.s"))
data=data[,-del]
## fit multistate model with treatment equals NULL
fit=optim.fit(data=data,
transM=matrix(c(0,1,0,0,0,0,0,0,1,0,1,1,0,0,0,
1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0),6,byrow=TRUE),
nstate=6,state_label=c("diagnose","cp1","ap","cp2","bc","death"),
absorb=c("death","death.s"),event_label=c("cp1.s","ap.s","cp2.s","bc.s","death.s"),
cov=c("age"),cov_value=c(0))
## calculate mean total lifetime and confidence intervals
## for state 1,2,3,4
conf.MTL(obj=fit,state=c(1,2,3,4),nsim=1000,L=120)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab