permDep: Permutation test for general dependent truncation

Description Usage Arguments Value References Examples

View source: R/depTrun.R

Description

Perform permutation test based on conditional or unconditional approach.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
permDep(
  trun,
  obs,
  permSize,
  cens,
  sampling = c("conditional", "unconditional", "is.conditional", "is.unconditional"),
  kendallOnly = FALSE,
  minp1Only = FALSE,
  minp2Only = FALSE,
  nc = ceiling(detectCores()/2),
  seed = NULL,
  minp.eps = NULL,
  plot.int = FALSE,
  anim_name = NULL
)

Arguments

trun

is the left truncation time.

obs

is the observed failure time.

permSize

is the number of permutations.

cens

is the status indicator if the observed failure time are subjected to right-censoring; 0 = censored, 1 = event.

sampling

a character string specifying the sampling method used in permutation. The following are permitted:

conditional

conditional permutation;

uconditional

unconditional permutation;

is.conditional

importance sampling version of conditional permutation;

is.uconditional

importance sampling version of unconditional permutation;

kendallOnly, minp1Only, minp2Only

optional values indicating which test statistics to be used. If all leave as FALSE, permDep will use all three test statistics in each permutation.

nc

is the number of cores used in permutation. When nc > 1, permutation is carried out with parallel computing.

seed

an optional vector containing random seeds to be used to generate permutation samples. Random seeds will be used when left unspecified.

minp.eps

an optional value indicating the width of the intervals used in minp2 procedure. The following input are allowed:

a single numerical number:

sets the common width for all intervals

a numerical vector:

the length of the vector needs to be a sub-multiple or multiple of the number of uncensored events. This input is useful for user specified widths.

a character string:

This option can be either "in" or "out", which require the minimum number of uncensored events inside or outside of each interval, respectively.

NULL:

automatic selection using the algorithm outlined in Chiou (2018) will be used.

plot.int

an optional logical value indicating whether an animated scatterplot will be produced to how the minp intervals are chosen for the observed data.

anim_name

an optional character string specifying the file name that the animation to be saved. When not specified, file name based on the current system date and time will be used. This argument will only be executed when plot.int = TRUE.

Value

A list containing output with the following components:

obsKen

the observed p-value using Kendall's tau test statistic.

obsP1

the observed p-value using minp1 test statistic.

obsP2

the observed p-value using minp2 test statistic.

obsTest1

the observed minp1 test statistic.

obsTest2

the observed minp2 test statistic.

permKen

Kendall's tau test statistics from permutation samples.

permP1

minp1 test statistics from permutation samples.

permP2

minp2 test statistics from permutation samples.

References

Chiou, S.H., Qian, J., and Betensky, R.A. (2018). Permutation Test for General Dependent Truncation. Computational Statistics \& Data Analysis, 128, p308–324.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
simDat <- function(n) {
  k <- s <- 1
  tt <- xx <- yy <- cc <- delta <- rep(-1, n)
  while(k <= n){
    tt[k] <- runif(1, 0, 3.5)
    xx[k] <- 1.95 + 0.65 * (tt[k] - 1.25)^2 + rnorm(1, sd = 0.1)
    cc[k] <- runif(1, 0, 10)
    delta[k] <- (xx[k] <= cc[k])
    yy[k] <- pmin(xx[k], cc[k])
    s <- s + 1
    if(tt[k] <= yy[k]) k = k+1
  }
 data.frame(list(trun = tt, obs = yy, delta = delta))
}

set.seed(123)
dat <- simDat(50)
B <- 20

## Perform conditional permutation with Kendall's tau, minp1 and minp2
set.seed(123)
system.time(fit <- with(dat, permDep(trun, obs, B, delta, nc = 1)))
fit

stc04003/permDep documentation built on Jan. 23, 2022, 6:35 a.m.