# NOT RUN {
# import and attach the data example
data(dataCSL)
dataCSL <- dataCSL[order(dataCSL$id, dataCSL$time),]
dataCSL$ordre <-0
for (i in unique(dataCSL$id))
{dataCSL$ordre[dataCSL$id==i] <- 1:sum(dataCSL$id==i)}
dataCSL$ttt[dataCSL$treat==0]<-"A"
dataCSL$ttt[dataCSL$treat==1]<-"B"
dataCSL0 <- dataCSL[dataCSL$ordre==1,]
dataCSL0<-dataCSL0[,c(1,4,5,14,9)]
# the expected utility function for a prognostic up to 8 years
EUt.obj <- expect.utility2(dataCSL0$eventT, dataCSL0$dc,
dataCSL0$prot.base, treatment= dataCSL0$ttt,
pro.time=8, u.A0=0.75*0.95, u.A1=0, u.B0=0.75, u.B1=0)
plot(EUt.obj$table$cut.off, EUt.obj$table$utility, type="l",
xlab="Cut-off values", ylab="Expected utility",col=1, lty=1)
segments(EUt.obj$estimation, 0, EUt.obj$estimation, EUt.obj$max.eu, lty=3)
segments(0, EUt.obj$max.eu, EUt.obj$estimation, EUt.obj$max.eu, lty=3)
text(EUt.obj$estimation-2, 3.38,
paste("Optimal cut-off=",round(EUt.obj$estimation,2)), srt=90, cex=0.8)
text(min(dataCSL0$prot.base)+40, EUt.obj$max.eu-0.005,
paste("Expected utility=",round(EUt.obj$max.eu,2)), cex=0.8)
# the optimal cut-off: patients with an higher value should receive the treatment A
EUt.obj$estimation
# }
Run the code above in your browser using DataCamp Workspace