kmPlot {GofCens} | R Documentation |
Plot of the Kaplen-Meier and parametric estimations
Description
Function kmPlot
is a function that generates a plot that combines a
Kaplan-Meier survival curve and a parametric survival curve in the same graph.
It is useful for comparing non-parametric survival estimates with the fitted
parametric survival model.
Usage
## Default S3 method:
kmPlot(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 class 'formula'
kmPlot(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 Weibull ( |
colour |
Vector indicating the colours of the displayed plots. |
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. |
ggp |
Logical to use or not the ggplot2 package to draw the plots.
Default is |
m |
Optional layout for the plots to be displayed. |
prnt |
Logical to indicate if the maximum likelihood estimates of the
parameters should be printed. Default is |
degs |
Integer indicating the number of decimal places of the numeric results of the output. |
formula |
A formula with a numeric vector as response (which assumes no censoring) or |
data |
Data frame for variables in |
... |
Optional arguments for function |
Details
The parameter estimation is acomplished with the fitdistcens
function of the fitdistrplus package.
Value
If prnt = TRUE
, the following output is returned:
Distribution |
Distribution under study. |
Parameters |
List with the maximum likelihood estimates of the parameters of the distribution under study. |
In addition, a list with the same contents is returned invisibly.
Author(s)
K. Langohr, M. Besalú, M. Francisco, G. Gómez.
References
Peterson Jr, Arthur V. Expressing the Kaplan-Meier estimator as a function of empirical subsurvival functions. In: Journal of the American Statistical Association 72.360a (1977): 854-858.
Examples
# Plots for complete data and default distributions
set.seed(123)
x <- rexp(1000, 0.1)
kmPlot(x)
# Plots for censored data using ggplot2
data(colon)
kmPlot(Surv(time, status) ~ 1, colon, distr= "lognormal", ggp = TRUE)
# Plots for censored data from three distributions
data(nba)
kmPlot(Surv(survtime, cens) ~ 1, nba, distr = c("normal", "weibull", "lognormal"),
prnt = FALSE)