cuIncCbnn | R Documentation |
This function calculates the cumulative incidence using a cbnn model.
cuIncCbnn(fit, times = times, x_test = x_test)
fit |
(list) output from fitHazard function. |
times |
(numeric) vector of time points at which you wish you calculate the cumulative incidence. |
x_test |
(matrix) matrix containing the data you wish to predict on. |
(matrix) a matrix representing the cumulative incidence of each individual.
library(cbnn)
library(casebase)
library(magrittr)
data<-casebase::ERSPC
data$ScrArm<-as.numeric(data$ScrArm)-1
eventVar<-"DeadOfPrCa"
timeVar<-"Follow.Up.Time"
features<-"ScrArm"
nnInput<-keras::layer_input(shape=length(features))
nnOutput<-nnInput %>% keras::layer_dense(units=1, use_bias = TRUE)
cbnnPrep<-prepCbnn(features, nnInput, nnOutput, data, offset=NA,timeVar,
eventVar, ratio=10, compRisk=FALSE)
fit<-fitHazard(cbnnPrep,epochs=1,batchSize=500)
times<-seq(min(data$Follow.Up.Time),max(data$Follow.Up.Time),length.out=10)
x_test<-as.matrix(data[sample(nrow(data),100),])
cumulativeIncidenceCurves<-cuIncCbnn(fit, times=times,x_test=x_test)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.