Survival probability function for survreg models

Share:

Description

Function for predicting survival probability as a function of time for survreg regression objects in survival package. It can be used to mix survreg models with other survival models in competing-risk analysis, using CFC package. This function is used inside cfc.survreg.

Usage

1

Arguments

t

Time from index. Must be non-negative, but can be a vector.

args

Regression object that is returned by survreg. If using newdata for prediction, the x field of this object must be updated accordingly.

n

Observation index, must be between 1 and nrow(args$x).

Value

Vector of survival probabilities at time(s) t.

Author(s)

Mansour T.A. Sharabiani, Alireza S. Mahani

See Also

cfc.survreg

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## Not run: 
library("CFC") # for cfc
data(bmt)
library("randomForestSRC") # for rfsrc
library("survival") # for survreg

prep <- cfc.prepdata(Surv(time, cause) ~ platelet + age + tcell, bmt)
f1 <- prep$formula.list[[1]]
f2 <- prep$formula.list[[2]]
dat <- prep$dat
tmax <- prep$tmax

# building a parametric Weibull regression model
# for cause 1
reg1 <- survreg(f1, dat, x = TRUE) # must keep x for prediction

# building a random forest survival model for cause 2
reg2 <- rfsrc(f2, dat)
# implementing a continuous interface for the random forest
# survival function
rfsrc.survfunc <- function(t, args, n) {
  which.zero <- which(t < .Machine$double.eps)
  ret <- approx(args$time.interest, args$survival[n, ], t, rule = 2)$y
  ret[which.zero] <- 1.0
  return (ret)
}

# constructing function and argument list
f.list <- list(cfc.survreg.survprob, rfsrc.survfunc)
arg.list <- list(reg1, reg2)

# competing-risk analysis
tout <- seq(0.0, tmax, length.out = 10)
# increase rel.tol for higher accuracy
cfc.out <- cfc(f.list, arg.list, nrow(bmt), tout, rel.tol = 1e-3)


## End(Not run)