Description Usage Arguments See Also Examples
Plot the survival curves returned from predict.mtlr. Users must have packages ggplot2 and reshape2 installed in order to use this function.
Survival curves for MTLR are smoothed using a monotonic cubic spline using a Hyman filtering between time points. For details regarding this
smoothing function see splinefun
.
1 2 | plotcurves(curves, index = 1, color = c(), xlim = c(),
remove_legend = TRUE)
|
curves |
survival curves formatted the same as those from predict.mtlr. Time points must be in the first column of the matrix followed by columns representing survival probabilities for each observation. |
index |
the index of the observation to plot. Here an index of 1 will refer to the second column of the curves object. If over 15 indices are given the legend will be removed as to not take up plotting space. To avoid this behavior set remove_legend = FALSE. |
color |
the color of the plotted survival curve. The length of color must match the length of index. |
xlim |
the limits of the x-axis (must be a 2 length vector). |
remove_legend |
if TRUE the legend will be removed if over 15 indices are supplied. If FALSE the legend will remain, however be aware that the legend may take up lots of space. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #Set up the example:
library(survival)
mod <- mtlr(Surv(time,status)~., data = lung)
curves <- predict(mod, type = "survivalcurve")
plotcurves(curves, 1:10)
plotcurves(curves, 1:3, color = c("red","blue","purple"))
plotcurves(curves, 1:10, xlim = c(0,42))
#Note the legend is now gone:
plotcurves(curves, 1:20)
#and it is back again:
plotcurves(curves, 1:20, remove_legend = FALSE)
|
Warning messages:
1: Use of `plot_data$value` is discouraged. Use `value` instead.
2: Use of `plot_data$Index` is discouraged. Use `Index` instead.
Warning messages:
1: Use of `plot_data$value` is discouraged. Use `value` instead.
2: Use of `plot_data$Index` is discouraged. Use `Index` instead.
Warning messages:
1: Use of `plot_data$value` is discouraged. Use `value` instead.
2: Use of `plot_data$Index` is discouraged. Use `Index` instead.
3: Removed 14100 row(s) containing missing values (geom_path).
Warning messages:
1: Use of `plot_data$value` is discouraged. Use `value` instead.
2: Use of `plot_data$Index` is discouraged. Use `Index` instead.
Warning messages:
1: Use of `plot_data$value` is discouraged. Use `value` instead.
2: Use of `plot_data$Index` is discouraged. Use `Index` instead.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.