diff --git a/R/censored-package.R b/R/censored-package.R index 86c1b6d7..7e1829cd 100644 --- a/R/censored-package.R +++ b/R/censored-package.R @@ -58,7 +58,7 @@ NULL utils::globalVariables( c( - "time", ".time", "object", "new_data", ".label", ".pred", ".cuts", + "eval_time", ".time", "object", "new_data", ".label", ".pred", ".cuts", ".id", ".tmp", "engine", "predictor_indicators", ".strata", "group", ".pred_quantile", ".quantile", "interval", "level", ".pred_linear_pred", ".pred_link", ".pred_time", ".pred_survival", "next_event_time", diff --git a/R/proportional_hazards-data.R b/R/proportional_hazards-data.R index 0d433148..df6c9aa6 100644 --- a/R/proportional_hazards-data.R +++ b/R/proportional_hazards-data.R @@ -82,7 +82,7 @@ make_proportional_hazards_survival <- function() { list( x = quote(object$fit), new_data = quote(new_data), - time = rlang::expr(eval_time), + eval_time = rlang::expr(eval_time), output = "surv", interval = expr(interval), conf.int = expr(level) diff --git a/tests/testthat/test-partykit.R b/tests/testthat/test-partykit.R index 15540cfe..d909db55 100644 --- a/tests/testthat/test-partykit.R +++ b/tests/testthat/test-partykit.R @@ -16,22 +16,22 @@ test_that("survival_prob_partykit() works for ctree", { times = pred_time, extend = TRUE ) %>% - combine_list_of_survfit_summary(time = pred_time) + combine_list_of_survfit_summary(eval_time = pred_time) - prob <- survival_prob_partykit(mod, new_data = lung_pred, time = pred_time) %>% + prob <- survival_prob_partykit(mod, new_data = lung_pred, eval_time = pred_time) %>% tidyr::unnest(cols = .pred) exp_prob <- surv_fit_summary$surv expect_equal( - prob$.time, + prob$.eval_time, rep(pred_time, nrow(lung_pred)) ) expect_equal( - prob %>% dplyr::filter(is.infinite(.time)) %>% dplyr::pull(.pred_survival), + prob %>% dplyr::filter(is.infinite(.eval_time)) %>% dplyr::pull(.pred_survival), rep(c(1, 0), nrow(lung_pred)) ) expect_equal( - prob %>% dplyr::filter(is.finite(.time)) %>% dplyr::pull(.pred_survival), + prob %>% dplyr::filter(is.finite(.eval_time)) %>% dplyr::pull(.pred_survival), as.vector(exp_prob) ) @@ -44,25 +44,25 @@ test_that("survival_prob_partykit() works for ctree", { times = pred_time, extend = TRUE ) %>% - combine_list_of_survfit_summary(time = pred_time) + combine_list_of_survfit_summary(eval_time = pred_time) - prob <- survival_prob_partykit(mod, new_data = lung_pred, time = pred_time) %>% + prob <- survival_prob_partykit(mod, new_data = lung_pred, eval_time = pred_time) %>% tidyr::unnest(cols = .pred) exp_prob <- surv_fit_summary$surv expect_equal( - prob %>% dplyr::filter(is.infinite(.time)) %>% dplyr::pull(.pred_survival), + prob %>% dplyr::filter(is.infinite(.eval_time)) %>% dplyr::pull(.pred_survival), c(1, 0) ) expect_equal( - prob %>% dplyr::filter(is.finite(.time)) %>% dplyr::pull(.pred_survival), + prob %>% dplyr::filter(is.finite(.eval_time)) %>% dplyr::pull(.pred_survival), as.vector(exp_prob) ) # all observations with missings lung_pred <- lung[c(14, 14), ] - prob <- survival_prob_partykit(mod, new_data = lung_pred, time = pred_time) %>% + prob <- survival_prob_partykit(mod, new_data = lung_pred, eval_time = pred_time) %>% tidyr::unnest(cols = .pred) expect_true(all(!is.na(prob$.pred_survival))) @@ -87,23 +87,23 @@ test_that("survival_prob_partykit() works for cforest", { times = pred_time, extend = TRUE ) %>% - combine_list_of_survfit_summary(time = pred_time) + combine_list_of_survfit_summary(eval_time = pred_time) set.seed(1234) - prob <- survival_prob_partykit(mod, new_data = lung_pred, time = pred_time) %>% + prob <- survival_prob_partykit(mod, new_data = lung_pred, eval_time = pred_time) %>% tidyr::unnest(cols = .pred) exp_prob <- surv_fit_summary$surv expect_equal( - prob$.time, + prob$.eval_time, rep(pred_time, nrow(lung_pred)) ) expect_equal( - prob %>% dplyr::filter(is.infinite(.time)) %>% dplyr::pull(.pred_survival), + prob %>% dplyr::filter(is.infinite(.eval_time)) %>% dplyr::pull(.pred_survival), rep(c(1, 0), nrow(lung_pred)) ) expect_equal( - prob %>% dplyr::filter(is.finite(.time)) %>% dplyr::pull(.pred_survival), + prob %>% dplyr::filter(is.finite(.eval_time)) %>% dplyr::pull(.pred_survival), as.vector(exp_prob) ) @@ -117,26 +117,26 @@ test_that("survival_prob_partykit() works for cforest", { times = pred_time, extend = TRUE ) %>% - combine_list_of_survfit_summary(time = pred_time) + combine_list_of_survfit_summary(eval_time = pred_time) set.seed(1234) - prob <- survival_prob_partykit(mod, new_data = lung_pred, time = pred_time) %>% + prob <- survival_prob_partykit(mod, new_data = lung_pred, eval_time = pred_time) %>% tidyr::unnest(cols = .pred) exp_prob <- surv_fit_summary$surv expect_equal( - prob %>% dplyr::filter(is.infinite(.time)) %>% dplyr::pull(.pred_survival), + prob %>% dplyr::filter(is.infinite(.eval_time)) %>% dplyr::pull(.pred_survival), c(1, 0) ) expect_equal( - prob %>% dplyr::filter(is.finite(.time)) %>% dplyr::pull(.pred_survival), + prob %>% dplyr::filter(is.finite(.eval_time)) %>% dplyr::pull(.pred_survival), as.vector(exp_prob) ) # all observations with missings lung_pred <- lung[c(14, 14), ] - prob <- survival_prob_partykit(mod, new_data = lung_pred, time = pred_time) %>% + prob <- survival_prob_partykit(mod, new_data = lung_pred, eval_time = pred_time) %>% tidyr::unnest(cols = .pred) expect_true(all(!is.na(prob$.pred_survival))) diff --git a/tests/testthat/test-proportional_hazards-survival.R b/tests/testthat/test-proportional_hazards-survival.R index badf71eb..689a0a6b 100644 --- a/tests/testthat/test-proportional_hazards-survival.R +++ b/tests/testthat/test-proportional_hazards-survival.R @@ -529,7 +529,7 @@ test_that("predictions with strata and dot in formula", { { predict(f_fit, lung2, type = "time") predict(f_fit, lung2, type = "linear_pred") - predict(f_fit, lung2, type = "survival", time = c(100, 300)) + predict(f_fit, lung2, type = "survival", eval_time = c(100, 300)) }, NA ) @@ -542,8 +542,8 @@ test_that("predictions with strata and dot in formula", { predict(f_fit_2, lung2, type = "linear_pred") ) expect_equal( - predict(f_fit, lung2, type = "survival", time = c(100, 300)), - predict(f_fit_2, lung2, type = "survival", time = c(100, 300)) + predict(f_fit, lung2, type = "survival", eval_time = c(100, 300)), + predict(f_fit_2, lung2, type = "survival", eval_time = c(100, 300)) ) }) diff --git a/tests/testthat/test-survival_reg-survival.R b/tests/testthat/test-survival_reg-survival.R index 673910e7..3629cd20 100644 --- a/tests/testthat/test-survival_reg-survival.R +++ b/tests/testthat/test-survival_reg-survival.R @@ -191,7 +191,7 @@ test_that("`fix_xy()` works", { f_fit, new_data = lung_pred, type = "hazard", - time = c(100, 200) + eval_time = c(100, 200) ) xy_pred_hazard <- predict( xy_fit,