censored
A tidymodels package for survival models - Hannah Frick
Photo by Lavi Perchik on Unsplash
Photo by sami salim on Unsplash
Photo by Nikolay Loubet on Unsplash
For censored data,
i.e., data with two aspects
use survival analysis
to take both aspects into account!
Photo by Waldemar Brandt on Unsplash
We’re extending support for
survival analysis in tidymodels
Consistency in
Consistency in
Photo by Linus Nylund on Unsplash
proportional_hazards()
"censored regression"
Adapted from Tidy Tuesday 2018-38:
cetaceans
#> # A tibble: 1,313 × 6
#> age event species sex transfers born_in_captivity
#> <dbl> <dbl> <fct> <fct> <int> <lgl>
#> 1 28 0 Bottlenose F 0 TRUE
#> 2 44 0 Bottlenose F 0 TRUE
#> 3 39 0 Bottlenose M 13 TRUE
#> 4 38 0 Bottlenose F 1 TRUE
#> 5 38 0 Bottlenose M 2 TRUE
#> 6 37 0 Bottlenose F 2 TRUE
#> 7 36 0 Bottlenose M 2 TRUE
#> 8 36 0 Bottlenose F 2 TRUE
#> 9 35 0 Bottlenose M 3 TRUE
#> 10 34 0 Bottlenose F 4 TRUE
#> # … with 1,303 more rows
Photo by Ádám Berkecz on Unsplash
All for the mode "censored regression"
.
model | engine |
---|---|
bag_tree() |
rpart |
boost_tree() |
mboost |
decision_tree() |
rpart |
decision_tree() |
partykit |
proportional_hazards() |
survival |
proportional_hazards() |
glmnet |
rand_forest() |
partykit |
survival_reg() |
survival |
survival_reg() |
flexsurv |
Photo by Linus Nylund on Unsplash
new_data
and the output are the same.predict(
mod_mboost_censored,
new_data = cetaceans[2:3,],
type = "survival",
time = 1:80
) %>%
mutate(id = factor(2:3)) %>%
tidyr::unnest(cols = .pred)
#> # A tibble: 160 × 3
#> .time .pred_survival id
#> <int> <dbl> <fct>
#> 1 1 1 2
#> 2 2 0.981 2
#> 3 3 0.957 2
#> 4 4 0.932 2
#> 5 5 0.901 2
#> 6 6 0.869 2
#> 7 7 0.843 2
#> 8 8 0.802 2
#> 9 9 0.776 2
#> 10 10 0.752 2
#> # … with 150 more rows
"time"
and "survival"
"hazard"
, "quantile"
, "linear_pred"