Plot Average Risks
Plot average risks.
## S3 method for class 'ate' autoplot( object, type = "meanRisk", first.derivative = FALSE, estimator = object$estimator[1], ci = object$inference$ci, band = object$inference$band, plot.type = "1", plot = TRUE, smooth = FALSE, digits = 2, alpha = NA, ylab = NULL, ... )
object |
Object obtained with the function |
type |
[character vector] what to displayed.
Can be |
first.derivative |
[logical] If |
estimator |
[character] The type of estimator relative to which the risks should be displayed. |
ci |
[logical] If |
band |
[logical] If |
plot.type |
[character] Type of plot to be used.
|
plot |
[logical] Should the graphic be plotted. |
smooth |
[logical] Should a smooth version of the risk function be plotted instead of a simple function? |
digits |
[integer, >0] Number of decimal places. |
alpha |
[numeric, 0-1] Transparency of the confidence bands. Argument passed to |
ylab |
[character] Label for the y axis. |
... |
Additional parameters to cutomize the display. |
Invisible. A list containing:
plot: the ggplot object.
data: the data used to create the plot.
ate
to compute average risks.
library(survival) library(rms) library(ggplot2) #### simulate data #### n <- 1e2 set.seed(10) dtS <- sampleData(n,outcome="survival") seqTimes <- c(0,sort(dtS$time[dtS$event==1]),max(dtS$time)) #### Cox model #### fit <- cph(formula = Surv(time,event)~ X1+X2,data=dtS,y=TRUE,x=TRUE) #### plot.type = 1: for few timepoints #### ateFit <- ate(fit, data = dtS, treatment = "X1", times = c(1,2,5,10), se = TRUE, band = TRUE) ggplot2::autoplot(ateFit) ggplot2::autoplot(ateFit, band = FALSE) ggplot2::autoplot(ateFit, type = "diffRisk") ggplot2::autoplot(ateFit, type = "ratioRisk") #### plot.type = 2: when looking at all jump times #### ateFit <- ate(fit, data = dtS, treatment = "X1", times = seqTimes, se = TRUE, band = TRUE) ggplot2::autoplot(ateFit, plot.type = "2") ## customize plot outGG <- ggplot2::autoplot(ateFit, plot.type = "2", alpha = 0.25) outGG$plot + facet_wrap(~X1, labeller = label_both) ## Looking at the difference after smoothing ## Not run: outGGS <- ggplot2::autoplot(ateFit, plot.type = "2", alpha = NA, smooth = TRUE) outGGS$plot + facet_wrap(~X1, labeller = label_both) ## End(Not run) ## first derivative ## (computation of the confidence intervals takes time) ## (based on simulation - n.sim parameter) ## Not run: ggplot2::autoplot(ateFit, plot.type = "2", smooth = TRUE, band = FALSE, type = "diffRisk") ggplot2::autoplot(ateFit, plot.type = "2", smooth = TRUE, first.derivative = TRUE, band = FALSE, type = "diffRisk") ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.