
Sequential One-by-One Experimental Design
Source:R/design_seq_one_by_one_abstract.R
DesignSeqOneByOne.RdAbstract R6 class encapsulating data and functionality for a sequential one-by- one experimental design.
Sample size and stopping
Subjects are assigned one at a time, but this class does not implement interim
outcome monitoring or an outcome-dependent stopping rule. For the usual
fixed-sample analysis, specify the target sample size n before enrollment
and stop after exactly n subjects; the caller is responsible for ending
enrollment at that point. With n = NULL, the class leaves the final sample
size unspecified and does not determine when enrollment ends. Inference methods
that assume a fixed sample size require the final size to be chosen independently
of accumulating outcomes.
Seed and reproducibility
With a non-NULL seed, each assignment draws its randomness from a
seed derived from (seed, the subject's index t), with the session's
random-number state saved before the draw and restored after it. So the
allocation depends only on the seed and the subjects' covariates (and, for the
KK21 designs, the responses recorded so far); random numbers used between
assignments do not change it, a trial saved with saveRDS() continues
after readRDS() exactly as an uninterrupted run would, and neither
construction nor assignment moves the caller's own stream.
draw_ws_according_to_design() on a seeded design likewise runs under a
seed derived from (seed, "redraw"), so repeated calls return the
same draws, as on a fixed design. With seed = NULL (the default) every
assignment draws from the session's stream, as before.
Super class
Design -> DesignSeqOneByOne
Methods
+ inherited public methods from Design
Design$add_all_subject_responses()Design$add_one_subject_response()Design$any_censoring()Design$applicable_inference_class_names()Design$assert_all_responses_recorded()Design$assert_all_subjects_arrived()Design$assert_even_allocation()Design$assert_fixed_sample()Design$capabilities()Design$check_experiment_completed()Design$duplicate()Design$get_X()Design$get_X_imp()Design$get_X_raw()Design$get_design_formula()Design$get_edi_version_created()Design$get_effective_dead()Design$get_effective_time()Design$get_missingness_method()Design$get_n()Design$get_ordinal_levels()Design$get_original_ordinal_levels()Design$get_prob_T()Design$get_response_type()Design$get_response_type_original()Design$get_t()Design$get_w()Design$get_y()Design$get_y_L()Design$get_y_R()Design$get_y_original()Design$has_general_censoring()Design$incompatible_inference_classes_due_to_design_structure()Design$is_a_bernoulli_capable()Design$is_a_cluster_capable()Design$is_a_kk_matching_capable()Design$is_blocking_design()Design$is_fixed_sample_size()Design$is_matching_design()Design$overwrite_all_subject_assignments()Design$prepare_for_resampling_replay()Design$randomization_family()Design$supports()Design$supports_randomization_draw()Design$supports_resampling()Design$supports_resampling_replay()Design$transform_y()Design$unavailable_inference_classes_due_to_missing_packages()Design$warm_all_subject_data_cache()
DesignSeqOneByOne$new()
Initialize a sequential one-by-one design.
Usage
DesignSeqOneByOne$new(
response_type,
prob_T = 0.5,
include_is_missing_as_a_new_feature = TRUE,
n = NULL,
verbose = FALSE,
missingness_method = "impute",
design_formula = ~.,
seed = NULL,
...
)Arguments
response_typeThe data type of response values.
prob_TThe probability of the treatment assignment. Efron, Atkinson, Pocock-Simon and the KK designs have no
prob_Targument; their allocation is always 1:1.include_is_missing_as_a_new_featureIf missing data is present, include a dummy variable for it.
nThe prespecified target sample size for fixed-sample analysis. If
NULL, the final sample size is left to the caller; the class does not provide a stopping rule.verboseWhether to print progress messages.
missingness_methodHow to handle missing values in covariates.
design_formulaA formula object.
seedInteger seed for reproducibility, or
NULL(the default) to draw from the session's stream. With a seed, each assignment is drawn under a seed derived from (seed, subject index) and the session's stream is restored afterwards; see the "Seed and reproducibility" section....Extra arguments passed to the
Designsuperclass.
DesignSeqOneByOne$draw_ws_according_to_design()
Draw treatment assignment vectors according to the design (the
sequential rule replayed over the enrolled subjects). With a non-NULL
seed the draws run under a seed derived from (seed, "redraw")
with the session's random-number state saved and restored, so repeated calls
return the same draws and the caller's stream is untouched; with
seed = NULL they come from the session's stream.
Examples
# DesignSeqOneByOne is abstract and cannot be instantiated directly;
# construct a concrete subclass instead, e.g.:
seq_des = DesignSeqOneByOneBernoulli$new(n = 6, response_type = 'continuous')
seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = rnorm(1)))
#> [1] 1