Skip to contents

A fixed-sample-size DesignFixed in which each subject's treatment assignment \(w_i\) is drawn independently as \(w_i \stackrel{iid}{\sim} \mathrm{Bernoulli}(p)\), \(i = 1, \dots, n\), where \(p\) is prob_T. This is the classical Bernoulli (independent-coin-flip) randomized design: unlike DesignFixediBCRD (complete randomization), which fixes the number of treated subjects at exactly \(\mathrm{round}(np)\), a Bernoulli design leaves the realized number of treated subjects \(n_T = \sum_i w_i \sim \mathrm{Binomial}(n, p)\) random; the trade-off is independence across subjects (useful for some asymptotic/martingale arguments) at the cost of not guaranteeing exact balance, which can matter for small \(n\) or for inference procedures (e.g. exact permutation tests over a fixed number of treated) that assume a fixed \(n_T\).

Draw mechanism. draw_ws_raw(r) delegates to generate_permutations_bernoulli_cpp(), which fills an \(n \times r\) matrix of independent \(\mathrm{Bernoulli}(p)\) draws (one column per requested replicate, via a Mersenne Twister RNG seeded once per call from R's RNG state), so r replicate allocation vectors are generated with a single C++ call rather than r separate calls into R's own random-number generation. assign_w_to_all_subjects() draws a single such allocation (r = 1) and applies it to all subjects at once.

No exchange/balance search. Because subjects are treated independently, there is no optimization step analogous to DesignFixedGreedyDOptimal: covariates, if supplied, do not influence the assignment probabilities or realized allocation at all.

References

Neyman, J. (1923, transl. 1990). "On the Application of Probability Theory to Agricultural Experiments." Statistical Science, 5(4), 465-472, for the potential-outcomes framework under which Bernoulli and complete randomization are compared; see also randomized experiment for orientation on Bernoulli vs. complete (restricted) randomization.

Super classes

Design -> DesignFixed -> DesignFixedBernoulli

Methods

+ inherited public methods from DesignFixed
+ inherited public methods from Design


DesignFixedBernoulli$is_a_bernoulli_capable()

Characterization: this design draws each subject's treatment assignment as an independent \(\mathrm{Bernoulli}(p)\) coin flip (see class documentation), so it is Bernoulli-capable by construction.

Usage

DesignFixedBernoulli$is_a_bernoulli_capable()

Returns

Always TRUE for this class.


DesignFixedBernoulli$new()

Initialize a fixed Bernoulli (independent-coin-flip) experimental design. Unlike DesignFixediBCRD, the realized number of treated subjects is not fixed at n * prob_T; it is random (\(\mathrm{Binomial}(n, prob\_T)\)) because each subject's assignment is an independent coin flip (see class documentation).

Usage

DesignFixedBernoulli$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

"continuous", "incidence", "proportion", "count", "survival", or "ordinal".

prob_T

Per-subject probability \(p\) that a given subject is assigned to treatment; need not be 0.5 (unlike DesignFixedGreedyDOptimal).

include_is_missing_as_a_new_feature

Flag for missingness indicators.

n

The sample size.

verbose

A flag for verbosity.

missingness_method

How to handle missing values in covariates.

design_formula

A formula object.

seed

Integer seed for reproducibility.

Returns

A new `DesignFixedBernoulli` object


DesignFixedBernoulli$clone()

The objects of this class are cloneable with this method.

Usage

DesignFixedBernoulli$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

des = DesignFixedBernoulli$new(n = 10, response_type = 'continuous')
des$add_all_subjects_to_experiment(data.frame(x1 = rnorm(10)))
des$assign_w_to_all_subjects()