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

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)
#> [1] "survtmle"
allTimes$t1
#> $est #> [,1] #> 0 1 0.11420933 #> 1 1 0.08893310 #> 0 2 0.09813023 #> 1 2 0.02051795 #> #> $var #> 0 1 1 1 0 2 1 2 #> 0 1 1.851155e-03 3.343729e-05 -1.918862e-04 -4.921541e-06 #> 1 1 3.343729e-05 1.679328e-03 -1.913208e-05 -3.350074e-05 #> 0 2 -1.918862e-04 -1.913208e-05 1.933470e-03 5.318150e-09 #> 1 2 -4.921541e-06 -3.350074e-05 5.318150e-09 3.632602e-04 #>
# look at results for time 2 allTimes$t2
#> $est #> [,1] #> 0 1 0.2725236 #> 1 1 0.2440495 #> 0 2 0.1758847 #> 1 2 0.2003141 #> #> $var #> 0 1 1 1 0 2 1 2 #> 0 1 4.513203e-03 6.160159e-05 -9.378340e-04 5.297656e-05 #> 1 1 6.160159e-05 4.270541e-03 -8.875712e-05 -1.167929e-03 #> 0 2 -9.378340e-04 -8.875712e-05 3.664619e-03 1.676504e-05 #> 1 2 5.297656e-05 -1.167929e-03 1.676504e-05 3.802279e-03 #>