y <- rnorm(50)
# v.d. Waerden scores
nq <- cscores(y, type="Normal", int=TRUE)
# quantile for m=20 observations in the first group
qperm(0.1, nq, 20)
# Table 9.19 StaXact-4 manual: lung cancer clinical trial
time <- c(257, 476, 355, 1779, 355, 191, 563, 242, 285, 16, 16, 16, 257, 16)
cens <- c(0,0,1,1,0,1,1,1,1,1,1,1,1,1)
# round logrank scores
scores <- cscores.Surv(cbind(time, cens))
T <- sum(scores[1:5])
system.time(prob <- pperm(T, scores, m=5, al="le"))
prob
pperm(T, scores, m=5, al="tw")
# map into integers, faster
scores <- cscores.Surv(cbind(time, cens), int=TRUE)
T <- sum(scores[1:5])
system.time(prob <- pperm(T, scores, m=5, al="le"))
prob # compare with 0.001
pperm(T, scores, m=5, al="tw") # compare with 0.001
Run the code above in your browser using DataLab