ADcens {GofCens} | R Documentation |
Anderson-Darling test for complete and right-censored data
Description
ADcens
computes the Anderson-Darling test statistic and p-value for complete
and right-censored data against eight possible distributions using bootstrapping.
Usage
ADcens(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, BS = 999,
params = list(shape = NULL, shape2 = NULL,
location = NULL, scale = NULL),
prnt = TRUE, outp = "list", tol = 1e-04)
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 ( |
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. |
BS |
Number of bootstrap samples. |
params |
List specifying the parameters of the theoretical distribution.
By default, parameters are set to |
outp |
Indicator of how the output will be displayed. The possible formats are |
prnt |
Logical to indicate if the estimations of the Anderson-Darling statistic and p-value should be printed. Default is |
tol |
Precision of survival times. |
Details
When dealing with complete data, we recommend to use the function
ad.test
of the goftest package.
The parameter estimation is acomplished with the fitdistcens
function of the fitdistrplus package.
The precision of the survival times is important mainly in the data generation step of the bootstrap samples.
Value
If prnt = TRUE
, a list containing the following components:
Distribution |
Null distribution. |
AD |
Value of Anderson-Darling statistic. |
p-value |
Estimated p-value. |
Parameters |
List with the maximum likelihood estimates of the parameters of the distribution under study. |
The list is also returned invisibly.
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.
Author(s)
K. Langohr, M. Besalú, M. Francisco, G. Gómez.
References
G. Marsaglia and J. Marsaglia. Evaluating the Aderson-Darling Distrinution. In: Journal os Statistical Software, Articles, 9 (2) (2004), 1-5.
See Also
Function ad.test
(Package goftest) for complete data and
function gofcens for statistics and p-value of th Kolmogorov-Smirnov,
Cramér von-Mises and Anderson-Darling together for right-censored data.
Examples
# Complete data
set.seed(123)
ADcens(times = rweibull(100, 12, scale = 4), distr = "weibull",
BS = 199)
## Not run:
# Censored data
library(survival)
colonsamp <- colon[sample(nrow(colon), 100), ]
ADcens(colonsamp$time, colonsamp$status, distr = "normal")
## End(Not run)