randomize {experiment} | R Documentation |
Randomization of the Treatment Assignment for Conducting Experiments
Description
This function can be used to randomize the treatment assignment for randomized experiments. In addition to the complete randomization, it implements randomized-block and matched-pair designs.
Usage
randomize(
data,
group = c("Treat", "Control"),
ratio = NULL,
indx = NULL,
block = NULL,
n.block = NULL,
match = NULL,
complete = TRUE
)
Arguments
data |
A data frame containing the observations to which the treatments are randomly assigned. |
group |
A numerical or character vector indicating the treatment/control groups. The length of the vector equals the total number of such groups. The default specifies two groups called “Treat” and “Control”. |
ratio |
An optional numerical vector which specifies the proportion of the treatment/control groups within the sample. The length of the vector should equal the number of groups. The default is the equal allocation. |
indx |
An optional variable name in the data frame to be used as the names of the observations. If not specified, the row names of the data frame will be used so long as they are available. If the row names are not available, the integer sequence starting from 1 will be used. |
block |
An optional variable name in the data frame or a formula to be
used as the blocking variables for randomized-block designs. If a variable
name is specified, then the unique values of that variable will form blocks
unless |
n.block |
An optional scalar specifying the number of blocks to be
created for randomized block designs. If unspecified, the unique values of
the blocking variable will define blocks. If specified, the blocks of
roughly equal size will be created based on the |
match |
An optional variable name in the data frame or a formula to be
used as the matching variables for matched-pair designs. This input is
applicable only to the case where there are two groups. Pairs of
observations will be formed based on the similar values of the matching
variable. If a formula is specified, the |
complete |
logical. If it equals |
Details
Randomized-block designs refer to the complete randomization of the treatment within the pre-specified blocks which contain multiple observations. Matched-pair designs refer to the randomization of the binary treatment variable within the pre-specified pair of observations.
Value
A list of class randomize
which contains the following items:
call |
the matched call. |
treatment |
The vector of randomized treatments. |
data |
The data frame that was used to conduct the randomization. |
block |
The blocking variable that was used to implement randomized-block designs. |
match |
The matching variable that was used to implement matched-pair designs. |
block.id |
The variable indicating which observations belong to which blocks in randomized-block designs. |
match.id |
The variable indicating which observations belong to which pairs in matched-pair designs. |
Author(s)
Kosuke Imai, Department of Government and Department of Statistics, Harvard University imai@Harvard.Edu, https://imai.fas.harvard.edu;