Closed
Description
Looking at unit tests for using augment()
on workflows for survival models and testing that it properly fails when eval_time
is unspecified (see #200). We should get this error:
! The
eval_time
argument is missing, with no default.
When using the glmnet model, a glmnet-related error is triggered instead of the one for an improper argument call. This doesn't happen when just parsnip is used, so it is most likely a workflows issue.
library(tidymodels)
library(censored)
#> Loading required package: survival
set.seed(1)
sim_dat <- prodlim::SimSurv(500) %>%
mutate(event_time = Surv(time, event)) %>%
select(event_time, X1, X2)
workflow() %>%
add_model(proportional_hazards()) %>%
add_formula(event_time ~ .) %>%
fit(data = sim_dat) %>%
augment(new_data = sim_dat)
#> Error in `augment()`:
#> ! The `eval_time` argument is missing, with no default.
#> Backtrace:
#> ▆
#> 1. ├─... %>% augment(new_data = sim_dat)
#> 2. ├─generics::augment(., new_data = sim_dat)
#> 3. └─workflows:::augment.workflow(., new_data = sim_dat)
#> 4. ├─generics::augment(...)
#> 5. └─parsnip:::augment.model_fit(fit, new_data_forged, eval_time = eval_time, ...)
#> 6. └─parsnip:::augment_censored(x, new_data, eval_time = eval_time)
#> 7. └─rlang::abort(...)
workflow() %>%
add_model(proportional_hazards(penalty = 0.001) %>% set_engine("glmnet")) %>%
add_formula(event_time ~ .) %>%
fit(data = sim_dat) %>%
augment(new_data = sim_dat)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting
#> a method for function 'as.matrix': Cholmod error 'X and/or Y have wrong
#> dimensions' at file ../MatrixOps/cholmod_sdmult.c, line 88
# Same error with parnsip
proportional_hazards() %>%
fit(event_time ~ ., data = sim_dat) %>%
augment(new_data = sim_dat)
#> Error in `augment()`:
#> ! The `eval_time` argument is missing, with no default.
#> Backtrace:
#> ▆
#> 1. ├─... %>% augment(new_data = sim_dat)
#> 2. ├─generics::augment(., new_data = sim_dat)
#> 3. └─parsnip:::augment.model_fit(., new_data = sim_dat)
#> 4. └─parsnip:::augment_censored(x, new_data, eval_time = eval_time)
#> 5. └─rlang::abort(...)
proportional_hazards(penalty = 0.001) %>%
set_engine("glmnet") %>%
fit(event_time ~ ., data = sim_dat) %>%
augment(new_data = sim_dat)
#> Error in `augment()`:
#> ! The `eval_time` argument is missing, with no default.
#> Backtrace:
#> ▆
#> 1. ├─... %>% augment(new_data = sim_dat)
#> 2. ├─generics::augment(., new_data = sim_dat)
#> 3. └─parsnip:::augment.model_fit(., new_data = sim_dat)
#> 4. └─parsnip:::augment_censored(x, new_data, eval_time = eval_time)
#> 5. └─rlang::abort(...)
Created on 2023-11-09 with reprex v2.0.2