Skip to contents

Filters cases based on the precedence relations between two sets of activities.

Usage

filter_precedence(
  log,
  antecedents,
  consequents,
  precedence_type = c("directly_follows", "eventually_follows"),
  filter_method = c("all", "one_of", "none"),
  reverse = FALSE,
  eventlog = deprecated()
)

# S3 method for log
filter_precedence(
  log,
  antecedents,
  consequents,
  precedence_type = c("directly_follows", "eventually_follows"),
  filter_method = c("all", "one_of", "none"),
  reverse = FALSE,
  eventlog = deprecated()
)

# S3 method for grouped_log
filter_precedence(
  log,
  antecedents,
  consequents,
  precedence_type = c("directly_follows", "eventually_follows"),
  filter_method = c("all", "one_of", "none"),
  reverse = FALSE,
  eventlog = deprecated()
)

Arguments

log

log: Object of class log or derivatives (grouped_log, eventlog, activitylog, etc.).

antecedents, consequents

character vector: The set of antecendent and consequent activities. Both are character vectors containing at least one activity identifier. All pairs of antecedents and consequents are turned into seperate precedence rules.

precedence_type

character (default "directly_follows"): When "directly_follows", the consequent activity should happen immediately after the antecedent activities.
When "eventually_follows", other events are allowed to happen in between.

filter_method

character (default "all"): When "all", only cases where all the relations are valid are preserved.
When "one_of", all the cases where at least one of the conditions hold, are preserved.
When "none", none of the relations are allowed.

reverse

logical (default FALSE): Indicating whether the selection should be reversed.

eventlog

[Deprecated]; please use log instead.

Value

When given an object of type log, it will return a filtered log. When given an object of type grouped_log, the filter will be applied in a stratified way (i.e. each separately for each group). The returned log will be grouped on the same variables as the original log.

Details

In order to extract a subset of an event log which conforms with a set of precedence rules, one can use the filter_precedence method. There are two types of precendence relations which can be tested: activities that should directly follow ("directly_follows") each other, or activities that should eventually follow ("eventually_follows") each other. The type can be set with the precedence_type argument.

Further, the filter requires a vector of one or more antecedents (containing activity labels), and one or more consequents.

Finally, a filter_method argument can be set. This argument is relevant when there is more than one antecedent or consequent. In such a case, you can specify that all possible precedence combinations must be present ("all"), at least one of them ("one_of"), or none ("none").

Methods (by class)

  • filter_precedence(log): Filters cases for a log.

  • filter_precedence(grouped_log): Filters cases for a grouped_log.

References

Swennen, M. (2018). Using Event Log Knowledge to Support Operational Exellence Techniques (Doctoral dissertation). Hasselt University.

Examples


eventdataR::patients %>%
  filter_precedence(antecedents = "Triage and Assessment",
            consequents = "Blood test",
            precedence_type = "directly_follows") %>%
  bupaR::traces()
#> # A tibble: 3 × 3
#>   trace                                    absolute_frequency relative_frequency
#>   <chr>                                                 <int>              <dbl>
#> 1 Registration,Triage and Assessment,Bloo…                234            0.987  
#> 2 Registration,Triage and Assessment,Bloo…                  2            0.00844
#> 3 Registration,Triage and Assessment,Bloo…                  1            0.00422

eventdataR::patients %>%
  filter_precedence(antecedents = "Triage and Assessment",
            consequents = c("Blood test", "X-Ray", "MRI SCAN"),
            precedence_type = "eventually_follows",
            filter_method = "one_of") %>%
  bupaR::traces()
#> # A tibble: 6 × 3
#>   trace                                    absolute_frequency relative_frequency
#>   <chr>                                                 <int>              <dbl>
#> 1 Registration,Triage and Assessment,X-Ra…                258            0.518  
#> 2 Registration,Triage and Assessment,Bloo…                234            0.470  
#> 3 Registration,Triage and Assessment,Bloo…                  2            0.00402
#> 4 Registration,Triage and Assessment,X-Ray                  2            0.00402
#> 5 Registration,Triage and Assessment,X-Ra…                  1            0.00201
#> 6 Registration,Triage and Assessment,Bloo…                  1            0.00201