This class provides methods to randomly assign treatments to a dataset while ensuring baseline covariate balance. It can handle both simple and stratified randomization.
version
The version of the im
package used for randomization.
data
The data frame with the assigned treatment.
seed
The random seed used for reproducibility.
balance_summary
A summary (or list of summaries) of the balance assessment after randomization.
balance_plot
A plot (or list of plots) of the balance assessment after randomization.
new()
Initialize a new Randomizer object.
randomizer$new(
data,
variables,
standard = "Not Concerned",
seed = NULL,
max_attempts = 100,
group_by = NULL
)
data
The input data frame.
variables
A vector of covariate names to check for balance.
standard
The desired level of baseline equivalence. Must be one of "Not Concerned", "Concerned", or "Very Concerned". Default is "Not Concerned". ("Not Concerned", "Concerned", or "Very Concerned").
seed
(Optional) An integer to set the random seed.
max_attempts
(Optional) Maximum number of randomization attempts.
group_by
(Optional) A character vector of column names to stratify randomization.
A new randomizer
object.
clone()
The objects of this class are cloneable with this method.
randomizer$clone(deep = FALSE)
deep
Whether to make a deep clone.