predictProb {LTRCforests} | R Documentation |
Compute a Survival Curve from a LTRCCIF model or a LTRCRRF model
Description
Constructs a monotone nonincreasing estimated survival curve from a LTRCCIF model or a LTRCRRF model for any given (left-truncated) right-censored survival data with time-varying covariates. It can also compute survival function estimates for left-truncated right-censored data with time-invariant covariates.
Usage
predictProb(
object,
newdata = NULL,
newdata.id,
OOB = FALSE,
time.eval,
time.tau = NULL
)
Arguments
object |
|
newdata |
an optional data frame containing the test data
(with the names of the variables the same as those in |
newdata.id |
optional variable name of subject identifiers for |
OOB |
a logical specifying whether out-of-bag predictions are desired (only if |
time.eval |
a vector of time points, at which the estimated survival probabilities will be computed. |
time.tau |
an optional vector, with the i-th entry giving the upper time limit for the
computed survival probabilities for the i-th data of interest (i.e., only computes
survival probabilies at |
Value
A list containing:
survival.id |
subject identifiers. |
survival.obj |
an object of class |
survival.probs |
the estimated survival probabilities for each data of interest. It is a list if the length of the estimated values differs from one to another; otherwise, it is a matrix with the number of columns equal to the number of the data of interest, number of rows equal to the number of the time points at which the estimated survival probabilities are computed. |
survival.tau |
the input value |
survival.times |
the input value |
See Also
sbrier_ltrc
for evaluation of model fit
Examples
#### 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")