Create a class of regimen. A regimen defines the rules to select treatments for patients switch, to determine the time of switching, and to update patients' endpoint data.
Methods
Method new()
initialize regimen
Usage
Regimens$new(what, when, how, ..., earliest_crossover_calendar_time = 0)Arguments
whata function determining whether patients' data would be updated due to switching treatment. It takes
patient_data, a data frame as argument, and returns a data frame of two columnspatient_idandnew_treatment, with one row per switching patient. The number of rows in the returned data frame may be smaller than the number of patients in the input data frame; patients that are left out are simply not switched. Note that the returned object will be passed into function `how()`, which is also provide by users. This argument can also be a list of functions that will be executed sequentially. No default value.whena function determining the time at which a patient switches to another treatment regimen, measured from the time of enrollment. It takes
patient_data, a data frame as argument, and returns a data frame of two columnspatient_idandswitch_time(fromenroll_time). The number of rows in the returned data frame must equal the number of rows inpatient_data, i.e., a switching time must be specified for every patient (missing values are not allowed). Note that the returned object will be passed into function `how()`, which is also provided by users. This argument can also be a list of functions that will be executed sequentially. No default value.howa function updating patients' data after treatment switching. Only modified columns and
patient_idare returned. For a cell that should not change, return its original value. Only post-switch outcomes may be changed: returning a value that differs from the original for an endpoint whose readout/event is at or beforeswitch_timeraises an error. This argument can also be a list of functions that will be executed sequentially. No default value....(optional) named arguments routed to one or more of
what,when, andhow.earliest_crossover_calendar_timenumeric. The earliest calendar time at which the triplet(s) may take effect.
0(default) is the classic enrollment-time regimen, applied from the first enrollment. A positive value marks the triplet(s) as a milestone-triggered crossover (eligibility filtering, switch-time validation and the post-switch data mask). This is set internally bytrial$crossover(); it is not a user argument ofregimen().
Method get_earliest_crossover_calendar_time()
return the earliest crossover calendar time of triplet(s)
Method append_triplet()
append one more triplet to the regimen. Used by milestone-triggered
crossover to stack a new what/when/how (with its own
earliest_crossover_calendar_time) onto an existing regimen without
overwriting earlier triplets. Triplets are executed in append order.
Arguments
what, when, howsee
regimen()....(optional) named arguments routed to
what,when, and/orhow.earliest_crossover_calendar_timenumeric. Earliest calendar time for the appended triplet. A positive value marks it as a crossover.