Probability of survival at specific points in time using randomForestSRC

I use rfsrc to simulate a survival problem, for example:

 library(OIsurv) library(survival) library(randomForestSRC) data(burn) attach(burn) library(randomForestSRC) fit <- rfsrc(Surv(T1, D1) ~ ., data=burn) # predict on the train set pred <- predict(fit, burn, OOB=TRUE, type=response) pred$predicted 

this gives me an overall survival probability for all patients.

How can I get the probability of survival for each person at different points in time, say, 0-5 months or 0-10 months?

+6
source share
1 answer

The documentation on this subject is not immediately obvious if you are not familiar with the package, but it is possible.

Data loading

 data(pbc, package = "randomForestSRC") 

Create trial and test data sets

 pbc.trial <- pbc %>% filter(!is.na(treatment)) pbc.test <- pbc %>% filter(is.na(treatment)) 

Build our model

 rfsrc_pbc <- rfsrc(Surv(days, status) ~ ., data = pbc.trial, na.action = "na.impute") 

Testing model

 test.pred.rfsrc <- predict(rfsrc_pbc, pbc.test, na.action="na.impute") 

All good things are stored in our forecasting facility. The $survival object is a matrix of n rows (one for one patient) and n columns (one for time.interest ) - they are automatically selected, although you can restrict them to using the ntime argument. Our matrix is ​​106x122)

 test.pred.rfsrc$survival 

The $time.interest is a list of different "time.interests" (122, the same as the number of columns in our matrix from $surival )

 test.pred.rfsrc$time.interest 

Let's say we wanted to see our predicted status in 5 years, we would like to find out what time the interest was closest to 1825 days (since our measurement period is days), when we look at our $time.interest object, we see that line 83 = 1827 days or about 5 years. row 83 in $time.interest matches column 83 in our $survival matrix. Thus, to see the predicted probability of survival at 5 years, we just look at column 83 of our matrix.

 test.pred.rfsrc$survival[,83] 

Then you can do this depending on what you are interested in.

+6
source

All Articles