MSKCC-Epi-Bio/tidycmprsk

Singular fit in crr with unused factor level

erikvona opened this issue · 1 comments

If I run crr, and one of my covariates has a level that does not occur in the data, I get an error that the system is exactly singular:

library(tidycmprsk)

trial$trt <- factor(trial$trt, levels = paste("Drug", c("A", "B", "C")))

crr_mod <- crr(Surv(ttdeath, death_cr) ~ age + trt, trial)
#> 11 cases omitted due to missing values
#> Error in solve.default(h, z[[2]]): Lapack routine dgesv: system is exactly singular: U[3,3] = 0

Created on 2022-08-11 by the reprex package (v2.0.1)

The expected behavior for me would be to ignore the unused level (e.g. run the covariates through a droplevels), or to generate a descriptive error message by testing for this scenario. I wasted quite some time trying to understand why I was getting a singular system in a nonfictive scenario, after I subsetted the data to exclude some patients.

P.s. Thanks for the excellent package! Makes competing risk analysis quite a lot easier to perform and especially to teach.

Thank you for the report! We'll address in the next release 🕺🏼