Skip to content

sometimes censoring weight columns have names #1023

Closed
@topepo

Description

@topepo

Discovered in tidymodels/extratests#120

Only when a single row is predicted at a single time:

library(tidymodels)
library(censored)
#> Loading required package: survival
tidymodels_prefer()
theme_set(theme_bw())
options(pillar.advice = FALSE, pillar.min_title_chars = Inf)
set.seed(1)
sim_dat <- prodlim::SimSurv(500) %>%
  mutate(event_time = Surv(time, event)) %>%
  select(event_time, X1, X2)

parsnip_fit <- 
  proportional_hazards() %>% 
  fit(event_time ~ ., sim_dat)

## 

times <- c(2.0, 1.0)

##

res_2_times_2_rows <- 
  augment(parsnip_fit, new_data = head(sim_dat, 2), eval_time = times)
names(res_2_times_2_rows$.pred[[1]]$.weight_censored)
#> NULL

res_2_time_1_row <- 
  augment(parsnip_fit, new_data = head(sim_dat, 1), eval_time = times)
names(res_2_time_1_row$.pred[[1]]$.weight_censored)
#> NULL

res_1_time_2_row <- 
  augment(parsnip_fit, new_data = head(sim_dat, 2), eval_time = times[1])
names(res_1_time_2_row$.pred[[1]]$.weight_censored)
#> NULL

res_1_time_1_row <- 
  augment(parsnip_fit, new_data = head(sim_dat, 1), eval_time = times[1])
names(res_1_time_1_row$.pred[[1]]$.weight_censored)
#> [1] "time"

Created on 2023-11-09 with reprex v2.0.2

Metadata

Metadata

Assignees

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