Package 'ksamplesLTRC'

Title: K-Sample Tests for Truncated and/or Censored Data
Description: Nonparametric analysis and comparison of distributions under left truncation and right censoring. The package includes simulation routines for truncated and/or censored survival data, nonparametric distribution comparison methods based on Kolmogorov-Smirnov-type and Cramér-von Mises-type statistics, and bootstrap routines for p-value approximation. For methodological details, see Lago, de Uña-Álvarez and Pardo-Fernández (2025) <doi:10.1007/s11749-024-00948-4> and Lago, Pardo-Fernández and de Uña-Álvarez (2026) <doi:10.1007/s10985-026-09713-1>.
Authors: Adrián Lago [aut, cre], Jacobo de Uña-Álvarez [aut], Juan Carlos Pardo-Fernández [aut]
Maintainer: Adrián Lago <[email protected]>
License: GPL-3
Version: 0.1.1
Built: 2026-09-18 12:26:04 UTC
Source: https://github.com/adrian-lago/ksamplesltrc

Help Index


Automatic test selector for survival data

Description

Performs tests for data subject to left truncation, right censoring or both.

Usage

ksample.test(
  time,
  entry = NULL,
  status = NULL,
  group,
  weights = NULL,
  tests = c("ks", "cvm", "logrank"),
  B = 500,
  plot.curves = FALSE,
  holes = c("holes", "add", "conditional"),
  p = 0,
  q = 0,
  seed = NULL,
  keep.boot = FALSE
)

Arguments

time

Numeric vector of event or follow-up times.

entry

Optional entry time (for left truncation).

status

Event indicator (1 = event, 0 = censored).

group

Group indicator (factor or vector).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

tests

Character: "ks", "cvm", "logrank".

B

Number of bootstrap replications for approximating the pp-value.

plot.curves

Logical, default to FALSE. If TRUE, the function depicts the functions to be compared.

holes

One of 'holes' (default), 'add', or 'conditional'. See ltrc.estimator() for details.

p, q

Weights for the log-rank-type tests to be performed. If NULL, the classical log-rank. test is performed.

seed

Seed for the bootstrap statistics.

keep.boot

Logical, default to FALSE. If TRUE, the statistics computed from the bootstrap resamples are stored.

Value

A list with the following components:

  • statistic: numerical value of the Kolmogorov–Smirnov and/or Cramér–von Mises statistics.

  • p.value: approximated pp-value of the tests.

  • stat.boot: bootstrap statistics for the pp-value approximation.

  • logrank: a matrix with weights p and q, test statistics, and pp-values.

  • B: number of bootstrap replications.

  • tests: tests performed, as specified in the input.

  • curves: distribution function estimators of the kk samples to be compared.

  • groups: group indicators.

  • holes: method for handling holes (if appropriate).

  • stat.boot: bootstrap statistics (if keep.boot = TRUE).

Examples

if (requireNamespace("KMsurv", quietly = TRUE)) {
data("channing", package = "KMsurv")

aa <- ksample.test(time = channing$age,entry = channing$ageentry,
status = channing$death, group = channing$gender,
weights=rep(1/2,2), B = 200, holes='conditional',
tests=c('ks','cvm','logrank'),plot.curves=TRUE,
p=c(0,1,0.5,0),q=c(0,0,0.5,1),keep.boot = FALSE)

summary(aa)
}

Add estimators to an existing plot

Description

Adds the survival estimator to an existing plot.

Usage

## S3 method for class 'estimators'
lines(x, conf.int = FALSE, ...)

Arguments

x

An object of class "estimators".

conf.int

Logical, default to FALSE. If TRUE, pointwise confidence bands are depicted for the curves.

...

Additional graphical parameters passed to graphics::lines().

Value

Invisibly returns x.


Add estimators to an existing plot

Description

Adds the survival estimator to an existing plot.

Usage

## S3 method for class 't.estimators'
lines(x, ...)

Arguments

x

An object of class "estimators".

...

Additional graphical parameters passed to graphics::lines().

Value

Invisibly returns x.


Cramér–von Mises-type statistic for the kk-sample problem under left truncation

Description

Computes the Cramér–von Mises statistic adapted to left truncation.

Usage

lt.cvm(
  p.sample,
  weights = NULL,
  holes = c("holes", "add", "conditional"),
  plot.curves = FALSE
)

Arguments

p.sample

Matrix or data frame with columns (U, X, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

holes

Way to handle holes, if present. See lt.estimator() for more details.

plot.curves

Logical, default to FALSE. If true, the kk distributions to be compared are depicted.

Details

In Kiefer (1959), the kk-sample version of the Cramér–von Mises test is defined as

DCvM=∑j=1knj∫(Fjnj(t)−Fn(t))2dFn(t),D_{CvM} = \sum_{j=1}^k n_j \int \left( F_{jn_j}(t) - F_n(t)\right)^2 dF_n(t),

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for left truncation.

Value

Numerical value of the test statistic computed from the kk samples.

References

Kiefer, J. (1959). K-sample analogues of the Kolmogorov–Smirnov and Cramér–von Mises tests. The Annals of Mathematical Statistics, 30:420-447.

Examples

if (requireNamespace("mvna", quietly = TRUE)) {
data("abortion", package = "mvna")
pooled.sample <- abortion[abortion$cause==3, 2:4]
head(pooled.sample)
aa <- lt.cvm(p.sample=pooled.sample,weights=rep(1/2,2),plot.curves=TRUE)
aa
}

Survival function estimator under left truncation

Description

Computes the survival function estimator accounting for left truncation. It also returns pointwise confidence bands and includes the possibility of dealing with holes in the sample.

Usage

lt.estimator(
  o.sample,
  conf.int = FALSE,
  alpha = 0.05,
  conf.type = c("plain", "loglog"),
  holes = c("holes", "add", "conditional")
)

Arguments

o.sample

Matrix or data frame with columns (U, X), such that U≤XU \le X. If this input contains more columns, they will not be used.

conf.int

Logical, set as default to FALSE. If TRUE, the function returns a pointwise confidence band.

alpha

Pointwise confidence bands with 1−α1-\alpha confidence level

conf.type

One of 'plain' (default) or 'loglog'. Type of pointwise confidence band.

holes

One of 'add', 'conditional', or 'holes' (default) (see details).

Details

The estimator of the survival function when data are subject to left truncation is defined as (Lynden-Bell, 1971)

Sn(t)=∏xi≤t(1−diri),S_n(t) = \prod_{x_i \leq t} \left( 1-\frac{d_i}{r_i} \right),

where x1,…,xmx_1, \ldots, x_m are the distinct observed event times, di=#{j:Xj=xi}d_i = \# \{j : X_j = x_i\} and ri=#{j:Uj≤xi≤Xj}r_i = \#\{j : U_j \leq x_i \leq X_j\}. One should note that this definition of the risk sets is not equal to that in survival::survfit, where ri=#{j:Uj<xi≤Xj}r_i = \#\{j : U_j < x_i \leq X_j\}, so these two implementations may not be equal when ties are present in the data.

The variance for the confidence bands follows a Greenwood's-like formula:

Var(Sn(t))=Sn(t)2∑xi≤tdini(ni−di).Var(S_n(t)) = S_n(t)^2 \sum_{x_i \leq t} \frac{d_i}{n_i(n_i-d_i)}.

A log-log transformation is also possible. The confidence band is based on the Gaussianity of the process n(Sn(t)−S(t))\sqrt{n}(S_n(t) - S(t)).

The function also includes a way to deal with possible holes. A hole is an event time with associated unitary risk set, namely ri=1r_i=1 for some i∈{1,…,m−1}i \in \{1, \ldots, m-1\}. We exclude the largest event time, since it is always a hole. If a hole is present in a sample, the estimator degenerates and takes the value 1 from that time on. Different techniques are available in the literature for the treatment of holes. For instance, in Stute and Wang (2008), authors suggest to increase the risk set by 1 (holes='add'). Other references, like Klein and Moeschberger (2003), suggest conditioning on the largest hole different from the largest event time (holes='conditional'). The possibility of computing the degenerate statistic is also included (holes='holes').

Value

An object with the following content:

  • fail.time: ordered distinct observed event times

  • estimation: estimated survival function at each observed event time

  • prob: jumps of the estimator

  • If conf.int = TRUE, it also returns the confidence band lower and upper limits for both the distribution and survival function.

References

Klein, J. P. and Moeschberger, M. L. (2003). Survival Analysis: Techniques for Censored and Truncated Data. Springer.

Lynden-Bell, D. (1971). A method of allowing for known observational selection in small samples applied to 3CR quasars. Monthly Notices of the Royal Astronomical Society, 155:95-118.

Stute, W. and Wang, J. L. (2008). The central limit theorem under random truncation. Bernoulli, 14:604–622.

Examples

if (requireNamespace("mvna", quietly = TRUE)) {
data("abortion", package = "mvna")
pooled.sample <- abortion[abortion$cause==3, 2:4]
plot( lt.estimator(pooled.sample[pooled.sample$group==0,],conf.int=TRUE,conf.type='loglog'),
xlab='Time (in weeks)',ylab='Estimated survival probability' )
lines( lt.estimator(pooled.sample[pooled.sample$group==1,],conf.int=TRUE,conf.type='loglog'),col=2 )
}

Kolmogorov–Smirnov-type statistic for the kk-sample problem under left truncation

Description

Computes the Kolmogorov–Smirnov statistic adapted to left truncation.

Usage

lt.ks(
  p.sample,
  weights = NULL,
  plot.curves = FALSE,
  holes = c("holes", "add", "conditional")
)

Arguments

p.sample

Matrix or data frame with columns (U, X, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

plot.curves

Logical, default to FALSE. If true, the kk distributions to be compared are depicted.

holes

What to do when a hole is present in a sample. See lt.estimator() for more details.

Details

In Kiefer (1959), the kk-sample version of the Kolmogorov–Smirnov test is defined as

DKS=sup⁡t∑j=1knj(Fjnj(t)−Fn(t))2,D_{KS} = \sup_t \sum_{j=1}^k n_j \left( F_{jn_j}(t) - F_n(t)\right)^2,

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for left truncation. The two-sample version of this statistic was studied in Lago et al. (2025). Note that, when k=2k=2, one has

DKS=(n1p22+n2p12)(sup⁡t∣F1n1(t)−F2n2(t)∣)2.D_{KS} = (n_1p_2^2 + n_2p_1^2) \left( \sup_t \mid F_{1n_1}(t) - F_{2n_2}(t) \mid \right)^2.

Value

A list with the following components:

  • statistic: numerical value of the Kolmogorov–Smirnov statistic.

  • time: time when the maximum is attained.

References

Kiefer, J. (1959). K-sample analogues of the Kolmogorov–Smirnov and Cramér–von Mises tests. The Annals of Mathematical Statistics, 30:420-447.

Lago, A., de Uña-Álvarez, J., & Pardo-Fernández, J. C. (2025). A Kolmogorov–Smirnov-type test for the two-sample problem with left-truncated data. Test, 34(1), 69-90.

Examples

if (requireNamespace("mvna", quietly = TRUE)) {
data("abortion", package = "mvna")
pooled.sample <- abortion[abortion$cause==3, 2:4]
head(pooled.sample)
aa <- lt.ks(p.sample=pooled.sample,weights=rep(1/2,2),plot.curves=TRUE)
aa
}

Weighted log-rank tests under left truncation

Description

Computes weighted log-rank-type tests (Fleming–Harrington family) for kk groups with left truncation.

Usage

lt.logrank(
  p.sample,
  p = 0,
  q = 0,
  plot.curves = FALSE,
  holes = c("holes", "conditional")
)

Arguments

p.sample

Matrix or data frame with columns (U, X, group).

p, q

Nonnegative tuning parameters. If one has length 1 and the other is a vector, the scalar is recycled.

plot.curves

Logical, default to FALSE. If true, the the kk distribution functions to be compared are depicted.

holes

How the function deals with holes when estimating the survival function with the pooled sample. One of 'add' (default), 'conditional', and 'holes'. If no holes are present in the sample, this argument will not be used.

Details

The test statistic is based on the quantity

Lj=∑i=1mωi(dji−dirjiri),L_j = \sum_{i=1}^m \omega_i \left(d_{ji} - d_i \frac{r_{ji}}{r_i}\right),

for j∈{1,…,k}j \in \{1, \ldots, k\}. Denote by x1,…,xmx_1, \ldots, x_m the distinct observed event times from the kk samples. For a time xix_i and a group jj, djid_{ji} denotes the total count of individuals that experience the event, and rjir_{ji} is the number of individuals at risk. In addition, di=∑j=1kdjid_i = \sum_{j=1}^k d_{ji} and ri=∑j=1krjir_i = \sum_{j=1}^k r_{ji}, which are the total number of events observed and the total number of individuals at risk at time xix_i, respectively.

Finally, the weights ω1,…,ωm\omega_1, \ldots, \omega_m are taken as

wi=S^(xi)p(1−S^(xi))q,w_i = \hat{S}(x_i)^p (1-\hat{S}(x_i))^q,

with S^(xi)\hat{S}(x_i) the pooled survival just before the event time. The choice p=0=qp=0=q results in the classical version of the log-rank test.

The test statistic is given by

(L1,…,Lk−1)Σ^−1(L1,…,Lk−1)⊤,(L_1, \ldots, L_{k-1}) \hat{\Sigma}^{-1}(L_1, \ldots, L_{k-1})^\top,

where Σ^\hat{\Sigma} is the matrix with the variance-covariance estimators. Each term in the matrix includes the correction factor (nj−dj)/(nj−1)(n_j-d_j)/(n_j-1) for tied event times. The test statistic follows an asymptotic χk−12\chi^2_{k-1} distribution under the null hypothesis of equal target distributions in the kk populations.

Value

A matrix with columns statistic, detailing the choices of p and q, in addition to the corresponding p.value.

References

Klein, J.P., and Moeschberger, M. L. (2003). Survival Analysis: Techniques for Censored and Truncated Data. Springer, New York.

Examples

if (requireNamespace("mvna", quietly = TRUE)) {
data("abortion", package = "mvna")
pooled.sample <- abortion[abortion$cause==3, 2:4]
head(pooled.sample)
lt.logrank(p.sample=pooled.sample,p=c(0,1,0.5,5),q=c(0,0,0.5,1),plot.curves=TRUE)
}

Cramér–von Mises-type test for the kk-sample problem under left truncation

Description

Computes the Cramér–von Mises statistic adapted to left truncation, and the corresponding pp-value.

Usage

lt.pv.cvm(
  p.sample,
  weights = NULL,
  B = 500,
  plot.curves = FALSE,
  holes = c("holes", "add", "conditional"),
  seed = NULL,
  keep.boot = FALSE
)

Arguments

p.sample

Matrix or data frame with columns (U, Y, Δ\Delta, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

B

Number of bootstrap replications to approximate the pp-value.

plot.curves

Logical, default to FALSE. If TRUE, the kk curves to be compared are depicted.

holes

How to handle holes if present in a sample. One of holes (default), conditional or add. See details in ltrc.estimator().

seed

Seed for the bootstrap resamples.

keep.boot

Logical, default to FALSE. If TRUE, the bootstrap statistics are returned in the output of the function.

Details

In Kiefer (1959), the kk-sample version of the Cramér–von Mises test is defined as

DCvM=∑j=1knj∫(Fjnj(t)−Fn(t))2dFn(t),D_{CvM} = \sum_{j=1}^k n_j \int \left( F_{jn_j}(t) - F_n(t)\right)^2 dF_n(t),

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for left truncation.

The pp-value is approximated by means of the obvious bootstrap accounting for left truncation, as a particular case of the obvious bootstrap proposed for left-truncated and right-censored data in Bilker and Wang (1997). The exact algorithm for the two-sample problem can be consulted in Lago et al. (2025).

Value

A list with the following elements:

  • statistic: numerical value of the Cramér–von Mises test statistic

  • pvalue: pp-value of the test

  • curves: A list with the estimators of the kk distribution functions to be compared.

  • groups: Group indicator

  • stat.boot: If keep.boot = TRUE, the function returns the statistic evaluated in the bootstrap resamples.

References

Bilker, W.B., and Wang, M.C. (1997). Bootstrapping left truncated and right censored data. Communications in Statistics - Simulation and Computation, 26:141-171.

Kiefer, J. (1959). K-sample analogues of the Kolmogorov–Smirnov and Cramér–von Mises tests. The Annals of Mathematical Statistics, 30:420-447.

Lago, A., de Uña-Álvarez, J., & Pardo-Fernández, J. C. (2025). A Kolmogorov–Smirnov-type test for the two-sample problem with left-truncated data. TEST, 34, 69-90.

Examples

if (requireNamespace("mvna", quietly = TRUE)) {
data("abortion", package = "mvna")
pooled.sample <- abortion[abortion$cause==3, 2:4]
head(pooled.sample)
aa <- lt.pv.cvm(p.sample=pooled.sample,weights=rep(1/2,2),plot.curves=TRUE, B = 200)
aa$pvalue
plot(aa)
}

Kolmogorov–Smirnov-type test for the kk-sample problem under left truncation

Description

Computes the Kolmogorov–Smirnov test adapted to left truncation and the corresponding pp-value.

Usage

lt.pv.ks(
  p.sample,
  weights = NULL,
  B = 500,
  plot.curves = FALSE,
  holes = c("holes", "add", "conditional"),
  seed = NULL,
  keep.boot = FALSE
)

Arguments

p.sample

Matrix or data frame with columns (U, X, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

B

Number of bootstrap replications to approximate the pp-value.

plot.curves

Logical, default to FALSE. If TRUE, the kk curves to be compared are depicted.

holes

How to handle holes if present in a sample. One of holes (default), conditional or add. See details in ltrc.estimator().

seed

Seed for the bootstrap resamples.

keep.boot

Logical, default to FALSE. If TRUE, the test statistics evaluated in the bootstrap resamples are included in the output.

Details

In Kiefer (1959), the kk-sample version of the Kolmogorov–Smirnov test is defined as

DKS=sup⁡t∑j=1knj(Fjnj(t)−Fn(t))2,D_{KS} = \sup_t \sum_{j=1}^k n_j \left( F_{jn_j}(t) - F_n(t)\right)^2,

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for left truncation. The two-sample version of this test was studied in Lago et al. (2025).

The pp-value is approximated by means of the obvious bootstrap accounting for left truncation, studied in Bilker and Wang (1997). The exact algorithm for the two-sample problem can be consulted in Lago et al. (2025).

Value

A list with the following components:

  • statistic: numerical value of the Kolmogorov–Smirnov statistic.

  • pvalue: approximated p-value of the test.

  • curves: A list with the estimators of the kk distribution functions to be compared.

  • groups: Group indicator

  • stat.boot: statistics computed from the bootstrap resamples. Included in the output only if keep.boot = TRUE

References

Bilker, W.B., and Wang, M.C. (1997). Bootstrapping left truncated and right censored data. Communications in Statistics - Simulation and Computation, 26:141-171.

Lago, A., Pardo-Fernández, J.C., and de Uña-Álvarez, J. (2026). A Kolmogorov–Smirnov-type test for the two-sample problem with left-truncated data. TEST: 34:69-90.

Kiefer, J. (1959). K-sample analogues of the Kolmogorov–Smirnov and Cramér–von Mises tests. The Annals of Mathematical Statistics, 30:420-447.

Examples

if (requireNamespace("mvna", quietly = TRUE)) {
data("abortion", package = "mvna")
pooled.sample <- abortion[abortion$cause==3, 2:4]
head(pooled.sample)
aa <- lt.pv.ks(p.sample=pooled.sample,weights=rep(1/2,2),plot.curves=TRUE, B = 200)
aa$pvalue
plot(aa)
}

Left-truncated data simulation

Description

Simulates data under left truncation from prespecified variables for the truncation and target variables.

Usage

lt.sim(
  n,
  rtrunc,
  trunc.args = list(),
  rtarget,
  target.args = list(),
  seed = NULL
)

Arguments

n

Sample size

rtrunc

A function that simulates data from a distribution

trunc.args

A list with the parameters of the truncation variable

rtarget

A function that simulates data from a distribution

target.args

A list with the parameters of the target distribution

seed

Optional seed.

Value

A data frame with nn rows and two columns: the truncation times are in the first column, and the event times, in the second one.

Examples

aa <- lt.sim(1000,rnorm,trunc.args=list(4,1),rnorm,target.args = list(4,1))
head(aa)
plot(lt.estimator(aa),col=2,xlab='t',ylab='Estimated survival probiblity')
curve(1-pnorm(x,4,1),add=TRUE)

Tests for the kk-sample problem under left truncation

Description

Computes kk-sample tests adapted to left truncation, and the corresponding pp-value.

Usage

lt.test(
  p.sample,
  weights = NULL,
  tests = c("ks", "cvm", "logrank"),
  B = 500,
  plot.curves = FALSE,
  holes = c("holes", "add", "conditional"),
  p = 0,
  q = 0,
  seed = NULL,
  keep.boot = FALSE
)

Arguments

p.sample

Matrix or data frame with columns (U, X, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

tests

Tests to perform. One of Kolmogorov–Smirnov (ks), Cramér–von Mises (cvm), or weighted log-rank-type tests (logrank).

B

Number of bootstrap replications to approximate the pp-values of the Kolmogorov–Smirnov and/or Cramér–von Mises tests.

plot.curves

Logical, FALSE by default. If set to TRUE, the kk survival functions to be compared are depicted.

holes

Treatment of possible holes. See details in ltrc.estimator().

p, q

Weights of the log-rank-type tests. The choice p=0=qp=0=q yields the classical log-rank test.

seed

Seed for the bootstrap resamples.

keep.boot

Logical. If TRUE, bootstrap replicates are included in the returned object as stat.boot. Default is FALSE.

Details

This function collects the three tests implemented in this package: Kolmogorov–Smirnov, Cramér–von Mises and weighted log-rank-type tests, (Klein and Moeschberger, 2003) adapted to left truncation. The pp-values of the first two are approximated by bootstrap, and the pp-value of the log-rank tests is computed by the χk−12\chi^2_{k-1} asymptotic distribution of the test statistic, where kk is the number of groups.

Value

A list with the following components:

  • statistic: numerical value of the Kolmogorov–Smirnov and/or Cramér–von Mises statistics.

  • p.value: approximated p-value of the tests.

  • stat.boot: bootstrap statistics for the p-value approximation.

  • logrank: a matrix with weights p and q, test statistics, and pp-values.

  • B: number of bootstrap replications.

  • tests: tests performed, as specified in the input.

  • curves: distribution function estimators of the kk samples to be compared.

  • groups: group indicators.

  • holes: method for handling holes.

The summary method returns a data frame with one row per test and the following columns:

Test

Name of the test. For the weighted log-rank-type tests, the weights p and q are detailed.

Statistic

Observed value of the test statistic.

p.value

Corresponding pp-value.

References

Klein, J.P., and Moeschberger, M. L. (2003). Survival Analysis: Techniques for Censored and Truncated Data. Springer, New York.

Lago, A., de Uña-Álvarez, J., and Pardo-Fernández, J.C. (2025). A Kolmogorov–Smirnov-type test for the two-sample problem with left-truncated data. TEST: 34:69-90.

Examples

if (requireNamespace("mvna", quietly = TRUE)) {
data("abortion", package = "mvna")
head(abortion)
pooled.sample <- abortion[abortion$cause==3, 2:4]
aa <- lt.test(pooled.sample,weights=rep(1/2,2),B=200,
holes='conditional', tests=c('ks','cvm','logrank'),
p=c(0,1,0.5,0),q=c(0,0,0.5,1))
summary(aa)
plot(aa)
}

Estimator of the truncation survival function for data subject to left truncation

Description

It computes the estimator of the truncation survival function for data subject to left truncation

Usage

lt.truncation.estimator(o.sample, holes = c("holes", "add", "conditional"))

Arguments

o.sample

Matrix or data frame with columns (U, X).

holes

Way to handle holes, if present. One of holes (default), add or conditional. See details in ltrc.estimator().

Details

This estimator is based on the idea that if XX is left-truncated by UU, then −U-U is left-truncated by −X-X. In addition, note that

SU(u)=1−SU(−u),S_U(u) = 1-S_{_U}(-u),

where SUS_U is the survival function of UU and S−US_{-U} is the survival function of −U-U. Thus, since lt.estimator() computes the estimator of the survival function, one can apply the Lynden-Bell estimator to the sample formed by reversing the roles of UU and XX by merely multiplying by -1.

The nontruncation probability is defined as

γ=P(U≤X)=∫G(z)dF(z),\gamma = \mathbb{P} (U \leq X) = \int G(z) dF(z),

where U∼GU \sim G and X∼FX \sim F. Then, an estimator of γ\gamma is given by (Woodroofe, 1985)

γn=∑i=1mφiGn(xi),\gamma_n = \sum_{i=1}^m \varphi_i G_n(x_i),

where x1,…,xmx_1, \ldots, x_m are the distinct observed event times, φ1,…,φm\varphi_1, \ldots, \varphi_m are the weights assigned by the Lynden-Bell estimator to the observed event times, and Gn(x1),…,Gn(xm)G_n(x_1), \ldots, G_n(x_m) are estimated distribution function of the observed variable evaluated at the distinct observed event times.

Value

A list with the following:

  • trunc.time: observed truncation times.

  • estimation: estimated survival probability.

  • prob: jumps of the estimator at each observed truncation time.

  • gamma: estimator of the nontruncation probability.

References

Lynden-Bell, D. (1971). A method of allowing for known observational selection in small samples applied to 3CR quasars. Monthly Notices of the Royal Astronomical Society, 155:95-118.

Woodroofe, M. (1985). Estimating a distribution function with truncated data. The Annals of Statistics, 13: 163-177.

Examples

aa <- lt.sim(500,rnorm,trunc.args=list(4,1),rnorm,target.args = list(4,1))
g.est <- lt.truncation.estimator(o.sample=aa)
plot(g.est$trunc.time,g.est$estimation,type='s',lwd=2,col=2)
curve(1-pnorm(x,4,1),add=TRUE,lwd=2,
xlab='t',ylab='Estimated distribution function')
# nontruncation probability estimator:
g.est$gamma

Cramér–von Mises-type statistic for the k-sample problem under left truncation and right censoring

Description

Computes the Cramér–von Mises statistic adapted to left truncation and right censoring.

Usage

ltrc.cvm(
  p.sample,
  weights = NULL,
  holes = c("holes", "add", "conditional"),
  plot.curves = FALSE
)

Arguments

p.sample

Matrix or data frame with columns (U, Y, Delta, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

holes

How to handle holes if present in a sample. One of holes (default), conditional or add. See ltrc.estimator() for details.

plot.curves

Logical, default to FALSE. If TRUE, the kk curves to be compared are depicted.

Details

In Kiefer (1959), the kk-sample version of the Cramér–von Mises test is defined as

DCvM=∑j=1knj∫(Fjnj(t)−Fn(t))2dFn(t),D_{CvM} = \sum_{j=1}^k n_j \int \left( F_{jn_j}(t) - F_n(t)\right)^2 dF_n(t),

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for left truncation and right censoring, as studied in Lago et al. (2026).

Value

Numerical value of the test statistic computed from the kk samples.

References

Lago, A., Pardo-Fernández, J.C., and de Uña-Álvarez, J. (2026). Kolmogorov–Smirnov and Cramér–von Mises tests for the k-sample problem for left-truncated and right-censored data. Lifetime Data Analysis: 32(2).

Kiefer, J. (1959). K-sample analogues of the Kolmogorov–Smirnov and Cramér–von Mises tests. The Annals of Mathematical Statistics, 30:420-447.

Examples

if (requireNamespace("KMsurv", quietly = TRUE)) {
data("channing", package = "KMsurv")
data.channing <- data.frame(channing$ageentry, channing$age,
channing$death, channing$gender)
ltrc.cvm(data.channing,weights=rep(1/2,2), holes='conditional', plot.curves = TRUE)
}

Survival function estimator under left truncation and right censoring

Description

Computes the survival function estimator accounting for late entry times and censored observations. It also returns pointwise confidence bands.

Usage

ltrc.estimator(
  o.sample,
  conf.int = FALSE,
  alpha = 0.05,
  conf.type = c("plain", "loglog"),
  holes = c("holes", "add", "conditional")
)

Arguments

o.sample

Matrix or data frame with columns (U, Y, Delta, group).

conf.int

Logical, set as default to FALSE. If set to TRUE, the function returns a pointwise confidence band.

alpha

Pointwise confidence bands with 1−α1-\alpha confidence level

conf.type

Type of pointwise confidence band. Set as default to plainplain.

holes

One of 'add','conditional', or 'holes' (default) (see details).

Details

The estimator is defined as

Sn(t)=∏yi≤t(1−dini),S_n(t) = \prod_{y_i \leq t} \left( 1-\frac{d_i}{n_i} \right),

where y1,…,ymy_1, \ldots, y_m are the distinct observed event times, di=#{j:Yj=yi,Δj=1}d_i = \# \{j : Y_j = y_i , \Delta_j=1 \} and ni=#{j:Uj≤yi≤Yj}n_i = \#\{j : U_j \leq y_i \leq Y_j\}. It reduces to the Kaplan–Meier estimator if data are not subject to truncation, and to the Lynden-Bell estimator if no censoring is present.

The variance for the confidence bands follows a Greenwood's like formula:

Var(Sn(t))=Sn(t)2∑yi≤tdini(ni−di).Var(S_n(t)) = S_n(t)^2 \sum_{y_i \leq t} \frac{d_i}{n_i(n_i-d_i)}.

The confidence intervals are based on the asymptotic Gaussianity of the process n(Sn(t)−S(t))\sqrt{n} (S_n(t) - S(t)). Different transformations are also possible.

The function also includes a way to deal with possible holes. A hole is an event time with associated unitary risk set. If a hole is present in a sample, the estimator degenerates and takes the value 1 from that time on. Different techniques are available in the literature for the treatment of holes. For instance, in Stute and Wang (2008), authors suggest to increase the risk set by 1 (holes='add'). Other references, like Klein and Moeschberger (2003), suggest conditioning on the largest hole different from the largest event time (holes='conditional'). The possibility of computing the degenerate statistic is also included (holes='holes').

Value

An object with the following content:

fail.time: ordered distinct observed event times

estimation: estimated survival function at each observed event time

prob: jumps of the estimator

If conf.int is set to TRUE, it also returns the confidence band lower and upper limits

References

Klein, J. P. and Moeschberger, M. L. (2003). Survival Analysis: Techniques for Censored and Truncated Data. Springer

Wang, M.C. (1991). Nonparametric estimation from cross-sectional survival data. Journal of the American Statistical Association, 86:130-143.

Stute, W. and Wang, J. L. (2008). The central limit theorem under random truncation. Bernoulli, 14:604–622.

Examples

observed.sample <- ltrc.sim(n=1000,rtrunc=rnorm,rtarget=rnorm,rcens=rexp,
trunc.args=list(4,1),target.args = list(4,1),cens.args = list(1))
est <- ltrc.estimator(observed.sample,conf.int=TRUE,alpha=0.05,conf.type='loglog')
str(est)
plot(est,col='firebrick',xlab='t', ylab='Estimated survival probability')

if (requireNamespace("KMsurv", quietly = TRUE)) {
data("channing", package = "KMsurv")
o.sample <- channing[channing$gender==1,c(3,4,2)] # subgroup of men
head(o.sample)
plot( ltrc.estimator(o.sample,holes='holes'),col=2,xlab='t',
ylab='Estimated survival probability' ,
main = 'Estimated survival probability for men') # no correction
lines( ltrc.estimator(o.sample,holes='add'),col=3 ) # +1 to risk set
lines( ltrc.estimator(o.sample,holes='conditional'),col=4 )
legend('topright',legend=c('holes="holes" ','holes="add" ',
'holes="conditional"'),col=2:4,lwd=rep(1,3))
}

Kolmogorov–Smirnov-type statistic for the kk-sample problem under left truncation and right censoring

Description

Computes the Kolmogorov–Smirnov statistic adapted to left truncation and right censoring.

Usage

ltrc.ks(
  p.sample,
  weights = NULL,
  plot.curves = FALSE,
  holes = c("holes", "add", "conditional")
)

Arguments

p.sample

Matrix or data frame with columns (U, Y, Delta, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

plot.curves

Logical, default to FALSE. If TRUE, the kk curves to be compared are depicted.

holes

How to handle holes if present in a sample. One of holes (default), conditional or add. See ltrc.estimator() for details.

Details

In Kiefer (1959), the kk-sample version of the Kolmogorov–Smirnov test is defined as

DKS=sup⁡t∑j=1knj(Fjnj(t)−Fn(t))2,D_{KS} = \sup_t \sum_{j=1}^k n_j \left( F_{jn_j}(t) - F_n(t)\right)^2,

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for left truncation and right censoring, as studied in Lago et al. (2026).

Value

A list with the following components:

  • statistic: numerical value of the Kolmogorov–Smirnov statistic.

  • time: time when the maximum is attained.

References

Lago, A., Pardo-Fernández, J.C., and de Uña-Álvarez, J. (2026) Kolmogorov–Smirnov and Cramér–von Mises tests for the k-sample problem for left-truncated and right-censored data. Lifetime Data Analysis: 32(2).

Examples

if (requireNamespace("KMsurv", quietly = TRUE)) {
data("channing", package = "KMsurv")

data.channing <- data.frame(channing$ageentry, channing$age,
channing$death, channing$gender)
ltrc.ks(data.channing,weights=rep(1/2,2),holes='conditional')
}

Weighted log-rank tests under left truncation and right censoring

Description

Computes weighted log-rank-type tests (Fleming–Harrington family) for k groups with left truncation and right censoring.

Usage

ltrc.logrank(
  p.sample,
  p = 0,
  q = 0,
  plot.curves = FALSE,
  holes = c("holes", "conditional")
)

Arguments

p.sample

Matrix or data frame with columns (U, Y, Delta, group).

p, q

Nonnegative weight parameters. If one has length 1 and the other is a vector, the scalar is recycled.

plot.curves

Logical, default to FALSE. If true, the the kk distribution functions to be compared are depicted.

holes

One of 'holes' (default) or 'conditional'. In contrast to other functions of this package the possibility of adding 1 to the risk set is not considered.

Details

The test statistic is based on the quantity

Lj=∑i=1mωi(dji−dirjiri),L_j = \sum_{i=1}^m \omega_i \left(d_{ji} - d_i \frac{r_{ji}}{r_i}\right),

for j∈{1,…,k}j \in \{1, \ldots, k\}. Denote by y1,…,ymy_1, \ldots, y_m the distinct observed event times from the kk samples. For a time yiy_i and a group jj, djid_{ji} denotes the total count of individuals that experience the event, and rjir_{ji} is the number of individuals at risk. In addition, di=∑j=1kdjid_i = \sum_{j=1}^k d_{ji} and ri=∑j=1krjir_i = \sum_{j=1}^k r_{ji}, which are the total number of events observed and the total number of individuals at risk at time yiy_i, respectively.

Finally, the weights ω1,…,ωm\omega_1, \ldots, \omega_m are taken as

wi=S^(yi)p(1−S^(yi))q,w_i = \hat{S}(y_i)^p (1-\hat{S}(y_i))^q,

with S^(xi)\hat{S}(x_i) the pooled survival just before the event time. The choice p=0=qp=0=q results in the classical version of the log-rank test.

The test statistic is given by

(L1,…,Lk−1)Σ^−1(L1,…,Lk−1)⊤,(L_1, \ldots, L_{k-1}) \hat{\Sigma}^{-1}(L_1, \ldots, L_{k-1})^\top,

where Σ^\hat{\Sigma} is the matrix with the variance-covariance estimators. Each term in the matrix includes the correction factor (nj−dj)/(nj−1)(n_j-d_j)/(n_j-1) for tied event times. The test statistic follows an χk−12\chi^2_{k-1} distribution under the null hypothesis of equal target distributions in the kk populations.

Value

A matrix with columns statistic and p.value.

References

Klein, J.P., and Moeschberger, M. L. (2003). Survival Analysis: Techniques for Censored and Truncated Data. Springer, New York.

Examples

if (requireNamespace("KMsurv", quietly = TRUE)) {
data("channing", package = "KMsurv")

data.channing <- data.frame(channing$ageentry, channing$age,
channing$death, channing$gender)
ltrc.logrank(data.channing, plot.curves=TRUE,
p = c(0,1,0.5,0),q = c(0,0,0.5,1),
holes = 'conditional')
}

Cramér–von Mises-type test for the kk-sample problem under left truncation and right censoring

Description

Computes the Cramér–von Mises test adapted to left truncation and right censoring and the corresponding pp-value.

Usage

ltrc.pv.cvm(
  p.sample,
  weights = NULL,
  B = 500,
  holes = c("holes", "add", "conditional"),
  plot.curves = FALSE,
  keep.boot = FALSE
)

Arguments

p.sample

Matrix or data frame with columns (U, Y, Δ\Delta, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

B

Number of bootstrap replications to approximate the pp-value

holes

How to deal with holes when estimating the distribution function of the target variable. One of 'holes' (default), 'add', and 'conditional'. See ltrc.estimator() for details.

plot.curves

Logical, default to FALSE. If TRUE, the kk samples to be compared are depicted.

keep.boot

Logical, default to FALSE. If TRUE, the function returns the statistics computed from the bootstrap resamples.

Details

In Kiefer (1959), the kk-sample version of the Cramér–von Mises test is defined as

DCvM=∑j=1knj∫(Fjnj(t)−Fn(t))2dFn(t),D_{CvM} = \sum_{j=1}^k n_j \int \left( F_{jn_j}(t) - F_n(t)\right)^2 dF_n(t),

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for left truncation and right censoring, as studied in Lago et al. (2026).

The pp-value is approximated by means of the obvious bootstrap accounting for left truncation and right censoring, studied in Bilker and Wang (1997). The exact algorithm for the kk-sample problem can be consulted in Lago et al. (2026).

Value

A list with the following:

  • statistic: Evaluation of the Cramér–von Mises statistic on the samples.

  • pvalue: pp-value approximated by bootstrap.

  • curves: A list with the estimators of the kk distribution functions to be compared.

  • groups: Group indicator

  • stat.boot: Evaluation of the Cramér–von Mises statistic on the bootstrap resamples. Only included in the output if keep.boot = TRUE.

References

Bilker, W.B., and Wang, M.C. (1997). Bootstrapping left truncated and right censored data. Communications in Statistics - Simulation and Computation, 26:141-171.

Lago, A., Pardo-Fernández, J.C., and de Uña-Álvarez, J. (2026). Kolmogorov–Smirnov and Cramér–von Mises tests for the k-sample problem for left-truncated and right-censored data. Lifetime Data Analysis: 32(2).

Kiefer, J. (1959). K-sample analogues of the Kolmogorov–Smirnov and Cramér–von Mises tests. The Annals of Mathematical Statistics, 30:420-447.

Examples

if (requireNamespace("KMsurv", quietly = TRUE)) {
data("channing", package = "KMsurv")

data.channing <- data.frame( channing$ageentry,channing$age,
channing$death,channing$gender )
aa <- ltrc.pv.cvm(data.channing, holes = 'conditional',
plot.curves = FALSE, B = 200)

aa$pvalue

}

Kolmogorov–Smirnov-type test for the kk-sample problem under left truncation and right censoring

Description

Computes the Kolmogorov–Smirnov test adapted to left truncation and right censoring and the corresponding pp-value.

Usage

ltrc.pv.ks(
  p.sample,
  weights = NULL,
  B = 500,
  plot.curves = FALSE,
  holes = c("holes", "add", "conditional"),
  keep.boot = FALSE
)

Arguments

p.sample

Matrix or data frame with columns (U, Y, Δ\Delta, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

B

Number of bootstrap replications to approximate the pp-value.

plot.curves

Logical, default to FALSE. If TRUE, the kk curves to be compared are depicted.

holes

How to handle holes if present in a sample. One of holes (default), conditional or add. See ltrc.estimator() for details.

keep.boot

Logical, default to FALSE. If TRUE, the function returns the statistics evaluated in the bootstrap resamples.

Details

In Kiefer (1959), the kk-sample version of the Kolmogorov–Smirnov test is defined as

DKS=sup⁡t∑j=1knj(Fjnj(t)−Fn(t))2,D_{KS} = \sup_t \sum_{j=1}^k n_j \left( F_{jn_j}(t) - F_n(t)\right)^2,

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for left truncation and right censoring, as studied in Lago et al. (2026).

The pp-value is approximated by means of the obvious bootstrap accounting for left truncation and right censoring, studied in Bilker and Wang (1997). The exact algorithm for the kk-sample problem can be consulted in Lago et al. (2026).

Value

A list with the following components:

  • statistic: numerical value of the Kolmogorov–Smirnov statistic.

  • p.value: approximated p-value of the tests.

  • curves: A list with the kk estimators of the distribution functions to be compared.

  • groups: Group indicator

  • stat.boot: the statistics computed from the bootstrap resamples. Included in the output only if keep.boot = TRUE.

References

Bilker, W.B., and Wang, M.C. (1997). Bootstrapping left truncated and right censored data. Communications in Statistics - Simulation and Computation, 26:141-171.

Lago, A., Pardo-Fernández, J.C., and de Uña-Álvarez, J. (2026). Kolmogorov–Smirnov and Cramér–von Mises tests for the k-sample problem for left-truncated and right-censored data. Lifetime Data Analysis: 32(2).

Kiefer, J. (1959). K-sample analogues of the Kolmogorov–Smirnov and Cramér–von Mises tests. The Annals of Mathematical Statistics, 30:420-447.

Examples

if (requireNamespace("KMsurv", quietly = TRUE)) {
data("channing", package = "KMsurv")
data.channing <- data.frame(channing$ageentry,channing$age,
channing$death,channing$gender)
aa <- ltrc.pv.ks(data.channing,weights=rep(1/2,2),
holes = 'conditional', plot.curves = FALSE, B = 200)
plot(aa)
aa$pvalue
}

Simulate left-truncated and right-censored data

Description

Simulates data under left truncation and right censoring.

Usage

ltrc.sim(
  n,
  rtrunc,
  trunc.args = list(),
  rtarget,
  target.args = list(),
  rcens,
  cens.args = list(),
  seed = NULL
)

Arguments

n

Sample size.

rtrunc

A function generating truncation times.

trunc.args

A list of arguments passed to rtrunc.

rtarget

A function generating target/event times.

target.args

A list of arguments passed to rtarget.

rcens

A function generating residual censoring times.

cens.args

A list of arguments passed to rcens.

seed

Optional seed.

Value

A data frame with columns u, y, and delta.

Examples

aa <- ltrc.sim(n=500,rtrunc=rnorm,trunc.args=list(4,1),
rtarget=rnorm,target.args = list(4,1),
rcens=rexp,cens.args=list(1),seed=12)
head(aa)

Tests for the kk-sample problem under left truncation and right censoring

Description

Computes kk-sample tests adapted to left truncation and right censoring and the corresponding pp-value.

Usage

ltrc.test(
  p.sample,
  weights = NULL,
  tests = c("ks", "cvm", "logrank"),
  B = 500,
  plot.curves = FALSE,
  holes = c("holes", "add", "conditional"),
  p = 0,
  q = 0,
  seed = NULL,
  keep.boot = FALSE
)

Arguments

p.sample

Matrix or data frame with columns (U, Y, Δ\Delta, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

tests

Tests to perform. One of Kolmogorov–Smirnov (ks), Cramér–von Mises (cvm), or weighted log-rank-type tests (logrank).

B

Number of bootstrap replications to approximate the pp-values of the Kolmogorov–Smirnov and/or Cramér–von Mises tests.

plot.curves

Logical, FALSE by default. If set to TRUE, the kk survival functions to be compared are depicted.

holes

One of holes (default), conditional or add. If holes = "add" and logrank is requested, the log-rank test is computed with holes = "holes" and a warning is issued. See ltrc.estimator() for details.

p, q

Weights of the log-rank-type tests. The choice p=0=qp=0=q yields the classical log-rank test.

seed

Seed for the bootstrap resamples.

keep.boot

Logical. If TRUE, bootstrap replicates are included in the returned object as stat.boot. Default is FALSE.

Details

This function collects the three tests implemented in this package: Kolmogorov–Smirnov, Cramér–von Mises (Lago et al., 2026) and weighted log-rank-type tests, (Klein and Moeschberger, 2003) adapted to left truncation and right censoring. The pp-values of the first two are approximated by bootstrap, and the pp-value of the log-rank tests is computed by the χk−12\chi^2_{k-1} asymptotic distribution of the test statistic, where kk is the number of groups.

Value

A list with the following components:

  • statistic: numerical value of the Kolmogorov–Smirnov and/or Cramér–von Mises statistics.

  • p.value: approximated p-value of the tests.

  • stat.boot: bootstrap statistics for the p-value approximation.

  • logrank: a matrix with weights p and q, test statistics, and pp-values.

  • B: number of bootstrap replications.

  • tests: tests performed, as specified in the input.

  • curves: distribution function estimators of the kk samples to be compared.

  • groups: group indicators.

  • holes: method for handling holes.

The summary method returns a data frame with one row per test and the following columns:

Test

Name of the test. For the weighted log-rank-type tests, the weights p and q are detailed.

Statistic

Observed value of the test statistic.

p.value

Corresponding pp-value.

References

Klein, J.P., and Moeschberger, M. L. (2003). Survival Analysis: Techniques for Censored and Truncated Data. Springer, New York.

Lago, A., Pardo-Fernández, J.C., and de Uña-Álvarez, J. (2026). Kolmogorov–Smirnov and Cramér–von Mises tests for the k-sample problem for left-truncated and right-censored data. Lifetime Data Analysis: 32(2).

Examples

if (requireNamespace("KMsurv", quietly = TRUE)) {
data("channing", package = "KMsurv")

data.channing <- data.frame(channing$ageentry, channing$age,
channing$death, channing$gender)
aa <- ltrc.test(data.channing,weights=rep(1/2,2),
holes='conditional',tests=c('ks','cvm','logrank'), B = 200,
p=c(0,1,0.5,0),q=c(0,0,0.5,1))
plot(aa)
summary(aa)
}

Estimator of the truncation distribution function for data subject to left truncation and right censoring

Description

It computes the estimator of the truncation distribution function for data subject to left truncation and right censoring

Usage

ltrc.truncation.estimator(o.sample, holes = c("holes", "add", "conditional"))

Arguments

o.sample

Matrix or data frame with columns (U, Y, Delta).

holes

One of 'add', 'conditional' or 'holes' (default). How to deal with holes in the estimation of the target variable survival function. See ltrc.estimator() for details.

Details

The estimator of the distribution function of the truncation variable is given by

Gn(t)=∑iSn(ui)−1∑jSn(uj)−1I[ui≤t],G_n(t) = \sum_i \frac{S_n(u_i)^{-1}}{\sum_j S_n(u_j)^{-1} } \mathbb{I}[u_i \leq t],

where u1,…,umu_1, \ldots, u_m are the distinct truncation times and SnS_n is the survival function estimator of the target variable.

The nontruncation probability is defined as

γ=P(U≤X)=∫G(z)dF(z),\gamma = \mathbb{P}(U \leq X) = \int G(z)dF(z),

where FF is the distribution function of the target variable. Then, it can be estimated as

γn=∑i=1mφiGn(yi),\gamma_n = \sum_{i=1}^m \varphi_i G_n(y_i),

where y1,…,ymy_1, \ldots, y_m are the distinct observed event times and φ1,…,φm\varphi_1, \ldots, \varphi_m are the weights that the estimator SnS_n assigns to y1,…,ymy_1, \ldots, y_m.

In practice, it is possible to observe truncation times larger than the largest event time. This would break the formula of the estimator GnG_{n} defined above. In such a case, following the recommendations in Wang (1991), we reduce the distribution function of the truncation variable to a conditional distribution on the identifiable region, by trimming a small amount of data. This is analogous to conditioning to times largest than the largest hole when estimating the distribution function of the target variable.

Value

An object with the observed truncation times, the estimator at those times, the jumps of the estimator and an estimator of the nontruncation probability

References

Wang, M.C. (1991). Nonparametric Estimation from Cross-Sectional Survival Data. Journal of the American Statistical Association, 86:130-143.

Examples

aa <- ltrc.sim(n=5000,rtrunc=rnorm,trunc.args = list(4,1),rtarget=rnorm,
target.args=list(4,1),rcens=rexp,cens.args=list(1))
head(aa)
plot(ltrc.truncation.estimator(aa))
curve(pnorm(x,4,1),add=TRUE,col=2)

if (requireNamespace("KMsurv", quietly = TRUE)) {
data("channing", package = "KMsurv")

o.sample <- channing[channing$gender==1,c(3,4,2)] # subgroup of men
plot(ltrc.estimator(o.sample)) # hole in the second event time
plot(ltrc.truncation.estimator(o.sample,holes='add'))
lines(ltrc.truncation.estimator(o.sample,holes='conditional'),col=2)
}

Plot method for estimators objects

Description

Produces a step plot of the survival estimator.

Usage

## S3 method for class 'estimators'
plot(x, conf.int = FALSE, ...)

Arguments

x

An object of class "estimators".

conf.int

Logical, default to FALSE. If TRUE, pointwise confidence bands are depicted for the curves.

...

Additional graphical parameters passed to graphics::plot().

Value

Invisibly returns x.


Plot method for k-sample test objects

Description

Plots the estimated survival curves for the groups involved in ltrc.test().

Usage

## S3 method for class 'ksamples_test'
plot(
  x,
  y = NULL,
  col = NULL,
  lwd = 2,
  lty = 1,
  xlab = "Time",
  ylab = "Survival probability",
  main = "Estimated survival curves",
  legend.pos = "topright",
  ...
)

Arguments

x

An object of class "ksamples_test".

y

Ignored.

col

Vector of colours for the groups.

lwd

Line width.

lty

Line type.

xlab

X-axis label.

ylab

Y-axis label.

main

Plot title.

legend.pos

Position of the legend.

...

Additional graphical parameters passed to graphics::plot().

Value

Invisibly returns x.


Plot method for estimators objects

Description

Produces a step plot of the survival estimator.

Usage

## S3 method for class 't.estimators'
plot(x, ...)

Arguments

x

An object of class "estimators".

...

Additional graphical parameters passed to graphics::plot().

Value

Invisibly returns x.


Cramér–von Mises-type statistic for the k-sample problem under right censoring

Description

Computes the Cramér–von Mises statistic adapted to left truncation and right censoring.

Usage

rc.cvm(p.sample, weights = NULL, plot.curves = FALSE)

Arguments

p.sample

Matrix or data frame with columns (U, Y, Delta, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

plot.curves

Logical, default to FALSE. If TRUE, the kk distributions to be compared are depicted

Details

In Kiefer (1959), the kk-sample version of the Cramér–von Mises test is defined as

DCvM=∑j=1knj∫(Fjnj(t)−Fn(t))2dFn(t),D_{CvM} = \sum_{j=1}^k n_j \int \left( F_{jn_j}(t) - F_n(t)\right)^2 dF_n(t),

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for right censoring.

Value

Numerical value of the test statistic computed from the kk samples.

References

Kiefer, J. (1959). K-sample analogues of the Kolmogorov–Smirnov and Cramér–von Mises tests. The Annals of Mathematical Statistics, 30:420-447.

Schumacher, M. (1984). Two-Sample Tests of Cramér–von Mises-and Kolmogorov–Smirnov-Type for Randomly Censored Data. International Statistical Review/Revue Internationale de Statistique, 263-281.

Examples

if (requireNamespace("survival", quietly = TRUE)) {
library(survival)

data <- data.frame(y=stanford2$time,
delta=stanford2$status,
group=as.numeric(stanford2$age<=35)+as.numeric(stanford2$age<=47))
rc.cvm(data,weights=table(data$group)/nrow(data))
}

Survival function estimator under left truncation and right censoring

Description

Computes the survival function estimator accounting for censored observations. It also returns pointwise confidence bands.

Usage

rc.estimator(
  o.sample,
  conf.int = FALSE,
  alpha = 0.05,
  conf.type = c("plain", "loglog")
)

Arguments

o.sample

Matrix or data frame with columns (U, Y, Delta, group).

conf.int

Logical, set as default to FALSE. If set to TRUE, the function returns a pointwise confidence band.

alpha

Pointwise confidence bands with 1−α1-\alpha confidence level

conf.type

Type of pointwise confidence band. Set as default to plainplain.

Details

The estimator is defined as

Sn(t)=∏yi≤t(1−dini),S_n(t) = \prod_{y_i \leq t} \left( 1-\frac{d_i}{n_i} \right),

where y1,…,ymy_1, \ldots, y_m are the distinct observed event times, di=#{j:Yj=yi,Δj=1}d_i = \# \{j : Y_j = y_i , \Delta_j=1 \} and ni=#{j:Uj≤yi≤Yj}n_i = \#\{j : U_j \leq y_i \leq Y_j\}. It reduces to the Kaplan–Meier estimator if data are not subject to truncation, and to the Lynden-Bell estimator if no censoring is present.

The variance for the confidence bands follows a Greenwood's like formula:

Var(Sn(t))=Sn(t)2∑yi≤tdini(ni−di).Var(S_n(t)) = S_n(t)^2 \sum_{y_i \leq t} \frac{d_i}{n_i(n_i-d_i)}.

Different transformations are also possible.

Value

An object with the following content:

fail.time: ordered distinct observed event times

estimation: estimated survival function at each observed event time

prob: jumps of the estimator

If conf.int is set to TRUE, it also returns the confidence band lower and upper limits

References

Klein, J. P. and Moeschberger, M. L. (2003). Survival Analysis: Techniques for Censored and Truncated Data. Springer

Wang, M.C. (1991). Nonparametric estimation from cross-sectional survival data. Journal of the American Statistical Association, 86:130-143.

Stute, W. and Wang, J. L. (2008). The central limit theorem under random truncation. Bernoulli, 14:604–622.

Examples

x <- rnorm(500,4,1)
c <- rnorm(500,4,1)
o.sample <- data.frame(y = pmin(x,c),delta = as.numeric(x <= c))
plot(rc.estimator(o.sample,conf.int=TRUE,conf.type='loglog'))
curve(1-pnorm(x,4,1),add=TRUE,col=2)

Kolmogorov–Smirnov-type statistic for the k-sample problem under right censoring

Description

Computes the Kolmogorov–Smirnov statistic adapted to right censoring.

Usage

rc.ks(p.sample, weights = NULL, plot.curves = FALSE)

Arguments

p.sample

Matrix or data frame with columns (Y, Delta, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

plot.curves

Logical, FALSE by default. Otherwise, it represents the k distribution functions to be compared.

Details

In Kiefer (1959), the kk-sample version of the Kolmogorov–Smirnov test is defined as

DKS=sup⁡t∑j=1knj(Fjnj(t)−Fn(t))2,D_{KS} = \sup_t \sum_{j=1}^k n_j \left( F_{jn_j}(t) - F_n(t)\right)^2,

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for right censoring.

For the particular case of k=2k=2, the test statistic reduces to

DKS=(n1p22+n2p12)(sup⁡t∣F1n1(t)−F2n2(t)∣)2,D_{KS} = (n_1p_2^2 + n_2p_1^2) \left(\sup_t \mid F_{1n_1}(t) - F_{2n_2}(t) \mid\right)^2,

thus the test indeed extends the classical two-sample Kolmogorov–Smirnov test. A two-sample Kolmogorov–Smirnov-type test for right-censored data was proposed in Schumacher (1984).

Value

A list with the following components:

  • statistic: numerical value of the Kolmogorov–Smirnov statistics.

  • time: time when the maximum is attained.

References

Kiefer, J. (1959). K-sample analogues of the Kolmogorov–Smirnov and Cramér–von Mises tests. The Annals of Mathematical Statistics, 30:420-447.

Schumacher, M. (1984). Two-Sample Tests of Cramér–von Mises-and Kolmogorov–Smirnov-Type for Randomly Censored Data. International Statistical Review/Revue Internationale de Statistique, 263-281.

Examples

if (requireNamespace("survival", quietly = TRUE)) {
library(survival)

data <- data.frame(y=stanford2$time,
delta=stanford2$status,
group=as.numeric(stanford2$age<=35)+as.numeric(stanford2$age<=47))
rc.ks(p.sample=data,weights=table(data$group)/nrow(data),plot.curves=TRUE)
}

Weighted log-rank tests under left truncation

Description

Computes weighted log-rank-type tests (Fleming–Harrington family) for k groups with left truncation and right censoring.

Usage

rc.logrank(p.sample, p = 0, q = 0, plot.curves = FALSE)

Arguments

p.sample

Matrix or data frame with columns (U, Y, Delta, group).

p, q

Nonnegative weight parameters. If one has length 1 and the other is a vector, the scalar is recycled.

plot.curves

Logical, default to FALSE. If TRUE, the kk distributions to be compared are depicted

Details

The test statistic is based on the quantity

Lj=∑i=1mωi(dji−dirjiri),L_j = \sum_{i=1}^m \omega_i \left(d_{ji} - d_i \frac{r_{ji}}{r_i}\right),

for j∈{1,…,k}j \in \{1, \ldots, k\}. Denote by y1,…,ymy_1, \ldots, y_m the distinct observed event times from the kk samples. For a time yiy_i and a group jj, djid_{ji} denotes the total count of individuals that experience the event, and rjir_{ji} is the number of individuals at risk. In addition, di=∑j=1kdjid_i = \sum_{j=1}^k d_{ji} and ri=∑j=1krjir_i = \sum_{j=1}^k r_{ji}, which are the total number of events observed and the total number of individuals at risk at time yiy_i, respectively.

Finally, the weights ω1,…,ωm\omega_1, \ldots, \omega_m are taken as

wi=S^(yi)p(1−S^(yi))q,w_i = \hat{S}(y_i)^p (1-\hat{S}(y_i))^q,

with S^(xi)\hat{S}(x_i) the pooled survival just before the event time. The choice p=0=qp=0=q results in the classical version of the log-rank test.

The test statistic is given by

(L1,…,Lk−1)Σ^−1(L1,…,Lk−1)⊤,(L_1, \ldots, L_{k-1}) \hat{\Sigma}^{-1}(L_1, \ldots, L_{k-1})^\top,

where Σ^\hat{\Sigma} is the matrix with the variance-covariance estimators. Each term in the matrix includes the correction factor (nj−dj)/(nj−1)(n_j-d_j)/(n_j-1) for tied event times. The test statistic follows an χk−12\chi^2_{k-1} distribution under the null hypothesis of equal target distributions in the kk populations.

Value

A matrix with columns statistic and p.value.

References

Klein, J.P., and Moeschberger, M. L. (2003). Survival Analysis: Techniques for Censored and Truncated Data. Springer, New York.

Examples

if (requireNamespace("survival", quietly = TRUE)) {
library(survival)
data <- data.frame(y=stanford2$time,
delta=stanford2$status,
group=as.numeric(stanford2$age<=35)+as.numeric(stanford2$age<=47))
rc.logrank(data, p = c(0, 1, 2), q = 0)
}

Cramér–von Mises-type test for the kk-sample problem under right censoring

Description

Computes the Kolmogorov–Smirnov test adapted to left truncation and right censoring and the corresponding pp-value.

Usage

rc.pv.cvm(p.sample, weights = NULL, B = 500, keep.boot = FALSE)

Arguments

p.sample

Matrix or data frame with columns (U, Y, Δ\Delta, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

B

Number of bootstrap replications to approximate the pp-value.

keep.boot

Logical, default to FALSE. If TRUE, the function returns the evaluation of the Cramér–von Mises statistic on the bootstrap resamples.

Details

In Kiefer (1959), the kk-sample version of the Cramér–von Mises test is defined as

DCvM=∑j=1knj∫(Fjnj(t)−Fn(t))2dFn(t),D_{CvM} = \sum_{j=1}^k n_j \int \left( F_{jn_j}(t) - F_n(t)\right)^2 dF_n(t),

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for right censoring.

The pp-value is approximated by means of the obvious bootstrap accounting for left truncation and right censoring, studied in Efron (1981).

Value

A list with the following:

  • statistic: Cramér–von Mises statistic evaluated on the the samples.

  • pvalue: pp-value of the test approximated via bootstrap.

  • curves: A list with the estimators of the kk distribution functions to be compared.

  • groups: Group indicator.

  • stat.boot: The Cramér–von Mises statistic evaluated from the bootstrap resamples.

References

Efron, B. (1981). Censored data and the bootstrap. Journal of the American Statistical Association, 76: 312-319.

Kiefer, J. (1959). K-sample analogues of the Kolmogorov–Smirnov and Cramér–von Mises tests. The Annals of Mathematical Statistics, 30:420-447.

Examples

if (requireNamespace("survival", quietly = TRUE)) {
library(survival)
data <- data.frame(y=stanford2$time,
delta=stanford2$status,
group=as.numeric(stanford2$age<=35)+as.numeric(stanford2$age<=47))
aa <- rc.pv.cvm(data,weights=table(data$group)/nrow(data), B = 200)
plot(aa)
aa$pvalue
}

Kolmogorov–Smirnov-type test for the kk-sample problem under right censoring

Description

Computes the Kolmogorov–Smirnov test adapted to right censoring and the corresponding pp-value.

Usage

rc.pv.ks(
  p.sample,
  weights = NULL,
  B = 500,
  plot.curves = FALSE,
  keep.boot = FALSE
)

Arguments

p.sample

Matrix or data frame with columns (U, Y, Δ\Delta, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

B

Number of bootstrap replications to approximate the pp-value

plot.curves

logical, set to FALSE by default. If TRUE, the function depicts the kk functions to be compared.

keep.boot

Logical, default to FALSE. If TRUE, the statistics evaluated on the bootstrap resamples are included in the output.

Details

In Kiefer (1959), the kk-sample version of the Kolmogorov–Smirnov test is defined as

DKS=sup⁡t∑j=1knj(Fjnj(t)−Fn(t))2,D_{KS} = \sup_t \sum_{j=1}^k n_j \left( F_{jn_j}(t) - F_n(t)\right)^2,

where FjnjF_{jn_j} is the cumulative distribution function estimator of calculated only with the jj-th sample, and FnF_n is given by

Fn(t)=∑j=1kpjFjnj(t),F_n(t) =\sum_{j=1}^k p_j F_{jn_j}(t),

where p1,…,pkp_1, \ldots, p_k correspond to the input weights. This function implements the previous test statistic accounting for right censoring.

For the particular case of k=2k=2, the test statistic reduces to

DKS=(n1p22+n2p12)(sup⁡t∣F1n1(t)−F2n2(t)∣)2,D_{KS} = (n_1p_2^2 + n_2p_1^2) \left(\sup_t \mid F_{1n_1}(t) - F_{2n_2}(t) \mid\right)^2,

thus the test indeed extends the classical two-sample Kolmogorov–Smirnov test. A two-sample Kolmogorov–Smirnov-type test for right-censored data was proposed in Schumacher (1984).

The pp-value is approximated by means of the obvious bootstrap accounting for right censoring, studied in Efron (1981).

Value

A list with the following components:

  • statistic: numerical value of the Kolmogorov–Smirnov statistic.

  • pvalue: approximated p-value of the test.

  • curves: A list with the estimators of the kk distribution functions to be compared.

  • groups: Group indicator

  • stat.boot: statistics computed from the bootstrap resamples.

References

Efron, B. (1981). Censored data and the bootstrap. Journal of the American Statistical Association, 76: 312-319.

Kiefer, J. (1959). K-sample analogues of the Kolmogorov–Smirnov and Cramér–von Mises tests. The Annals of Mathematical Statistics, 30:420-447.

Examples

if (requireNamespace("survival", quietly = TRUE)) {
library(survival)

data <- data.frame(y=stanford2$time,
delta=stanford2$status,
group=as.numeric(stanford2$age<=35)+as.numeric(stanford2$age<=47))
aa <- rc.pv.ks(data,weights=table(data$group)/nrow(data), B = 200)
plot(aa)
aa$pvalue
}

Right-censored data simulation

Description

Simulates right-censored survival data from prespecified event-time and censoring-time distributions.

Usage

rc.sim(
  n,
  rtarget,
  target.args = list(),
  rcens,
  cens.args = list(),
  seed = NULL
)

Arguments

n

Sample size.

rtarget

A function that simulates event/survival times.

target.args

A list with the parameters of the target distribution.

rcens

A function that simulates censoring times.

cens.args

A list with the parameters of the censoring distribution.

seed

Optional seed for reproducibility.

Value

A data frame with nn rows and two columns:

y

Observed follow-up time, i.e. min⁡(X,C)\min(X, C).

delta

Event indicator, equal to 1 if the event is observed and 0 if censored.

Examples

aa <- rc.sim(n = 1000, rtarget = rweibull,
target.args = list(shape = 2, scale = 3),
rcens = rexp, cens.args = list(rate = 0.2),
seed = 123)
head(aa)
mean(aa$delta == 0)  # empirical censoring rate

Tests for the kk-sample problem under right censoring

Description

Computes kk-sample tests adapted to right censoring and the corresponding pp-value.

Usage

rc.test(
  p.sample,
  weights = NULL,
  tests = c("ks", "cvm", "logrank"),
  B = 500,
  plot.curves = FALSE,
  p = 0,
  q = 0,
  seed = NULL,
  keep.boot = FALSE
)

Arguments

p.sample

Matrix or data frame with columns (Y, Δ\Delta, group).

weights

Vector of weights of the estimator under the null hypothesis. If no vector is provided, weights proportional to each sample size are assigned automatically by the function. Not used when tests="logrank".

tests

Tests to perform. One or more of Kolmogorov–Smirnov ('ks'), Cramér–von Mises ('cvm'), or weighted log-rank-type tests ('logrank').

B

Number of bootstrap replications to approximate the pp-values of the Kolmogorov–Smirnov and/or Cramér–von Mises tests.

plot.curves

Logical, FALSE by default. If set to TRUE, the kk survival functions to be compared are depicted.

p, q

Weights of the log-rank-type tests. The choice p=0=qp=0=q yields the classical log-rank test.

seed

Seed for the bootstrap resamples.

keep.boot

Logical. If TRUE, bootstrap replicates are included in the returned object as stat.boot. Default is FALSE.

Details

This function collects the three tests implemented in this package: Kolmogorov–Smirnov, Cramér–von Mises and weighted log-rank-type tests, (Klein and Moeschberger, 2003) adapted to right censoring. The pp-values of the first two are approximated by the obvious bootstrap (Efron, 1981), and the pp-value of the log-rank tests is computed by the χk−12\chi^2_{k-1} asymptotic distribution of the test statistic, where kk is the number of groups.

Value

A list with the following components:

  • statistic: numerical value of the Kolmogorov–Smirnov and/or Cramér–von Mises statistics.

  • p.value: approximated pp-value of the tests.

  • logrank: a matrix with weights p and q, test statistics, and pp-values.

  • B: number of bootstrap replications.

  • tests: tests performed, as specified in the input.

  • curves: distribution function estimators of the kk samples to be compared.

  • groups: group indicators.

  • stat.boot: evaluation of the tests in the bootstrap resamples. Only when keep.boot = TRUE.

The summary method returns a data frame with one row per test and the following columns:

Test

Name of the test. For the weighted log-rank-type tests, the weights p and q are detailed.

Statistic

Observed value of the test statistic.

p.value

Corresponding pp-value.

References

Klein, J.P., and Moeschberger, M. L. (2003). Survival Analysis: Techniques for Censored and Truncated Data. Springer, New York.

Efron, B. (1981). Censored data and the bootstrap. Journal of the American Statistical Association, 76: 312-319.

Examples

if (requireNamespace("survival", quietly = TRUE)) {
library(survival)

data <- data.frame(y=stanford2$time,delta=stanford2$status,
group=as.numeric(stanford2$age<=35)+as.numeric(stanford2$age<=47))
aa <- rc.test(p.sample=data,weights=table(data$group)/nrow(data),
plot.curves=TRUE,tests=c('ks','cvm','logrank'),
B = 200, p=c(0,1,2), q=0 )

plot(aa)
summary(aa)
}

Summary method for k-sample test objects

Description

Produces a table with the test name, test statistic and p-value for the procedures computed by ltrc.test().

Usage

## S3 method for class 'ksamples_test'
summary(object, ...)

Arguments

object

An object of class "ksamples_test".

...

Additional arguments passed to methods.

Value

A data frame with columns:

Test

Name of the test ("KS", "CvM", or the corresponding ⁠(p, q)⁠ values for weighted rank tests).

Statistic

Observed test statistic.

p-value

Associated p-value.