bivrecSurv {BivRec} | R Documentation |
This function creates a bivariate recurrent survival object to be used as a response variable in a model formula.
bivrecSurv(id, episode, xij, yij, d1, d2)
id |
Numeric or character vector of subject's unique identifier (i). |
episode |
Vector indicating the observation or episode (j) for a subject (i). This will determine order of events for each subject. |
xij |
Vector with the lengths of time spent in event of Type I for individual i in episode j. |
yij |
Vector with the lengths of time spent in event of Type II for individual i in episode j. |
d1 |
Vector of censoring indicator corresponding to Type I gap times (xij): = 1 for uncensored, and = 0 for censored gap times. |
d2 |
Vector of censoring indicator corresponding to Type II gap times (yij): = 1 for uncensored, and = 0 for censored gap times. Note that in the last episode (or pair) of gap times, yij is always censored, i.e., d2 = 0. |
All the following data requirements must be met to avoid errors or warnings:
All variables should have the same length.
The Type I (xij) and Type II (yij) gap times must be numeric and meet the requirements xij>0, yij≥0 respectively for all observations.
Only unique, positive, consecutive integers starting from 1, are allowed within each subject for episode (i.e., 1, 2, ...), but they should be allowed to be in any order in the raw data as long as they are unique and have no gap within each subject.
Censoring indicators d1 and d2 must be numeric. Only the last episode is allowed to have zero value for either, and for the last episode, the only combinations allowed are (d1, d2) = (0, 0) or (1, 0).
No missing values. If a subject has missing values in any variables, the whole subject's data will not be used.
A bivrecSurv object ready to be used as the response for analysis using bivrecReg
or bivrecNP
.
library(BivRec) set.seed(28) sim_data <- simBivRec(nsize=100, beta1=c(0.5,0.5), beta2=c(0,-0.5)) bivrecsurv_data <- with(sim_data, bivrecSurv(id, epi, xij, yij, d1, d2)) class(bivrecsurv_data)