Solved – R neural network model with target vector as output containing survival predictions

machine learningneural networksrself-studysurvival

Overview

I want to simulate the survival prediction using neural networks described in this paper entitled "Application of Artificial Neural Network-Based Survival Analysis on Two Breast Cancer Datasets" by Chi, Street and Wolberg where a target vector of 1's representing time points are evaluated and returns a vector of the probabilities. Unfortunately they did not provide the software used to create the method.

For example, a dataset with time, status (indicating alive or dead) and other predictive variables are needed to be trained in a neural network. There will be a data structure to hold the time points the research needs (say a {1,1,1,1,1,1}, six-month intervals in three years). The output of this model, after taking into account the aforementioned predictive variables will look like this: {0.98761,0.91111,0.82710,0.70003,0.64253,0.47181} that corresponds to:

          6      12      18      24      30      36
1   0.98761 0.91111 0.82710 0.70003 0.64253 0.47181
2   ...

These data can be used for future records that will be fed into the network.


R neural network packages

I have been searching for ways to implement this in the nnet, neuralnet and rminer packages and unfortunately my limited knowledge can't modify them to suit my needs. I only know that these predict nominal and numeric values but now how to do vectors.

So far the functions relating to predicting in those packages do not give a hint on the usage of a vector as output.

  1. nnet's predict()'s description clearly states below.

    Predict new examples by a trained neural net.

    # X1, X2, and the rest of predictive variables
    model.nnet <- nnet(Surv(time,status)~X1+X2, data=data.train, size=1, maxit=500)
    
  2. neuralnet's compute() does not support a similar target vector for support.

    Computation of a given neural network for given covariate vectors.

  3. rminer's predict() and lforecast() prove to have potential (based from the examples) but I have no idea how to transform them into what I want to do.

  4. the survnnet package is said to support the common predictSurvProb function of the pec package but I stayed away from it because of the poor documentation and support here in the Internet.

    Predict new examples by a trained survival neural net.

    model.survnet <- survnnet(Surv(time,status)~X1+X2, data=dat,
        model='llog', decay=0.1, bias.decay=25, size=1,
        skip=T, alpha=0.1)  
    predictions   <- predict(model.survnet, data.train, type="raw")
    

Cox PH (current known method)

The closest method I've got so far was coxph and cph applied with the predictSurvProb function where a times variable is declared with the numeric points of interest.

Usually I do this:

data.train  <- SimSurv(300)
model.coxph <- cph(Surv(time,status)~X2,data=dat,surv=TRUE,x=TRUE,y=TRUE)

# declare target times as 25,50,75,100,150 for probabilities
predictions <- predictSurvProb(coxph12, newdata=data.train, times=c(25,50,75,100,150))
round(predictions, digits=6) 

and I would get an output of probabilities per time period I specified:

          25       50       75      100      150
1   0.648268 0.509353 0.460196 0.425917 0.324364
2   0.648268 0.509353 0.460196 0.425917 0.324364
3   0.756732 0.648020 0.607077 0.577596 0.484789
4   0.648268 0.509353 0.460196 0.425917 0.324364
5   0.648268 0.509353 0.460196 0.425917 0.324364

These are now ready to be integrated as new variables into the dataset for other purposes.


I now want to implement this in a neural network with the target vector or a similar implementation to the Cox PH process like the example above.

Unfortunately I can not find a straightforward package or tutorial online that states if this is possible to do, as I said before.

I checked into the data mining software WEKA's MultilayerPerceptron implementation but it requires that the outcome variable (or in my case a vector of probabilities) to be existing first, which takes me back here into R.

Is this method possible in these R packages or the only way is to create my own? All help and suggestions would be greatly appreciated.

Best Answer

Why not just put binary indicator for event as a target variable and length of time period as a explanatory variable (plus other covariates)? If event happens then target is 1 and time period is calculated as time until event happens - start time. For some observations where target is 0 this time period is 36, if measured in months. For some observations where target is 1 it can be much less.

Can there be panel attrition where some observation is removed from the data set before whole surveillance period is over? That must be accounted somehow.

To get individual survival probabilities for various time intervals you score new data set with just developed model object i times where i number of different time periods and particular time period has value n. Then just concatenate i vectors containing time period specific probabilities.

Idea is that measured time period with other covariates accounts for the survival probability conditional on length of time in the observational study.

EDIT:

I looked for R package neuralnet. You can have individual time period specific survival events in the target matrix in the following way. C1 is covariate1, T1 is vector of survival events in the time period 1 etc. Your data frame / matrix could look like this:

ID T1 T2 T3 T4 T5 T6 C1 C2 C3 CN  
1 1 1 1 1 1 1 X11 X12 X13 X1N  
2 1 0 0 0 0 0 X21 X22 X23 X2N  
..  

Use following code:

survexample=neuralnet(T1+T2+T3+T4+T5+T6~C1+C2+...+CN,data=example,hidden=n,err.fct="ce",linear.output=FALSE)  

This example code does classifying and forces output vector values to be in the range of [0,1].