prune_event_durations: Prune event durations.

View source: R/matching_function.R

prune_event_durationsR Documentation

Prune event durations.


Flags or removes leftover supply durations after dosage changes, the end of a special period, or treatment interruption. The function accepts the raw list output of compute_event_durations and additional arguments to specify event durations that need to be removed.


  include = c("special periods", "treatment interruptions", "dosage changes"),
  medication.class.colnames = data$medication.class.colnames,,,
  keep.all = TRUE,
  suppress.warnings = FALSE, = FALSE,



A list, the output of compute_event_durations.


A Vector of strings indicating whether to include dosage changes, special periods, and/or treatment interruptions.


A Vector of strings, the name(s) of the column(s) in the event_durations element of data to identify medication classes. Defaults to the columns used in compute_event_durations.

event durations from before the dosage change, special period, or treatment interruptions are removed if there is a new dispensing event within the number of days specified as integer after the dosage change or end of the special period/treatment interruption.

event durations from before dosage change, special period, or treatment interruption are removed if there is NO new dispensing event within the number of days specified as integer after the dosage change or end of the special period/treatment interruption.


Logical, should events be kept and marked for removal? If TRUE, a new column .prune.event will be added to event_durations, if FALSE the events will be removed from the output.


Logical, if TRUE don't show any warnings.

Logical, if TRUE return a data.table object, otherwise a data.frame.


other possible parameters.


Dosage changes, special periods, and treatment interruptions may lead to overestimation of implementation, e.g. if patients get a refill after discharge from hospital and don't continue to use their previous supply. Likewise, it may also lead to overestimation of persistence, e.g. when patients discontinue treatments after the end of a special period or treatment interruption.


A data.frame or data.table, the pruned event_durations.


## Not run: 
# select medication class of interest and compute event durations

disp_data <- durcomp.dispensing[ID == 3 & grepl("J01EE01", ATC.CODE)]
presc_data <- durcomp.prescribing[ID == 3 & grepl("J01EE01", ATC.CODE)]

# compute event durations
event_durations_list <- compute_event_durations( = disp_data,
                                       = presc_data,
                                       = durcomp.hospitalisation,
                                                ID.colname = "ID",
                                       = "DATE.PRESC",
                                       = "DATE.DISP",
                                                date.format = "%Y-%m-%d",
                                                medication.class.colnames = c("ATC.CODE",
                                                total.dose.colname = "TOTAL.DOSE",
                                                presc.daily.dose.colname = "DAILY.DOSE",
                                                presc.duration.colname = "PRESC.DURATION",
                                                visit.colname = "VISIT",
                                                force.init.presc = TRUE,
                                                force.presc.renew = TRUE,
                                                split.on.dosage.change = TRUE,
                                                trt.interruption = "carryover",
                                                special.periods.method = "carryover",
                                                suppress.warnings = FALSE,
                                       = TRUE,
                                       = FALSE)

# prune event durations
event_durations <- prune_event_durations(event_durations_list,
                                         include = c("special periods"),
                                         medication.class.colnames = "ATC.CODE",
                                = 7,
                                = 30,
                                         keep.all = FALSE)
## End(Not run)

AdhereR documentation built on July 5, 2022, 5:08 p.m.