Skip to contents

Abstract 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


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_type

The data type of response values.

prob_T

The probability of the treatment assignment. Efron, Atkinson, Pocock-Simon and the KK designs have no prob_T argument; their allocation is always 1:1.

include_is_missing_as_a_new_feature

If missing data is present, include a dummy variable for it.

n

The 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.

verbose

Whether to print progress messages.

missingness_method

How to handle missing values in covariates.

design_formula

A formula object.

seed

Integer 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 Design superclass.


DesignSeqOneByOne$add_one_subject()

Add subject-specific measurements for the next subject entrant.

Usage

DesignSeqOneByOne$add_one_subject(x_new, allow_new_cols = TRUE)

Arguments

x_new

A data frame with one row representing the new subject's covariates.

allow_new_cols

Allow new features in the new subject's covariates.


DesignSeqOneByOne$add_one_subject_to_experiment_and_assign()

Adds a subject and assigns treatment.

Usage

DesignSeqOneByOne$add_one_subject_to_experiment_and_assign(x_new)

Arguments

x_new

A data frame with one row representing the new subject's covariates.

Returns

The treatment assignment as {0,1} (1 = treated, 0 = control).


DesignSeqOneByOne$assign_wt()

Assigns treatment to the current subject.

Usage

DesignSeqOneByOne$assign_wt()

Returns

The treatment assignment (0 or 1).


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.

Usage

DesignSeqOneByOne$draw_ws_according_to_design(r = 1L)

Arguments

r

Number of vectors to draw. Default is 1.

Returns

A matrix with one row per enrolled subject and r columns of {0,1} entries (1 = treated, 0 = control).


DesignSeqOneByOne$print_current_subject_assignment()

Prints the current subject's assignment.

Usage

DesignSeqOneByOne$print_current_subject_assignment()


DesignSeqOneByOne$clone()

The objects of this class are cloneable with this method.

Usage

DesignSeqOneByOne$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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