Learn R Programming

survtmle (version 1.1.1)

plot.tp.survtmle: Plot Results of Cumulative Incidence Estimates

Description

Step function plots for both raw and smoothed (monotonic) estimates, the latter by isotonic regression of the raw estimates, of cumulative incidence.

Usage

# S3 method for tp.survtmle
plot(x, ..., type = c("iso", "raw"),
  pal = ggsci::scale_color_lancet())

Arguments

x

object of class tp.survtmle as produced by a sequence of appropriate calls to survtmle and timepoints

...

additional arguments passed plot as necessary

type

character describing whether to provide a plot of raw ("raw") or monotonic ("iso") estimates in the resultant step function plot, with the latter being computed by a call to stats::isoreg

pal

A ggplot2 palette object from the ggsci package. The default of scale_color_lancet is generally appropriate for medical and epidemiologic applications, though there are situations in which one might opt to change this. Note that this can also be overridden in the resultant plot object using standard ggplot2 semantics.

Value

object of class ggplot containing a step function plot of the raw or smoothened point estimates of cumulative incidence across a series of timepoints of interest.

Examples

Run this code
# NOT RUN {
library(survtmle)
set.seed(341796)
n <- 100
t_0 <- 10
W <- data.frame(W1 = runif(n), W2 = rbinom(n, 1, 0.5))
A <- rbinom(n, 1, 0.5)
T <- rgeom(n,plogis(-4 + W$W1 * W$W2 - A)) + 1
C <- rgeom(n, plogis(-6 + W$W1)) + 1
ftime <- pmin(T, C)
ftype <- as.numeric(ftime == T)
suppressWarnings(
  fit <- survtmle(ftime = ftime, ftype = ftype,
                  adjustVars = W, glm.ftime = "I(W1*W2) + trt + t",
                  trt = A, glm.ctime = "W1 + t", method = "hazard",
                  verbose = TRUE,  t0 = t_0, maxIter = 2)
)
tpfit <- timepoints(fit, times = seq_len(t_0))
plot(tpfit)
# }

Run the code above in your browser using DataLab