Skip to contents

Builds the (entry, stop] pieces that model_survival(entry =, subject =) reads from two tables: one row per subject with the end of its follow-up, the event indicator and the covariates at the start, and one row per CHANGE of a time-dependent covariate, with the time it happens and the new values. Each subject is cut at its change times; every piece carries the covariate values in force during it, the subject's time-fixed columns, and the event only on the last piece (a piece that ends before the end of the follow-up is right-censored by construction). Changes at or after the end of the follow-up change nothing and are dropped, with the count in the attribute "dropped_changes".

Usage

survival_split(
  subjects,
  changes,
  id = "id",
  time = "time",
  event = "event",
  at = "at"
)

Arguments

subjects

data.frame, one row per subject: id, time (end of follow-up), event (1 failure, 0 censored), the starting values of every time-dependent covariate named in changes, and any time-fixed column. event follows the rule of censor= in model_survival(): a factor or text event is read by its labels ("0" and "1", or "TRUE" and "FALSE"), never by the codes 1, 2, ... of the factor, and any other label is refused; the output carries it as the number 0 or 1. time is numeric: a factor or text time is refused, naming the column

changes

data.frame: id, at (the time of the change, > 0, numeric like time) and the new values of one or more time-dependent covariates (columns also present in subjects)

id, time, event, at

column names

Value

data.frame of elementary records: the subject columns, with entry added, time holding the end of each piece and event its indicator, ordered by subject and entry. Fit it with model_survival(time ~ ..., censor = "event", entry = "entry", subject = "id").