polish {msmtools} | R Documentation |
Remove observations with different states occurring at the same time
Description
Fast algorithm to get rid of transitions to different states occurring at
the same exact time in an augmented data structure as computed by
augment
(see 'Details').
Usage
polish(
data,
data_key,
pattern,
time,
check_NA = FALSE,
convert = FALSE,
verbose = TRUE
)
Arguments
data |
A |
data_key |
A keying variable which |
pattern |
Either an integer, a factor or a character with 2 or 3 unique
values which provides the ID status at the end of the study. |
time |
The target time variable to check duplicates. By default it is set to 'augmented_int'. |
check_NA |
If |
convert |
If |
verbose |
If |
Details
The function finds all those cases where two subsequent events for
a given subject land on different states but occur at the same time.
When this happens, the whole subject, as identified by data_key
, is
removed from the data. The total number of subjects to be removed is
printed out in order to be more informative.
Author(s)
Francesco Grossetti francesco.grossetti@unibocconi.it.
See Also
Examples
# loading data
data( hosp )
# augmenting longitudinal data
hosp_aug = augment( data = hosp, data_key = subj, n_events = adm_number,
pattern = label_3, t_start = dateIN, t_end = dateOUT,
t_cens = dateCENS )
# cleaning any targeted occurrence
hosp_aug_clean = polish( data = hosp_aug, data_key = subj, pattern = label_3 )