episodes | R Documentation |
Dated events (records) within a certain duration of an index event are assigned to a unique group.
Each group has unique ID and are described as "episodes"
.
"episodes"
can be "fixed"
or "rolling"
("recurring"
).
Each episodes has a "Case"
and/or "Recurrent"
record
while all other records within the group are either "Duplicates"
of
the "Case"
or "Recurrent"
event.
episodes(
date,
case_length = Inf,
episode_type = "fixed",
recurrence_length = case_length,
episode_unit = "days",
strata = NULL,
sn = NULL,
episodes_max = Inf,
rolls_max = Inf,
case_overlap_methods = 8,
recurrence_overlap_methods = case_overlap_methods,
skip_if_b4_lengths = FALSE,
data_source = NULL,
data_links = "ANY",
custom_sort = NULL,
skip_order = Inf,
reference_event = "last_record",
case_for_recurrence = FALSE,
from_last = FALSE,
group_stats = c("case_nm", "wind", "epid_interval"),
display = "none",
case_sub_criteria = NULL,
recurrence_sub_criteria = case_sub_criteria,
case_length_total = 1,
recurrence_length_total = case_length_total,
skip_unique_strata = TRUE,
splits_by_strata = 1,
batched = "semi"
)
links_wf_episodes(
date,
case_length = Inf,
episode_type = "fixed",
strata = NULL,
sn = NULL,
display = "none"
)
episodes_af_shift(
date,
case_length = Inf,
sn = NULL,
strata = NULL,
group_stats = FALSE,
episode_type = "fixed",
data_source = NULL,
episode_unit = "days",
data_links = "ANY",
display = "none"
)
date |
|
case_length |
|
episode_type |
|
recurrence_length |
|
episode_unit |
|
strata |
|
sn |
|
episodes_max |
|
rolls_max |
|
case_overlap_methods |
|
recurrence_overlap_methods |
|
skip_if_b4_lengths |
|
data_source |
|
data_links |
|
custom_sort |
|
skip_order |
|
reference_event |
|
case_for_recurrence |
|
from_last |
|
group_stats |
|
display |
|
case_sub_criteria |
|
recurrence_sub_criteria |
|
case_length_total |
|
recurrence_length_total |
|
skip_unique_strata |
|
splits_by_strata |
|
batched |
|
episodes()
links dated records (events) that
are within a set duration of each other in iterations.
Every record is linked to a unique group (episode; epid
object).
These episodes represent occurrences of interest as specified by function's arguments and defined by a case definition.
Two main type of episodes are possible;
"fixed"
- An episode where all events are within a fixed duration of an index event.
"rolling"
- An episode where all events are within a recurring duration of an index event.
Every record in each episode is categorised as one of the following;
"Case"
- Index event of the episode (without a nested match criteria).
"Case_CR"
- Index event of the episode (with a nested match criteria).
"Duplicate_C"
- Duplicate of the index event.
"Recurrent"
- Recurrence of the index event (without a nested match criteria).
"Recurrent_CR"
- Recurrence of the index event (with a nested match criteria).
"Duplicate_R"
- Duplicate of the recurrent event.
"Skipped"
- Skipped records.
If data_links
is supplied, every element of the list must be named "l"
(links) or "g"
(groups).
Unnamed elements are assumed to be "l"
.
If named "l"
, groups without records from every listed data_source
will be unlinked.
If named "g"
, groups without records from any listed data_source
will be unlinked.
All records with a missing (NA
) strata
or date
are skipped.
Wrapper functions or alternative implementations of episodes()
for specific use cases or benefits:
episodes_wf_splits()
- Identical records are excluded from the main analysis.
episodes_af_shift()
- A mostly vectorised approach.
links_wf_episodes()
- The same functionality achieved with links
.
See vignette("episodes")
for further details.
epid
; list
episodes_wf_splits
; custom_sort
;
sub_criteria
; epid_length
;
epid_window
; partitions
;
links
; overlaps
;
data(infections)
data(hospital_admissions)
# One 16-day (15-day difference) fixed episode per type of infection
episodes(date = infections$date,
strata = infections$infection,
case_length = 15,
episodes_max = 1,
episode_type = "fixed")
# Multiple 16-day episodes with an 11-day recurrence period
episodes(date = infections$date,
strata = NULL,
case_length = 15,
episodes_max = Inf,
episode_type = "rolling",
recurrence_length = 10)
# Overlapping periods of hospital stays
dfr <- hospital_admissions[2:3]
dfr$admin_period <-
number_line(dfr$admin_dt,dfr$discharge_dt)
dfr$ep <-
episodes(date = dfr$admin_period,
strata = NULL,
case_length = index_window(dfr$admin_period),
case_overlap_methods = "inbetween")
dfr
as.data.frame(dfr$ep)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.