dataprep {intccr} | R Documentation |
Data manipulation
Description
The function dataprep
reshapes data from a long format to a ready-to-use format to be used directly in the function ciregic
.
Usage
dataprep(data, ID, time, event, Z)
Arguments
data |
a data frame that includes the variables named in the |
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, |
Z |
a vector of variables indicating name of covariates |
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]
.
Value
a data frame
Author(s)
Jun Park, jun.park@alumni.iu.edu
Giorgos Bakoyannis, gbakogia@iu.edu
Examples
library(intccr)
dataprep(data = longdata, ID = id, time = t, event = c, Z = c(z1, z2))