chisqcens.RdFunction chisqcens computes the general chi-squared test statistic for
right-censored data introduced by Kim (1993) and the respective p-value
using bootstrapping.
# Default S3 method
chisqcens(times, cens = rep(1, length(times)), M,
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, theta = NULL),
tol = 1e-04, start = NULL, ...)
# S3 method for class 'formula'
chisqcens(formula, data,...)Numeric vector of times until the event of interest.
Status indicator (1, exact time; 0, right-censored time). If not provided, all times are assumed to be exact.
Number indicating the number of cells that will be considered.
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. In addition, if the
character string used is "name", every distribution for which the
corresponiding density (dname), probability (pname)
and random generator (rname) functions are defined, can be used.
Two-components vector with the lower and upper bounds of the Beta distribution. This argument is only required, if the beta distribution is considered.
Two-components vector with the initial values for the estimation of the Gumbel distribution parameters.
Number of bootstrap samples.
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.
Precision of survival times.
A formula with a numeric vector as response (which assumes no censoring) or Surv object.
Data frame for variables in formula.
A named list giving the initial values of parameters of the named distribution or a function of data computing initial values and returning a named list. This argument may be omitted (default) for the eight prespecified distributions. See more details in mledist.
Additional arguments for the boot function of the
boot package.
The function implements the test introduced by Kim (1993) and returns the value of the test statistic.
The cell boundaries of the test are obtained via the quantiles, which
are based on the Kaplan-Meier estimate of the distribution function.
In the presence of right-censored data, it is possible that not all
quantiles are estimated, and in this case, the value of M
provided by the user is reduced.
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.
chisqcens returns an object of class "chisqcens".
An object of class "chisqcens" is a list containing the following components:
DistributionNull distribution.
HypothesisParameters under the null hypothesis (if params0 is provided).
TestVector containing the value of the test statistic (Statistic) and the
estimated p-value (p-value).
EstimatesVector with the maximum likelihood estimates of the parameters of the distribution under study.
StdErrorsVector containing the estimated standard errors.
CellNumberVector with two values: the original cell number introduced by the user and the final cell number used.
aicThe Akaike information criterion.
bicThe so-called BIC or SBC (Schwarz Bayesian criterion).
BSThe number of bootstrap samples used.
J. H. Kim. Chi-Square Goodness-of-Fit Tests for Randomly Censored Data. In: The Annals of Statistics, 21 (3) (1993), 1621-1639. URL: https://doi.org/10.1214/aos/1176349275
# Complete data
set.seed(123)
chisqcens(times = rgumbel(100, 12, scale = 4), M = 8, distr = "gumbel",
BS = 99)
#> Null hypothesis: the data follows a gumbel distribution
#>
#> Chi-squared Test results:
#> Statistic p-value
#> 2.812 0.120
#>
summary(chisqcens(times = rlogis(100, 20, scale = 3), M = 8, distr = "loglogistic",
BS = 105), print.AIC = FALSE, print.infoBoot = TRUE)
#> Distribution: loglogistic
#>
#> Chi-squared Test results:
#> Statistic p-value
#> 2.932 NA
#>
#> Parameter estimates (se):
#> shape scale
#> 5.019 (0.427) 19.362 (0.654)
#>
#> Cell numbers:
#> Original Final
#> 8 8
#>
#> BIC: 675.925
#>
#> Number of bootstrap samples: 105
#>
if (FALSE) { # \dontrun{
# Censored data
set.seed(123)
colonsamp <- colon[sample(nrow(colon), 300), ]
chisqcens(Surv(time, status) ~ 1, colonsamp, M = 6, distr = "normal")
} # }