Skip to content

as_ped with CR cuts off times after the last event where status == 1L if using tdcs #221

Description

@jonas-schropp

If I try to use as_ped to build my competing risks data set with time dependent covariates, the follow up time is cut short at the last event time where status == 1L and any events for status > 1L (as well as censoring after that time, status == 0L) are ignored.

Example:

dat <- data.frame(
  id = factor(1:10),
  status = c(0L, 1L, 2L, 0L, 1L, 2L, 1L, 0L, 0L, 2L),
  time = seq(from = 10, to = 100, by = 10)
)

tdcs <- data.frame(
  id = factor(c(1:10, 1:10)),
  var = rbinom(20, 1, 0.3),
  tt = c(rep(0, 10), seq(5, 23, 2))
)


ped_dat <- as_ped(
  data = list(dat, tdcs),
  formula = Surv(time, status) ~ concurrent(var, tz_var = "tt"), 
  id = "id"
)

max(ped_dat$tend)

Returns [1] 70 when it should return 100.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions