Creates an omop_temporal_spec object that defines how events
are filtered relative to a cohort index date or calendar dates. The
spec can combine index-relative windows, calendar date ranges, and event
selection (first/last N) and deterministic minimum-gap collapsing.
Arguments
- index_window
Named list with
startandend(integer days relative to the cohort index date). Negative values denote time before the index date.- calendar
Named list with
startandend(character ISO 8601 dates, e.g."2020-01-01").- event_select
Named list with
order("first"or"last"),n(integer; number of events), and optionalby = "grain"(default) orby = "concept". Concept mode keeps the first/last N independently for each concept within a cohort episode whenindex_windowis present, otherwise within each person.- min_gap
Positive integer days, or a named list with
days, optionalby = "concept"or"grain", and optionalkeep = "first"or"last". Adjacent events no more thandaysapart form one chain. The normalized policy defaults to concept-specific chains represented by their first event.
Examples
if (FALSE) { # \dontrun{
# Events within 1 year before each index episode; keep its first 3 events
temporal <- omop.temporal(
index_window = list(start = -365, end = 0),
event_select = list(order = "first", n = 3)
)
plan <- ds.omop.plan.events(plan, "conditions",
"condition_occurrence", temporal = temporal)
} # }