timepoints: Evaluate Results over Time Points of Interest

View source: R/timepoints.R

timepointsR Documentation

Evaluate Results over Time Points of Interest

Description

Wrapper function for survtmle that takes a fitted survtmle object and computes the TMLE estimated incidence for all times specified in the times argument. For this function to work, the original call to survtmle should have been executed with returnModels = TRUE. This allows the function to be more efficient than repeated calls to survtmle in that timepoints will use fitted censoring (and hazard if method="hazard" was used in the original call) estimates. It is therefore advisable that the vector times used in the call to timepoints not include times beyond the time specified in t0 in the original call to survtmle. This can be ensured be making the original call to survtmle with t0 = max(ftime).

Usage

timepoints(object, times, returnModels = FALSE)

Arguments

object

A fitted survtmle object with returnModels = TRUE

times

The times to evaluate incidence.

returnModels

Should the function return fitted GLM or Super Learner models at each timepoint. If set to TRUE, memory issues could arise depending on the number of timepoints specified and the size of the Super Learner library.

Value

An object of class tp.survtmle with number of entries equal to length(times). Each entry is named "tX", where X denotes a single value of times.

Examples

# simulate data
set.seed(1234)
n <- 100
ftime <- round(runif(n, 1, 4))
ftype <- round(runif(n, 0, 2))
trt <- rbinom(n, 1, 0.5)
adjustVars <- data.frame(W1 = rnorm(n), W2 = rnorm(n))

# fit an initial survtmle object with t0=max(ftime)
fm <- survtmle(
  ftime = ftime, ftype = ftype,
  trt = trt, adjustVars = adjustVars,
  glm.trt = "1", glm.ftime = "trt + W1 + W2",
  glm.ctime = "trt + W1 + W2", method = "mean",
  returnModels = TRUE
)

# call timepoints to get cumulative incidence estimates at each timepoint
allTimes <- timepoints(object = fm, times = 1:4, returnModels = FALSE)

# look at results for time 1
class(allTimes$t1)
allTimes$t1
# look at results for time 2
allTimes$t2

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