The function dataprep reshapes data from a long format to a ready-to-use format to be used directly in the function ciregic.
dataprep(data, ID, time, event, Z)
Arguments
data: a data frame that includes the variables named in the ID, time, event, and z arguments
ID: a variable indicating individuals' ID
time: a variable indicating observed time points
event: a vector of event indicator. If an observation is righ-censored, event = 0; otherwise, event = 1 or event = 2, where 1 represents the first cause of failure, and 2 represents the second cause of failure. The current version of package only allows two causes of failure.
Z: a vector of variables indicating name of covariates
Returns
a data frame
Details
The function dataprep provides a ready-to-use data format that can be directly used in the function ciregic. The returned data frame consists of id, v, u, c, and covariates as columns. The v and u indicate time window with the last observation time before the event and the first observation after the event. The c represents a type of event, for example, c = 1 for the first cause of failure, c = 2 for the second cause of failure, and c = 0 for the right-censored. For individuals having one time record with the event, the lower bound v will be replaced by zero, for example (0, v]. For individuals having one time record without the event, the upper bound u will be replaced by Inf, for example (v, Inf].
Examples
library(intccr)dataprep(data = longdata, ID = id, time = t, event = c, Z = c(z1, z2))