KScens {GofCens}R Documentation

Kolmogorov-Smirnov test for complete and right-censored data

Description

Function KScens computes the Kolmogorov-Smirnov statistic and p-value for complete and right-censored data against eight possible distributions.

Usage

KScens(times, cens = rep(1, length(times)), 
       distr = c("exponential", "gumbel", "weibull", "normal", 
                 "lognormal", "logistic", "loglogistic", "beta"), 
       betaLimits = c(0, 1), igumb = c(10, 10), degs = 3, 
       params = list(shape = NULL, shape2 = NULL, location = NULL, 
                     scale = NULL), outp = "list", prnt = TRUE)

Arguments

times

Numeric vector of times until the event of interest.

cens

Status indicator (1, exact time; 0, right-censored time). If not provided, all times are assumed to be exact.

distr

A string specifying the name of the distribution to be studied. The possible distributions are the exponential ("exponential"), the Weibull ("weibull"), the Gumbel ("gumbel"), the normal ("normal"), the lognormal ("lognormal"), the logistic ("logistic"), the loglogistic ("loglogistic"), and the beta ("beta") distribution.

betaLimits

Two-components vector with the lower and upper bounds of the Beta distribution. This argument is only required, if the beta distribution is considered.

igumb

Two-components vector with the initial values for the estimation of the Gumbel distribution parameters.

degs

Integer indicating the number of decimal places of the numeric results of the output.

params

List specifying the parameters of the theoretical distribution. By default, parameters are set to NULL and estimated with the maximum likelihood method. This argument is only considered, if all parameters of the studied distribution are specified.

outp

Indicator of how the output will be displayed. The possible formats are list and table.

prnt

Logical to indicate if the estimations of the Kolmogorov-Smirnov statistic and p-value should be printed. Default is TRUE.

Details

Fleming et al. (1980) proposed a modified Kolmogorov-Smirnov test to use with right-censored data. This function reproduces this test for a given survival data and a theorical distribution. The p-value is computed following the results of Koziol and Byar (1975) and the output of the function follows the notation of Fleming et al. (1980).

In presence of ties, different authors provide slightly different definitions of \widehat{F}_n(t), with which other values of the test statistic might be obtained.

When dealing with complete data, we recommend to use the function ks.test of the stats package.

The parameter estimation is acomplished with the fitdistcens function of the fitdistrplus package.

Value

If prnt = TRUE, a list containing the following components:

Distribution

Null distribution.

p-value

P-value.

A

Value of the modified Kolmogorov-Smirnov statistic.

F(y_m)

Estimation of the image of the last recorded time.

y_m

Last recorded time.

Parameters

List with the maximum likelihood estimates of the parameters of the distribution under study.

The list is also returned invisibly.

Author(s)

K. Langohr, M. Besalú, M. Francisco, G. Gómez.

References

T. R. Fleming et al. Modified Kolmogorov-Smirnov test procedure with application to arbitrarily right-censored data. In: Biometrics 36 (1980), 607-625.

J.A. Koziol and P. Byar. Percentage Points of the Asymptotic Distributions of One and Two Sample K-S statistics for Truncated or Censored Data. In: Technometrics 17 (4) (1975), 507-510.

See Also

Function ks.test (Package stats) for complete data and gofcens for statistics and p-value of Kolmogorov-Smirnov, Cramér von-Mises and Anderson-Darling together for right-censored data.

Examples

# Complete data
set.seed(123)
KScens(times = rweibull(1000, 12, scale = 4), distr = "weibull", outp = "table")

# Censored data
library(survival)
colonsamp <- colon[sample(nrow(colon),100),]
KScens(colonsamp$time, colonsamp$status, distr = "norm", outp = "list")

data(nba)
KScens(nba$survtime, nba$cens, "logis", degs = 2)
KScens(nba$survtime, nba$cens, "beta", betaLimits = c(0, 80))

[Package GofCens version 0.98 Index]