nn.time: Library of the Super Learner for Survival Neural Network

View source: R/nn.time.R

nn.timeR Documentation

Library of the Super Learner for Survival Neural Network

Description

Fit a 1-layer neural network based on the partial likelihood from a Cox proportional hazards model.

Usage

nn.time(times, failures, group, cov.quanti, cov.quali,
data, n.nodes, decay, batch.size, epochs)

Arguments

times

The name of the variable related the numeric vector with the follow-up times.

failures

The name of the variable related the numeric vector with the event indicators (0=right censored, 1=event).

group

The name of the variable related to the exposure/treatment. This variable shall have only two modalities encoded 0 for the untreated/unexposed patients and 1 for the treated/exposed ones. The default value is NULL: no specific exposure/treatment is considered. When a specific exposure/treatment is considered, it will be forced in the algorithm or related interactions will be tested when possible.

cov.quanti

The name(s) of the variable(s) related to the possible quantitative covariates. These variables must be numeric.

cov.quali

The name(s) of the variable(s) related to the possible qualitative covariates. These variables must be numeric with two levels: 0 and 1. A complete disjunctive form must be used for covariates with more levels.

data

A data frame for training the model in which to look for the variables related to the status of the follow-up time (times), the event (failures), the optional treatment/exposure (group) and the covariables included in the previous model (cov.quanti and cov.quali).

n.nodes

The number of hidden nodes.

decay

The value of the weight decay.

batch.size

The value of batch size.

epochs

The value of epochs.

Details

The survival neural network is obtained by using the deepsurv function from the survivalmodels package.

Value

model

The estimated model.

group

The name of the variable related to the exposure/treatment.

cov.quanti

The name(s) of the variable(s) related to the possible quantitative covariates.

cov.quali

The name(s) of the variable(s) related to the possible qualitative covariates.

data

The data frame used for learning. The first column is entitled times and corresponds to the observed follow-up times. The second column is entitled failures and corresponds to the event indicators. The other columns correspond to the predictors.

times

A vector of numeric values with the times of the predictions.

predictions

A matrix with the predictions of survivals of each subject (lines) for each observed times (columns).

Author(s)

Yohann Foucher <Yohann.Foucher@univ-poitiers.fr>

Camille Sabathe <camille.sabathe@univ-nantes.fr>

References

Katzman, J. L., Shaham, U., Cloninger, A., Bates, J., Jiang, T., & Kluger, Y. (2018). DeepSurv: personalized treatment recommender system using a Cox proportional hazards deep neural network. BMC Medical Research Methodology, 18(1), 24. https://doi.org/10.1186/s12874-018-0482-1

Examples


# On a linux machine

# Install Python 

# sudo apt install python3-pip

# Install Python Miniconda for CPU computaion on a linux machine

# Download the file from https://docs.conda.io/en/latest/miniconda.html#linux-installers

  # chmod +x Miniconda3-latest-Linux-x86_64.sh 
  # ./Miniconda3-latest-Linux-x86_64.sh 
  # conda create --name torch python=3.8
  # conda activate torch
  # conda install pytorch torchvision torchaudio cpuonly -c pytorch
  # conda install -c conda-forge pycox

# export PATH="/home/username/.local/bin:$PATH"

# remotes::install_github("RaphaelS1/survivalmodels")
# install_pycox(method = "auto",  conda = "auto",  pip = TRUE,  install_torch = TRUE )
# install_keras(method = "auto",  conda = "auto",  pip = TRUE,  install_tensorflow = TRUE)

# use_condaenv(condaenv = "~/miniconda3/envs/torch", conda = "auto", required = FALSE)

# data(dataDIVAT2)

# The estimation of the model from the first 500 individuals

# model<-nn.time(times="times", failures="failures", data=dataDIVAT2[1:500,],
#  cov.quanti=c("age"),  cov.quali=c("hla", "retransplant", "ecd"), n.nodes=5, decay=.01,
#                 batch.size=256L, epochs = 1L)
                 
# The predicted survival of the first subject of the training sample
# plot(y=model$predictions[1,], x=model$times, xlab="Time (years)", ylab="Predicted survival",
#     col=1, type="l", lty=1, lwd=2, ylim=c(0,1))


RISCA documentation built on March 31, 2023, 11:06 p.m.

Related to nn.time in RISCA...