nn.time | R Documentation |
Fit a 1-layer neural network based on the partial likelihood from a Cox proportional hazards model.
nn.time(times, failures, group, cov.quanti, cov.quali,
data, n.nodes, decay, batch.size, epochs)
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 ( |
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. |
The survival neural network is obtained by using the deepsurv
function from the survivalmodels
package.
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 |
A vector of numeric values with the times of the |
predictions |
A matrix with the predictions of survivals of each subject (lines) for each observed times (columns). |
Yohann Foucher <Yohann.Foucher@univ-poitiers.fr>
Camille Sabathe <camille.sabathe@univ-nantes.fr>
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
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.