Skip to content

check_censor_model() should error for models without mode "censored regression" #971

Closed
@hfrick

Description

@hfrick

.censoring_weights_graf.model_fit() checks the model fit via .check_censor_model() and since censoring weights only make sense for models with mode "censored regression", the check function should error for models with a different mode.

library(parsnip)
library(survival)

lung2 <- lung %>%
  dplyr::mutate(surv = Surv(time, status), .keep = "unused")

not_a_censor_model <- fit(linear_reg(), mpg ~ ., data = mtcars)

# this should error
parsnip:::.check_censor_model(not_a_censor_model)

# because it's used in and this now gives a different error
.censoring_weights_graf(not_a_censor_model, lung2)
#> Error:
#> ! The input should have a list column called `.pred`.
#> Backtrace:
#>     ▆
#>  1. ├─parsnip::.censoring_weights_graf(not_a_censor_model, lung2)
#>  2. └─parsnip:::.censoring_weights_graf.model_fit(...) at parsnip/R/survival-censoring-weights.R:188:2
#>  3.   └─parsnip:::.check_pred_col(predictions) at parsnip/R/survival-censoring-weights.R:223:2
#>  4.     └─rlang::abort(...) at parsnip/R/survival-censoring-weights.R:48:4

Created on 2023-05-17 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions