Skip to content

Commit 9afb8b4

Browse files
authored
remove .time_as_binary_event() (#980)
* remove `.time_as_binary_event()` until we have a better understanding of the use cases to inform how we deal with not-well-defined evaluation times * update NEWS
1 parent 7f05f42 commit 9afb8b4

File tree

6 files changed

+5
-88
lines changed

6 files changed

+5
-88
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ export(.model_param_name_key)
165165
export(.obs)
166166
export(.organize_glmnet_pred)
167167
export(.preds)
168-
export(.time_as_binary_event)
169168
export(.x)
170169
export(.y)
171170
export(C5.0_train)

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
* For BART models with the `dbarts` engine, `predict()` can now also return the standard error for confidence and prediction intervals (#976).
88

9-
* A few censored regression helper functions were exported: `.extract_surv_status()`, `.extract_surv_time()`, and `.time_as_binary_event()` (#973).
9+
* A few censored regression helper functions were exported: `.extract_surv_status()` and `.extract_surv_time()` (#973, #980).
1010

1111
* Fixed bug where prediction on rank dificient `lm()` models produced `.pred_res` instead of `.pred`. (#985)
1212

R/standalone-survival.R

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ---
22
# repo: tidymodels/parsnip
33
# file: standalone-survival.R
4-
# last-updated: 2023-05-18
4+
# last-updated: 2023-06-14
55
# license: https://unlicense.org
66
# ---
77

@@ -14,6 +14,9 @@
1414
#
1515
# 2023-05-18
1616
# * added time to factor conversion
17+
#
18+
# 2023-06-14
19+
# * removed time to factor conversion
1720

1821
# @param surv A [survival::Surv()] object
1922
# @details
@@ -22,15 +25,11 @@
2225
#
2326
# `.extract_status()` will return the data as 0/1 even if the original object
2427
# used the legacy encoding of 1/2. See [survival::Surv()].
25-
#
26-
# `.time_as_binary_event()` takes a Surv object and converts it to a binary
27-
# outcome (if possible).
2828

2929
# @return
3030
# - `.extract_surv_status()` returns a vector.
3131
# - `.extract_surv_time()` returns a vector when the type is `"right"` or `"left"`
3232
# and a tibble otherwise.
33-
# - `.time_as_binary_event()` returns a two-level factor.
3433
# - Functions starting with `.is_` or `.check_` return logicals although the
3534
# latter will fail when `FALSE`.
3635

@@ -91,25 +90,4 @@
9190
}
9291
res
9392
}
94-
95-
.time_as_binary_event <- function(surv, eval_time) {
96-
eval_time <- eval_time[!is.na(eval_time)]
97-
eval_time <- eval_time[eval_time >= 0 & is.finite(eval_time)]
98-
eval_time <- unique(eval_time)
99-
if (length(eval_time) != 1 || !is.numeric(eval_time)) {
100-
stop("'eval_time' should be a single, complete, finite numeric value.")
101-
}
102-
103-
event_time <- .extract_surv_time(surv)
104-
status <- .extract_surv_status(surv)
105-
is_event_before_t <- event_time <= eval_time & status == 1
106-
# Three possible contributions to the statistic from Graf 1999
107-
# Censoring time before eval_time, no contribution (Graf category 3)
108-
binary_res <- rep(NA_character_, length(event_time))
109-
# A real event prior to eval_time (Graf category 1)
110-
binary_res <- ifelse(is_event_before_t, "event", binary_res)
111-
# Observed time greater than eval_time (Graf category 2)
112-
binary_res <- ifelse(event_time > eval_time, "non-event", binary_res)
113-
factor(binary_res, levels = c("event", "non-event"))
114-
}
11593
# nocov end

R/survival-helpers.R

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,3 @@ assign(".extract_surv_time", surv_ns[[".extract_surv_time"]])
2424
#' @return A numeric vector.
2525
#' @export
2626
assign(".extract_surv_status", surv_ns[[".extract_surv_status"]])
27-
28-
#' Convert survival objects to binary factors
29-
#'
30-
#' For a given evaluation time, convert a [survival::Surv()] object to a binary
31-
#' factor with levels `"event"` and `"non-event"`.
32-
#'
33-
#' @name .time_as_binary_event
34-
#' @param surv A single [survival::Surv()] object.
35-
#' @param eval_time A single numeric value for the evaluation time.
36-
#' @return A two level factor.
37-
#' @details
38-
#' The following three cases can occur:
39-
#' - **Events**: Evaluation time is greater than or equal to the event time
40-
#' ("it has already happened").
41-
#' - **Non-events**: Evaluation time is less than the observed time, censored
42-
#' or not ("nothing has happened yet").
43-
#' - **Ambiguous outcomes**: Evaluation time is greater than or equal to the
44-
#' observed censored time ("we don't know if anything might have happened by now").
45-
#' A missing value is returned for these observations.
46-
#'
47-
#' @references Graf, E., Schmoor, C., Sauerbrei, W., and Schumacher, M. (1999).
48-
#' "Assessment and Comparison of Prognostic Classification Schemes for Survival Data."
49-
#' _Statistics in Medicine_, 18, 2529-2545.
50-
#' @export
51-
assign(".time_as_binary_event", surv_ns[[".time_as_binary_event"]])

_pkgdown.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,3 @@ reference:
107107
- .extract_surv_status
108108
- .extract_surv_time
109109
- .model_param_name_key
110-
- .time_as_binary_event

man/dot-time_as_binary_event.Rd

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)