kmPlot {GofCens} | R Documentation |
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.
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, ...)
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. |
... |
Optional arguments for function |
The parameter estimation is acomplished with the fitdistcens
function of the fitdistrplus package.
If prnt = TRUE
, a list containing the following components
Distribution |
Distribution under study. |
Parameters |
List with the maximum likelihood estimates of the parameters of the distribution under study. |
K. Langohr, M. Besalú, M. Francisco, G. Gómez.
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.
# Plots for complete data and default distributions
set.seed(123)
x <- rexp(1000, 0.1)
kmPlot(x)
# Plots for censored data using ggplot2
library(survival)
colonsamp <- colon[sample(nrow(colon), 100), ]
kmPlot(colonsamp$time, colonsamp$status, distr= "lognormal", ggp = TRUE)
# Plots for censored data from three distributions
data(nba)
kmPlot(nba$survtime, nba$cens, distr = c("normal", "weibull", "lognormal"),
prnt = FALSE)