pistacliffcho / icenReg_devel

Code for icenReg plus testData
4 stars 0 forks source link

Non-graceful degradation with missing value in a covariate #9

Closed tamas-ferenci closed 4 years ago

tamas-ferenci commented 4 years ago

While I don't find it in the documentation, it seems ic_sp doesn't like NAs in covariates. But what is even more unfortunate is that instead of indicating this in an error message, it either prints the not-really-informative "Covar rows not equal to n!" error or prints nothing, and then crashes the whole R session.

Reproducible example:

library(icenReg)

set.seed(1)

sim_data <- simIC_weib(n = 100, inspections = 5, inspectLength = 1)
sim_data$x1[1] <- NA
ph_fit <- ic_sp(Surv(l, u, type = 'interval2') ~ x1 + x2, 
                data = sim_data)
pistacliffcho commented 4 years ago

Thanks Tamas! I'll add a catch for NA's.

tamas-ferenci commented 4 years ago

Thanks @pistacliffcho ! By the way, was my initial assumption correct, i.e., that icenReg can't handle missing values...?

pistacliffcho commented 4 years ago

That is correct.

In such cases, I'd suggest something like a multiple imputations approach, although to be I haven't looked into whether there are currently available R multiple imputations packages that can be used easily with icenReg to handle interval censoring.

tamas-ferenci commented 4 years ago

Thank you!

pistacliffcho commented 4 years ago

Fixed (v2.0.15): now throws an error if there are missing values in the covariate. Pushed to CRAN, should be available in a few days.