LTRCforests (version 0.5.5)

predictProb: 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

an object as returned by ltrccif or by ltrcrrf.

newdata

an optional data frame containing the test data (with the names of the variables the same as those in data from object).

newdata.id

optional variable name of subject identifiers for newdata. If this is present, it will be searched for in the newdata data frame. Each group of rows in newdata with the same subject id represents the covariate path through time of a single subject, and the result will contain one curve per subject. If it is not specified, then an estimated survival curve is returned for each row of newdata.

OOB

a logical specifying whether out-of-bag predictions are desired

(only if newdata = NULL).

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 time.eval[time.eval <= time.tau[i]] for the i-th data of interest). If OOB = TRUE, the length of time.tau is equal to the size of data used to train the object; If OOB = FALSE, the length of time.tau is equal to the size of newdata, or equal to the size of data if newdata is not given. The default NULL is simply to set all entries of time.tau equal to the maximum value of time.eval, so that all estimated survival probabilities are computed at the same time.eval.

Value

A list containing:

survival.id

subject identifiers.

survival.obj

an object of class Surv.

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 time.tau.

survival.times

the input value time.eval.

See Also

sbrier_ltrc for evaluation of model fit

Examples

Run this code
# 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