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

Description Usage Arguments Value Examples

View source: R/plots.R

Description

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

Usage

1
2
3
## S3 method for class '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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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)

survtmle documentation built on May 2, 2019, 9:44 a.m.