Function CvMcens computes the Cramér-von Mises statistic and p-value for complete and right-censored data against eight possible distributions.

# Default S3 method
CvMcens(times, cens = rep(1, length(times)),
        distr = c("exponential", "gumbel", "weibull", "normal",
                  "lognormal", "logistic", "loglogistic", "beta"),
        betaLimits = c(0, 1), igumb = c(10, 10), BS = 999,
        params0 = list(shape = NULL, shape2 = NULL,
                       location = NULL, scale = NULL), tol = 1e-04, ...)
# S3 method for class 'formula'
CvMcens(formula, data,...)

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.

BS

Number of bootstrap samples.

params0

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.

tol

Precision of survival times.

formula

A formula with a numeric vector as response (which assumes no censoring) or Surv object.

data

Data frame for variables in formula.

...

Additional arguments.

Details

Koziol and Green (1976) proposed a Cramér-von Mises statistic for randomly censored data. This function reproduces this test for a given survival data and a theorical distribution. In presence of ties, different authors provide slightly different definitions of the product-limit estimator, what might provide different values of the test statistic.

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

To avoid long computation times due to bootstrapping, an alternative with complete data is the function cvm.test of the goftest package.

The precision of the survival times is important mainly in the data generation step of the bootstrap samples.

Value

CvMcens returns an object of class "CvMcens".

An object of class "CvMcens" is a list containing the following components:

Distribution

Null distribution.

Hypothesis

Parameters under the null hypothesis (if params0 is provided).

Test

Vector containing the value of the Cramér-von Mises statistic (CvM) and the estimated p-value (p-value).

Estimates

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

StdErrors

Vector containing the estimated standard errors.

aic

The Akaike information criterion.

bic

The so-called BIC or SBC (Schwarz Bayesian criterion).

BS

The number of bootstrap samples used.

References

J. A. Koziol and S. B. Green. A Cramér-von Mises statistic for randomly censored data. In: Biometrika, 63 (3) (1976), 465-474.

A. N. Pettitt and M. A. Stephens. Modified Cramér-von Mises statistics for censored data. In: Biometrika, 63 (2) (1976), 291-298.

Author

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

Warning

If the amount of data is large, the execution time of the function can be elevated. The parameter BS can limit the number of random censored samples generated and reduce the execution time.

See also

Function cvm.test (Package goftest) 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)
CvMcens(times = rweibull(100, 12, scale = 4), distr = "weibull",
        BS = 199)
#> Distribution: weibull 
#> 
#> CvM Test results:
#>     CvM p-value 
#>   0.021   0.975 
#> 
#> Parameter estimates (se):
#> shape             scale             
#> 12.241 (0.938)     4 (0.034)     
#> 
#> AIC: 84.375 
#> BIC: 89.585 
#> 
print(CvMcens(times = rweibull(100, 12, scale = 4), distr = "normal",
      BS = 99), degs = 4, print.AIC = FALSE, print.BIC = FALSE)
#> Distribution: normal 
#> 
#> CvM Test results:
#>     CvM p-value 
#>   0.199   0.020 
#> 
#> Parameter estimates (se):
#> location            scale               
#> 3.8342 (0.0408)     0.4076 (0.0288)     
#> 
#> 

if (FALSE) { # \dontrun{
# Censored data
set.seed(123)
colonsamp <- colon[sample(nrow(colon), 300), ]
CvMcens(Surv(time, status) ~ 1, colonsamp, distr = "normal")
} # }