# NOT RUN {
#### Example with data pbcsample
library(survival)
Formula <- Surv(Start, Stop, Event) ~ age + alk.phos + ast + chol + edema
## Fit an LTRC conditional inference forest on time-varying data
LTRCCIFobj <- ltrccif(formula = Formula, data = pbcsample, id = ID,
mtry = 3, ntree = 50L)
## Construct an estimated survival estimate for the second subject
tpnt <- seq(0, max(pbcsample$Stop), length.out = 50)
newData <- pbcsample[pbcsample$ID == 2, ]
Pred <- predictProb(object = LTRCCIFobj, newdata = newData, newdata.id = ID,
time.eval = tpnt)
## Since time.tau = NULL, Pred$survival.probs is in the matrix format, with dimensions:
dim(Pred$survival.probs) # length(time.eval) x nrow(newdata)
## Plot the estimated survival curve
plot(Pred$survival.times, Pred$survival.probs, type = "l", col = "red",
xlab = "Time", ylab = "Survival probabilities")
# }
Run the code above in your browser using DataLab