surv_split: Split time to interval for survival model - improved

View source: R/Utils.R

surv_splitR Documentation

Split time to interval for survival model - improved

Description

This is similar to survSplit but allow the starting time and ending time to be equal (e.g., immediate death, automatic default in loan) and automatically include min and max of duration in the cut intervals

Usage

surv_split(
  x,
  duration,
  event,
  cuts,
  time_varying = NULL,
  label_episode = FALSE
)

Arguments

x

data frame

duration

exposure time

event

binary 0 and 1 coded

time_varying

not in use

label_episode

set to TRUE to have the episode labeled with actual cut intervals, otherwise episodes are integers

cut

the cut points on duration forming intervals [min_duration, first_value], (first_value, second_value], ..., (last_value, max_duration]

Details

The tested speed is 1.37 times to that of survSplit.

Examples

x <- data.frame(time = c(5, 10), event = c(1, 0))
surv_split(x, "time", "event", c(2,4,6))
surv_split(x, "time", "event", c(2,4,6), label_episode = TRUE)

kklot/ktools documentation built on Aug. 13, 2024, 7:08 p.m.