Learn R Programming

experiment (version 1.0-0)

randomize: 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 sta
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 i
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
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 sim
complete
logical. If it equals TRUE (default), then complete randomization will be performed (within each block if randomized block designs are used). Otherwise, simple randomization will be implemented. For matched-pair designs, com

Value

  • A list of class randomize which contains the following items:
  • callthe matched call.
  • treatmentThe vector of randomized treatments.
  • dataThe data frame that was used to conduct the randomization.
  • blockThe blocking variable that was used to implement randomized-block designs.
  • matchThe matching variable that was used to implement matched-pair designs.
  • block.idThe variable indicating which observations belong to which blocks in randomized-block designs.
  • match.idThe variable indicating which observations belong to which pairs in matched-pair designs.

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.