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

View source: R/plots.R

plot.tp.survtmleR Documentation

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 class 'tp.survtmle'
plot(
  x,
  ...,
  incidence = TRUE,
  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

incidence

boolean indicating whether to plot cumulative incidence or 1 minus cumulative incidence (corresponding to survival curves if only one type of failure)

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 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

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)

benkeser/survtmle documentation built on Nov. 23, 2023, 4:45 a.m.