Function cumhazPlot
uses the cumulative hazard plot to check if a certain distribution
is an appropiate choice for the data.
# S3 method for default
cumhazPlot(times, cens = rep(1, length(times)), distr = "all6", colour = 1,
betaLimits = c(0, 1), igumb = c(10, 10), ggp = FALSE, m = NULL,
prnt = TRUE, degs = 3, ...)
# S3 method for formula
cumhazPlot(formula, data, ...)
If prnt = TRUE
, the following output is returned:
A list with the maximum likelihood estimates of the parameters of all distributions considered.
In addition, a list with the same contents is returned invisibly.
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.
A string specifying the names of the distributions 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. By default, distr
is set to "all6"
, which means that the cumulative hazard
plots are drawn for the Weibull, loglogistic, lognormal, Gumbel,
logistic, and normal distributions.
Colour of the points. Default colour: black.
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.
Logical to use or not the ggplot2 package to draw the plots.
Default is FALSE
.
Optional layout for the plots to be displayed.
Logical to indicate if the maximum likelihood estimates of the
parameters of all distributions considered should be printed.
Default is TRUE
.
Integer indicating the number of decimal places of the numeric results of the output.
A formula with a numeric vector as response (which assumes no censoring) or Surv
object.
Data frame for variables in formula
.
Optional arguments for function par
, if ggplo = FALSE
.
K. Langohr, M. Besalú, M. Francisco, G. Gómez.
The cumulative hazard plot is based on transforming the cumulative hazard function \(\Lambda\) in such a way that it becomes linear in \(t\) or \(\log(t)\). This transformation is specific for each distribution. The function uses the data to compute the Nelson-Aalen estimator of the cumulative hazard function, \(\widehat{\Lambda}\), and the maximum likelihood estimators of the parameters of the theoretical distribution under study. If the distribution fits the data, the plot is expected to be a straight line.
The parameter estimation is acomplished with the fitdistcens
function of the fitdistrplus package.
# Complete data and default distributions
set.seed(123)
x <- rlogis(1000, 50, 5)
cumhazPlot(x, lwd = 2)
# Censored data comparing three distributions
data(nba)
cumhazPlot(Surv(survtime, cens) ~ 1, nba, distr = c("expo", "normal", "gumbel"))
Run the code above in your browser using DataLab