| crossover | R Documentation |
Apply a milestone-triggered crossover to patients who are still in the trial.
Unlike a regimen registered via add_regimen() (which is applied once,
at enrollment), crossover() is meant to be called inside a
milestone's action function. At the earliest crossover (calendar) time
T = trial$get_current_time() + delay, eligible patients may switch to a
new treatment, and only their post-switch endpoint values are altered;
already-observed data is left intact. The crossover triplet is stacked onto
the trial's regimen, so it is also re-applied to patients enrolled later.
Eligibility (the pool passed to what()) consists of patients with at
least one endpoint still "open" (unobserved, dropout-/duration-aware) at
T; fully-observed patients are excluded. when() must return a
switch time with enroll_time + switch_time >= T (a crossover cannot
predate its opening) or an error is raised. how() may only change
post-switch outcomes; returning a changed value for a pre-switch/locked cell
raises an error.
Two helper columns are injected into patient_data for the triplet
functions: earliest_crossover_calendar_time (= T) and
earliest_crossover_time_from_enrollment (= max(T - enroll_time, 0)),
so when() can write e.g.
switch_time = pmax(pfs, earliest_crossover_time_from_enrollment).
Note that this function should only be called within action functions of
milestones. It is users' responsibility to ensure that and
TrialSimulator has no way to track it.
This is a user-friendly wrapper of the member function of trial, i.e.,
Trials$crossover(). Users who are not familiar with the concept of
classes may consider using this wrapper directly.
crossover(trial, what, how, when = NULL, delay = 0, ...)
trial |
a trial object returned by |
what |
a function selecting which eligible patients crossover, returning
one row per crossing-over patient with their |
how |
a function returning the modified post-switch endpoint values for
crossing-over patients. See |
when |
(optional) a function returning |
delay |
numeric. Time after the milestone before the crossover opens, so
|
... |
(optional) named arguments routed to |
no return value, called for its side effect of updating trial.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.