Skip to contents

Create a class of controller to run a trial.

Public methods in this R6 class are used in developing this package. Thus, we have to export the whole R6 class which exposures all public methods. However, only the public methods in the list below are useful to end users.

  • $run()

  • $get_output()

  • $reset()

Methods


Method new()

initialize a controller of the trial

Usage

Controllers$new(trial, listener)

Arguments

trial

a trial object returned from trial().

listener

a listener object returned from listener().


Method get_listener()

return listener in a controller.

Usage

Controllers$get_listener()


Method get_trial()

return trial in a controller.

Usage

Controllers$get_trial()


Method mute()

mute all messages (not including warnings).

Usage

Controllers$mute()

Arguments

silent

logical.


Method reset()

reset the trial and listener registered to the controller before running additional replicate of simulation. This is usually done between two calls of controller$run().

Usage

Controllers$reset()


Method get_output()

return a data frame of all current outputs saved by calling save.

Usage

Controllers$get_output(cols = NULL, simplify = TRUE)

Arguments

cols

character vector. Columns to be returned from the data frame of simulation outputs. If NULL, all columns are returned.

simplify

logical. Return vector rather than a data frame of one column when length(cols) == 1 and simplify == TRUE.


Method run()

run trial simulation.

Usage

Controllers$run(n = 1, plot_event = TRUE, silent = FALSE, dry_run = FALSE)

Arguments

n

integer. Number of replicates of simulation. n = 1 by default. Simulation results can be accessed by controller$get_output().

plot_event

logical. Create event plot if FALSE. Users should set it to be FALSE if n > 1.

silent

logical. TRUE if muting all messages during a trial. Note that warning messages are still displayed.

dry_run

logical. We are considering retire this argument. TRUE if action function provided by users is ignored and an internal default action .default_action is called instead. This default function only locks data when the milestone is triggered. Milestone time and number of endpoints' events or sample sizes are saved. It is suggested to set dry_run = TRUE to estimate distributions of triggering time and number of events before formally using custom action functions if a fixed design is in use. This helps determining planned maximum information for group sequential design and reasonable time of milestone of interest when planning a trial. Set it to FALSE for formal simulations. However, for an adaptive design where arm(s) could possibly be added or removed, setting dry_run to TRUE is usually not helpful because adaption should be executed before estimating the milestone time.


Method clone()

The objects of this class are cloneable with this method.

Usage

Controllers$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

##