Title: | Permutational Group Sequential Test for Time-to-Event Data |
---|---|
Description: | Permutational group-sequential tests for time-to-event data based on the log-rank test statistic. Supports exact permutation test when the censoring distributions are equal in the treatment and the control group and approximate imputation-permutation methods when the censoring distributions are different. |
Authors: | Matthias Brueckner [aut, cre], Martin Posch [aut], Franz Koenig [aut] |
Maintainer: | Matthias Brueckner <[email protected]> |
License: | GPL-3 | file LICENSE |
Version: | 0.2.5 |
Built: | 2025-03-05 03:47:02 UTC |
Source: | https://github.com/mbrueckner/permgs |
Create permGS object representing a permutational group-sequential trial.
createPermGS(B = 1000, restricted = TRUE, method = "IPZ", pool = TRUE, type = c("logrank", "Gehan-Breslow", "Tarone-Ware", "Prentice", "Prentice-Marek", "Andersen-Borgan-Gill-Keiding", "Fleming-Harrington", "Self"), imputeData = NULL, permuteData = NULL)
createPermGS(B = 1000, restricted = TRUE, method = "IPZ", pool = TRUE, type = c("logrank", "Gehan-Breslow", "Tarone-Ware", "Prentice", "Prentice-Marek", "Andersen-Borgan-Gill-Keiding", "Fleming-Harrington", "Self"), imputeData = NULL, permuteData = NULL)
B |
number of random permutations |
restricted |
if TRUE only permute within strata |
method |
imputation/permuation method IPZ, IPT, Heinze or none (default: IPZ) |
pool |
if TRUE impute event times from Kaplan-Meier estimator calculated from pooled data |
type |
logrank weights to be used with coin::logrank_trafo |
imputeData |
user-supplied imputation function (ignored if method is given) |
permuteData |
user-supplied permutation function (ignore if method is given) |
object of class permGS
## standard permutation test (no imputation, free permutations) x <- createPermGS(1000, FALSE, "none") summary(x) ## imputation using IPT method, restricted permutations y <- createPermGS(1000, TRUE, "IPT") summary(y)
## standard permutation test (no imputation, free permutations) x <- createPermGS(1000, FALSE, "none") summary(x) ## imputation using IPT method, restricted permutations y <- createPermGS(1000, TRUE, "IPT") summary(y)
One-sided exact / approximate permutation and asymptotic log-rank test
exactLR(B, formula, data = parent.frame(), type = "exact")
exactLR(B, formula, data = parent.frame(), type = "exact")
B |
number of random permutations (only used if type="approximate") |
formula |
a formula object, as used by |
data |
data.frame or list containing the variables in "formula", by default "formula" is evaluated in the parent frame |
type |
if type="exact" performs complete enumeration of all permutations, if type="approximate" draw random permutations, if type="asymptotic" perform asymptotic log-rank test |
This function performs a standard exact or approximate permutation test which is only valid under the extended null hypothesis of equal survival AND censoring distributions.
A list containing the exact or approximate permutation p-value and the observed test statistic
T <- rexp(20) C <- rexp(20) data <- data.frame(time=pmin(T, C), status=(T<=C), trt=rbinom(20, 1, 0.5)) # Approximate permutation test using 1000 random permutations x <- exactLR(1000, Surv(time, status) ~ trt, data, "approximate") print(paste("Approximate permutation p-value:", x$p)) # Exact permutation test y <- exactLR(0, Surv(time, status) ~ trt, data, "exact") print(paste("Exact permutation p-value:", y$p))
T <- rexp(20) C <- rexp(20) data <- data.frame(time=pmin(T, C), status=(T<=C), trt=rbinom(20, 1, 0.5)) # Approximate permutation test using 1000 random permutations x <- exactLR(1000, Surv(time, status) ~ trt, data, "approximate") print(paste("Approximate permutation p-value:", x$p)) # Exact permutation test y <- exactLR(0, Surv(time, status) ~ trt, data, "exact") print(paste("Exact permutation p-value:", y$p))
Impute data according to Heinze et al. method. Output is supposed to be passed to permute.heinze
imputeHeinze(data, pool = TRUE)
imputeHeinze(data, pool = TRUE)
data |
matrix as returned by as.matrix(generateData(param)) |
pool |
if TRUE impute events times from pooled Kaplan-Meier estimator (default: TRUE) |
list containing Kaplan-Meier estimators of censoring and survival distributions and the original data
Heinze, G., Gnant, M. and Schemper, M. Exact Log-Rank Tests for Unequal Follow-Up. Biometrics, 59(4), December 2003.
Impute data according to IPT method. Output is supposed to be passed to permute.IPT
imputeIPT(data, pool = TRUE)
imputeIPT(data, pool = TRUE)
data |
matrix as returned by as.matrix(generateData(param)) |
pool |
if TRUE impute events times from pooled Kaplan-Meier estimator (default: TRUE) |
matrix containing imputed survival and censoring times (columns 1 and 2), and original treatment indicator (column 3)
Wang, R., Lagakos, S.~W. and Gray, R.~J. Testing and interval estimation for two-sample survival comparisons with small sample sizes and unequal censoring. Biostatistics, 11(4), 676–692, January 2010.
Impute data according to IPZ method. Output is supposed to be passed to permute.IPZ
imputeIPZ(data, pool = TRUE)
imputeIPZ(data, pool = TRUE)
data |
matrix as returned by as.matrix(generateData(param)) |
pool |
if TRUE impute events times from pooled Kaplan-Meier estimator (default: TRUE) |
original data with 4 new columns (V1 and V2) containing the imputed observations
Wang, R., Lagakos, S.~W. and Gray, R.~J. Testing and interval estimation for two-sample survival comparisons with small sample sizes and unequal censoring. Biostatistics, 11(4), 676–692, January 2010.
Imputation permutation group-sequential log-rank test. Random permutations of a block a reused in all later stages. This automatically results in blockwise permutations.
nextStage(pgs.obj, alpha, formula, data = parent.frame())
nextStage(pgs.obj, alpha, formula, data = parent.frame())
pgs.obj |
permGS object as returned by |
alpha |
alpha at current stage |
formula |
a formula object, as used by |
data |
a data.frame or list containing the variables in "formula", by default "formula" is evaluated in the parent frame |
An updated permGS object.
## Two-stage design with one-sided O'Brien-Fleming boundaries using IPZ method x <- createPermGS(1000, TRUE, "IPZ") t1 <- 9 ## calendar time of interim analysis t2 <- 18 ## calendar time of final analysis T <- rexp(100) ## event times R <- runif(100, 0, 12) ## recruitment times Z <- rbinom(100, 1, 0.5) ## treatment assignment C <- rexp(100) ## drop-out times ## Stage 1 data data.t1 <- data.frame(time=pmin(T, C, max(0, (t1-R))), status=(T<=pmin(C, t1-R)), trt=Z) data.t1 <- data.t1[R <= t1,] ## Stage 2 data data.t2 <- data.frame(time=pmin(T, C, max(0, (t2-R))), status=(T<=pmin(C, t2-R)), trt=Z) data.t2 <- data.t2[R <= t2,] x <- nextStage(x, 0.00153, Surv(time, status) ~ trt, data.t1) summary(x) if(!x$results$reject[1]) { data.t2$strata <- rep.int(c(1,2), c(nrow(data.t1), nrow(data.t2)-nrow(data.t1))) x <- nextStage(x, 0.025, Surv(time, status) ~ trt + strata(strata), data.t2) summary(x) }
## Two-stage design with one-sided O'Brien-Fleming boundaries using IPZ method x <- createPermGS(1000, TRUE, "IPZ") t1 <- 9 ## calendar time of interim analysis t2 <- 18 ## calendar time of final analysis T <- rexp(100) ## event times R <- runif(100, 0, 12) ## recruitment times Z <- rbinom(100, 1, 0.5) ## treatment assignment C <- rexp(100) ## drop-out times ## Stage 1 data data.t1 <- data.frame(time=pmin(T, C, max(0, (t1-R))), status=(T<=pmin(C, t1-R)), trt=Z) data.t1 <- data.t1[R <= t1,] ## Stage 2 data data.t2 <- data.frame(time=pmin(T, C, max(0, (t2-R))), status=(T<=pmin(C, t2-R)), trt=Z) data.t2 <- data.t2[R <= t2,] x <- nextStage(x, 0.00153, Surv(time, status) ~ trt, data.t1) summary(x) if(!x$results$reject[1]) { data.t2$strata <- rep.int(c(1,2), c(nrow(data.t1), nrow(data.t2)-nrow(data.t1))) x <- nextStage(x, 0.025, Surv(time, status) ~ trt + strata(strata), data.t2) summary(x) }
Parse formula of survival model
parseFormula(formula, data = parent.frame())
parseFormula(formula, data = parent.frame())
formula |
formula object |
data |
data.frame (optional) |
data.frame containing the parsed variables
This package implements permutational group-sequential tests for time-to-event data based on (weighted) log-rank test statistics. It supports exact permutation test when the censoring distributions are equal in the treatment and the control group and the approximate imputation-permutation methods of Heinze et al. (2003) and Wang et al. (2010) and when the censoring distributions are different. Permutations can be stratified, i.e. only patients within the same stratum are treated as exchangeable. Rejection boundaries are monotone and finite even when only a random subset of all permutations is used. One- and Two-sided testing possible.
Matthias Brueckner [email protected], Franz Koenig [email protected], Martin Posch [email protected]
Brueckner, M., Koenig, F. and Posch, M. Group-sequential permutation tests for time-to-event data.
Heinze, G., Gnant, M. and Schemper, M. Exact Log-Rank Tests for Unequal Follow-Up. Biometrics, 59(4), December 2003.
Wang, R., Lagakos, S.~W. and Gray, R.~J. Testing and interval estimation for two-sample survival comparisons with small sample sizes and unequal censoring. Biostatistics, 11(4), 676–692, January 2010.
Kelly, P., Zhou, Y., Whitehead, N. J., Stallard, N. and Bowman, C. Sequentially testing for a gene–drug interaction in a genomewide analysis. Statistics in Medicine, 27(11), 2022–2034, May 2008.
## IPZ method based on logrank test with 1000 restricted random permutations x <- createPermGS(1000, TRUE, "IPZ", type="logrank") T <- rexp(100) ## event times R <- runif(100, 0, 12) ## recruitment times Z <- rbinom(100, 1, 0.5) ## treatment assignment C <- rexp(100) ## drop-out times ## two-stage design t1 <- 9 ## calendar time of interim analysis t2 <- 18 ## calendar time of final analysis ## Stage 1 data.t1 <- data.frame(time=pmin(T, C, max(0, (t1-R))), status=(T<=pmin(C, t1-R)), trt=Z) data.t1 <- data.t1[R <= t1,] x <- nextStage(x, 0.00153, Surv(time, status) ~ trt, data.t1) summary(x) if(!x$results$reject[1]) { ## Stage 2 data.t2 <- data.frame(time=pmin(T, C, max(0, (t2-R))), status=(T<=pmin(C, t2-R)), trt=Z) data.t2 <- data.t2[R <= t2,] data.t2$strata <- rep.int(c(1,2), c(nrow(data.t1), nrow(data.t2)-nrow(data.t1))) x <- nextStage(x, alpha=0.025, Surv(time, status) ~ trt + strata(strata), data.t2) summary(x) }
## IPZ method based on logrank test with 1000 restricted random permutations x <- createPermGS(1000, TRUE, "IPZ", type="logrank") T <- rexp(100) ## event times R <- runif(100, 0, 12) ## recruitment times Z <- rbinom(100, 1, 0.5) ## treatment assignment C <- rexp(100) ## drop-out times ## two-stage design t1 <- 9 ## calendar time of interim analysis t2 <- 18 ## calendar time of final analysis ## Stage 1 data.t1 <- data.frame(time=pmin(T, C, max(0, (t1-R))), status=(T<=pmin(C, t1-R)), trt=Z) data.t1 <- data.t1[R <= t1,] x <- nextStage(x, 0.00153, Surv(time, status) ~ trt, data.t1) summary(x) if(!x$results$reject[1]) { ## Stage 2 data.t2 <- data.frame(time=pmin(T, C, max(0, (t2-R))), status=(T<=pmin(C, t2-R)), trt=Z) data.t2 <- data.t2[R <= t2,] data.t2$strata <- rep.int(c(1,2), c(nrow(data.t1), nrow(data.t2)-nrow(data.t1))) x <- nextStage(x, alpha=0.025, Surv(time, status) ~ trt + strata(strata), data.t2) summary(x) }
Convenience function which calls createPermGS and nextStage to perform fixed sample size permutation test with Heinze method
permHeinze(formula, data, B = 1000, alpha = 0.05, pool = TRUE, type = c("logrank", "Gehan-Breslow", "Tarone-Ware", "Prentice", "Prentice-Marek", "Andersen-Borgan-Gill-Keiding", "Fleming-Harrington", "Self"))
permHeinze(formula, data, B = 1000, alpha = 0.05, pool = TRUE, type = c("logrank", "Gehan-Breslow", "Tarone-Ware", "Prentice", "Prentice-Marek", "Andersen-Borgan-Gill-Keiding", "Fleming-Harrington", "Self"))
formula |
a formula object, as used by |
data |
a data.frame or list containing the variables in "formula", by default "formula" is evaluated in the parent frame |
B |
number of random permutations (default: 1000) |
alpha |
significance level (default: 0.05) |
pool |
if TRUE impute event times from Kaplan-Meier estimator calculated from pooled data |
type |
logrank weights to be used with coin::logrank_trafo |
An object of class permGS
T <- rexp(30) ## event times Z <- rbinom(30, 1, 0.5) ## treatment assignment C <- rexp(30) ## drop-out times data <- data.frame(time=pmin(T,C), status=T<=C, Z=Z) x <- permHeinze(Surv(time, status) ~ Z, data) summary(x)
T <- rexp(30) ## event times Z <- rbinom(30, 1, 0.5) ## treatment assignment C <- rexp(30) ## drop-out times data <- data.frame(time=pmin(T,C), status=T<=C, Z=Z) x <- permHeinze(Surv(time, status) ~ Z, data) summary(x)
Convenience function which calls createPermGS and nextStage to perform fixed sample size permutation test with IPT method
permIPT(formula, data, B = 1000, alpha = 0.05, pool = TRUE, type = c("logrank", "Gehan-Breslow", "Tarone-Ware", "Prentice", "Prentice-Marek", "Andersen-Borgan-Gill-Keiding", "Fleming-Harrington", "Self"))
permIPT(formula, data, B = 1000, alpha = 0.05, pool = TRUE, type = c("logrank", "Gehan-Breslow", "Tarone-Ware", "Prentice", "Prentice-Marek", "Andersen-Borgan-Gill-Keiding", "Fleming-Harrington", "Self"))
formula |
a formula object, as used by |
data |
a data.frame or list containing the variables in "formula", by default "formula" is evaluated in the parent frame |
B |
number of random permutations (default: 1000) |
alpha |
significance level (default: 0.05) |
pool |
if TRUE impute event times from Kaplan-Meier estimator calculated from pooled data |
type |
logrank weights to be used with coin::logrank_trafo |
An object of class permGS
T <- rexp(30) ## event times Z <- rbinom(30, 1, 0.5) ## treatment assignment C <- rexp(30) ## drop-out times data <- data.frame(time=pmin(T,C), status=T<=C, Z=Z) x <- permIPT(Surv(time, status) ~ Z, data) summary(x)
T <- rexp(30) ## event times Z <- rbinom(30, 1, 0.5) ## treatment assignment C <- rexp(30) ## drop-out times data <- data.frame(time=pmin(T,C), status=T<=C, Z=Z) x <- permIPT(Surv(time, status) ~ Z, data) summary(x)
Convenience function which calls createPermGS and nextStage to perform fixed sample size permutation test with IPZ method
permIPZ(formula, data, B = 1000, alpha = 0.05, pool = TRUE, type = c("logrank", "Gehan-Breslow", "Tarone-Ware", "Prentice", "Prentice-Marek", "Andersen-Borgan-Gill-Keiding", "Fleming-Harrington", "Self"))
permIPZ(formula, data, B = 1000, alpha = 0.05, pool = TRUE, type = c("logrank", "Gehan-Breslow", "Tarone-Ware", "Prentice", "Prentice-Marek", "Andersen-Borgan-Gill-Keiding", "Fleming-Harrington", "Self"))
formula |
a formula object, as used by |
data |
a data.frame or list containing the variables in "formula", by default "formula" is evaluated in the parent frame |
B |
number of random permutations (default: 1000) |
alpha |
significance level (default: 0.05) |
pool |
if TRUE impute event times from Kaplan-Meier estimator calculated from pooled data |
type |
logrank weights to be used with coin::logrank_trafo |
An object of class permGS
T <- rexp(30) ## event times Z <- rbinom(30, 1, 0.5) ## treatment assignment C <- rexp(30) ## drop-out times data <- data.frame(time=pmin(T,C), status=T<=C, Z=Z) x <- permIPZ(Surv(time, status) ~ Z, data) summary(x)
T <- rexp(30) ## event times Z <- rbinom(30, 1, 0.5) ## treatment assignment C <- rexp(30) ## drop-out times data <- data.frame(time=pmin(T,C), status=T<=C, Z=Z) x <- permIPZ(Surv(time, status) ~ Z, data) summary(x)
Convenience function which calls createPermGS and nextStage to perform fixed sample size permutation test without imputation
permLR(formula, data, B = 1000, alpha = 0.05, pool = TRUE, type = c("logrank", "Gehan-Breslow", "Tarone-Ware", "Prentice", "Prentice-Marek", "Andersen-Borgan-Gill-Keiding", "Fleming-Harrington", "Self"))
permLR(formula, data, B = 1000, alpha = 0.05, pool = TRUE, type = c("logrank", "Gehan-Breslow", "Tarone-Ware", "Prentice", "Prentice-Marek", "Andersen-Borgan-Gill-Keiding", "Fleming-Harrington", "Self"))
formula |
a formula object, as used by |
data |
a data.frame or list containing the variables in "formula", by default "formula" is evaluated in the parent frame |
B |
number of random permutations (default: 1000) |
alpha |
significance level (default: 0.05) |
pool |
if TRUE impute event times from Kaplan-Meier estimator calculated from pooled data |
type |
logrank weights to be used with coin::logrank_trafo |
An object of class permGS
## Two-sided permutation test T <- rexp(100) ## event times Z <- rbinom(100, 1, 0.5) ## treatment assignment C <- rexp(100) ## drop-out times data <- data.frame(time=pmin(T,C), status=T<=C, Z=Z) x <- permLR(Surv(time, status) ~ Z, data, alpha=c(0.025, 0.025)) summary(x)
## Two-sided permutation test T <- rexp(100) ## event times Z <- rbinom(100, 1, 0.5) ## treatment assignment C <- rexp(100) ## drop-out times data <- data.frame(time=pmin(T,C), status=T<=C, Z=Z) x <- permLR(Surv(time, status) ~ Z, data, alpha=c(0.025, 0.025)) summary(x)
Perform single imputation and permutation step
permuteHeinze(imp, pp, index = TRUE)
permuteHeinze(imp, pp, index = TRUE)
imp |
list as returned by impute.heinze |
pp |
vector of permuted indices |
index |
not used |
matrix with time, status, trt columns
Heinze, G., Gnant, M. and Schemper, M. Exact Log-Rank Tests for Unequal Follow-Up. Biometrics, 59(4), December 2003.
Permute survival times after imputation (IPT)
permuteIPT(data, pp, index = TRUE)
permuteIPT(data, pp, index = TRUE)
data |
matrix as returned by impute.IPT |
pp |
vector of permuted indices |
index |
not used |
matrix with time, status, trt columns
Wang, R., Lagakos, S.~W. and Gray, R.~J. Testing and interval estimation for two-sample survival comparisons with small sample sizes and unequal censoring. Biostatistics, 11(4), 676–692, January 2010.
Permute treatment assignment after imputation (IPZ)
permuteIPZ(data, pZ, index = FALSE)
permuteIPZ(data, pZ, index = FALSE)
data |
matrix as returned by impute.IPT |
pZ |
vector of permuted indices if index is TRUE, else binary vector of treatment assignments |
index |
indicates if pZ is a vector of indices or a binary vector of treatment assignments |
matrix with time, status, Z columns
Wang, R., Lagakos, S.~W. and Gray, R.~J. Testing and interval estimation for two-sample survival comparisons with small sample sizes and unequal censoring. Biostatistics, 11(4), 676–692, January 2010.
Sample from conditional distribution estimated by Kaplan-Meier estimator. Imputed values > tmax are right-censored.
sampleFromCondKM(U, fit, tmax = NULL, dv = 1, f = NULL)
sampleFromCondKM(U, fit, tmax = NULL, dv = 1, f = NULL)
U |
vector of observed times |
fit |
Kaplan-Meier fit as returned by survfit |
tmax |
largest observation of the pooled sample |
dv |
1 if imputing events, 0 if imputing censoring times |
f |
interpolated Kaplan-Meier estimate |
Random sample of survival times drawn from conditional distribution of T given T > U
Sample from distribution estimated by Kaplan-Meier estimator. Imputed values > tmax are right-censored.
sampleFromKM(n, fit, start = 0, tmax = NULL, dv = 1)
sampleFromKM(n, fit, start = 0, tmax = NULL, dv = 1)
n |
sample size |
fit |
Kaplan-Meier fit as returned by survfit |
start |
if 0 sample from L(T), else sample from L(T, T > start) |
tmax |
largest observation in pooled sample |
dv |
1 if imputing events, 0 if imputing censoring times |
Random sample of survival times
shuffleBlock Permute block preserving group sizes, randomization blocks
shuffleBlock(block, strata = 0)
shuffleBlock(block, strata = 0)
block |
vector of row indices to be permuted |
strata |
factor defining strata with block |
random permutation of each stratum within block
summary of permGS object
## S3 method for class 'permGS' summary(object, ...)
## S3 method for class 'permGS' summary(object, ...)
object |
permGS object as returned by |
... |
additional parameters (currently unused) |
nothing