dnnsurv: DNNSurv Neural Network for Conditional Survival Probabilities

View source: R/dnnsurv.R

dnnsurvR Documentation

DNNSurv Neural Network for Conditional Survival Probabilities

Description

DNNSurv neural fits a neural network based on pseudo-conditional survival probabilities.

Usage

dnnsurv(
  formula = NULL,
  data = NULL,
  reverse = FALSE,
  time_variable = "time",
  status_variable = "status",
  x = NULL,
  y = NULL,
  cutpoints = NULL,
  cuts = 5L,
  custom_model = NULL,
  loss_weights = NULL,
  weighted_metrics = NULL,
  optimizer = "adam",
  early_stopping = FALSE,
  min_delta = 0,
  patience = 0L,
  verbose = 0L,
  baseline = NULL,
  restore_best_weights = FALSE,
  batch_size = 32L,
  epochs = 10L,
  validation_split = 0,
  shuffle = TRUE,
  sample_weight = NULL,
  initial_epoch = 0L,
  steps_per_epoch = NULL,
  validation_steps = NULL,
  ...
)

Arguments

formula

(formula(1))
Object specifying the model fit, left-hand-side of formula should describe a survival::Surv() object.

data

(data.frame(1))
Training data of data.frame like object, internally is coerced with stats::model.matrix().

reverse

(logical(1))
If TRUE fits estimator on censoring distribution, otherwise (default) survival distribution.

time_variable

(character(1))
Alternative method to call the function. Name of the 'time' variable, required if formula. or x and Y not given.

status_variable

(character(1))
Alternative method to call the function. Name of the 'status' variable, required if formula or x and Y not given.

x

(data.frame(1))
Alternative method to call the function. Required if formula, time_variable and status_variable not given. Data frame like object of features which is internally coerced with model.matrix.

y

([survival::Surv()])
Alternative method to call the function. Required if formula, time_variable and status_variable not given. Survival outcome of right-censored observations.

cutpoints

(numeric())
Points at which to cut survival time into discrete points.

cuts

(integer(1))
If cutpoints not provided then number of equally spaced points at which to cut survival time.

custom_model

(keras.engine.training.Model(1))
Optional custom architecture built with build_keras_net or directly with keras. Output layer should be of length 1 input is number of features plus number of cuts.

loss_weights, weighted_metrics

See keras::compile.keras.engine.training.Model.

optimizer

(character(1))
See get_keras_optimizer.

early_stopping

(logical(1))
If TRUE then early stopping callback is included.

min_delta, patience, baseline, restore_best_weights

See keras::callback_early_stopping.

verbose

(integer(1))
Level of verbosity for printing, 0 or 1.

batch_size, epochs, validation_split, shuffle, sample_weight, initial_epoch, steps_per_epoch, validation_steps

See keras::fit.keras.engine.training.Model. # nolint

...

ANY
Passed to get_keras_optimizer.

Details

Code for generating the conditional probabilities and pre-processing data is taken from https://github.com/lilizhaoUM/DNNSurv.

Value

An object of class survivalmodel.

References

Zhao, L., & Feng, D. (2020). DNNSurv: Deep Neural Networks for Survival Analysis Using Pseudo Values. https://arxiv.org/abs/1908.02337

Examples


if (requireNamespaces(c("keras", "pseudo")))
  # all defaults
  dnnsurv(data = simsurvdata(10))

  # setting common parameters
  dnnsurv(time_variable = "time", status_variable = "status", data = simsurvdata(10),
          early_stopping = TRUE, epochs = 100L, validation_split = 0.3)

  # custom model
  library(keras)
  cuts <- 10
  df <- simsurvdata(50)
  # shape = features + cuts
  input <- layer_input(shape = c(3L + cuts), name = 'input')
  output <- input %>%
     layer_dense(units = 4L, use_bias = TRUE) %>%
     layer_dense(units = 1L, use_bias = TRUE ) %>%
     layer_activation(activation="sigmoid")

  model <- keras_model(input, output)
  class(model)

  dnnsurv(custom_model = model, time_variable = "time",
          status_variable = "status", data = df, cuts = cuts)




survivalmodels documentation built on March 24, 2022, 9:05 a.m.