wilsoncai1992 / MOSS

(Model One-Step Survival): one-step TMLE for survival curve
https://wilsoncai1992.github.io/MOSS/
BSD 3-Clause "New" or "Revised" License
5 stars 6 forks source link

hazard_to_survival() error #12

Open rachaelvp opened 4 years ago

rachaelvp commented 4 years ago

Hi Wilson,

I get the following error when calling hazard_to_survival():

Error in self$survival[i, ] <- cumprod(1 - hazard_here) : number of items to replace is not a multiple of replacement length

This may be because I am setting t_max lower than max(T_tilde)?

I included the R code below that's generating the error.

library(MOSS) vet_data <- read.csv("https://raw.githubusercontent.com/tlverse/deming2019-workshop/master/data/veteran.csv") head(vet_data)

T_tilde <- vet_data$time Delta <- vet_data$status A <- vet_data$trt W <- vet_data[, c(3, 6:9)] t_max <- 200

SL.ranger.faster = function(...) { SL.ranger(..., num.trees = 50) } sl_lib_decent <- c("SL.mean", "SL.glm", "SL.step.forward", "SL.bayesglm", "SL.ranger.faster", "SL.gam") initial_fit <- initial_sl_fit(T_tilde, Delta, A, W, t_max, sl_censoring = sl_lib_decent, sl_failure = sl_lib_decent)

initial_fit$density_failure_1$hazard_to_survival() initial_fit$density_failure_0$hazard_to_survival()

wilsoncai1992 commented 4 years ago

Thanks for the catch! Let me take a look at this