# NOT RUN {
library(data.table)
# reset the default value of the number of permuation sample
BuyseTest.options(method.inference = "none") # no permutation test
#### simulate some data ####
set.seed(10)
df.data <- simBuyseTest(1e2, n.strata = 2)
# display
if(require(prodlim)){
resKM_tempo <- prodlim(Hist(eventtime,status)~treatment, data = df.data)
plot(resKM_tempo)
}
#### one time to event endpoint ####
BT <- BuyseTest(treatment ~ TTE(eventtime, status = status), data= df.data)
summary(BT) # net benefit
summary(BT, percentage = FALSE)
summary(BT, statistic = "winRatio") # win Ratio
## bootstrap to compute the CI
# }
# NOT RUN {
BT <- BuyseTest(treatment ~ TTE(eventtime, status = status), data=df.data,
method.inference = "permutation", n.resampling = 1e3)
# }
# NOT RUN {
summary(BT, statistic = "netBenefit") ## default
summary(BT, statistic = "winRatio")
## parallel bootstrap
# }
# NOT RUN {
BT <- BuyseTest(treatment ~ TTE(eventtime, status = status), data=df.data,
method.inference = "permutation", n.resampling = 1e3, cpus = 2)
summary(BT)
# }
# NOT RUN {
## method Gehan is much faster but does not optimally handle censored observations
BT <- BuyseTest(treatment ~ TTE(eventtime, status = status), data=df.data,
scoring.rule = "Gehan", trace = 0)
summary(BT)
#### one time to event endpoint: only differences in survival over 1 unit ####
BT <- BuyseTest(treatment ~ TTE(eventtime, threshold = 1, status = status), data=df.data)
summary(BT)
#### one time to event endpoint with a strata variable
BT <- BuyseTest(treatment ~ strata + TTE(eventtime, status = status), data=df.data)
summary(BT)
#### several endpoints with a strata variable
f <- treatment ~ strata + T(eventtime, status, 1) + B(toxicity)
f <- update(f,
~. + T(eventtime, status, 0.5) + C(score, 1) + T(eventtime, status, 0.25))
BT <- BuyseTest(f, data=df.data)
summary(BT)
#### real example : Veteran dataset of the survival package ####
#### Only one endpoint. Type = Time-to-event. Thresold = 0. Stratfication by histological subtype
#### scoring.rule = "Gehan"
if(require(survival)){
# }
# NOT RUN {
data(veteran,package="survival")
## scoring.rule = "Gehan"
BT_Gehan <- BuyseTest(trt ~ celltype + TTE(time,threshold=0,status=status),
data=veteran, scoring.rule="Gehan")
summary_Gehan <- summary(BT_Gehan)
summary_Gehan <- summary(BT_Gehan, statistic = "winRatio")
## scoring.rule = "Peron"
BT_Peron <- BuyseTest(trt ~ celltype + TTE(time,threshold=0,status=status),
data=veteran, scoring.rule="Peron")
class(BT_Peron)
summary(BT_Peron)
# }
# NOT RUN {
}
# }
Run the code above in your browser using DataLab