randomize: Randomization of the Treatment Assignment for Conducting...

Description Usage Arguments Details Value Author(s)

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

1
2
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 is specified (see below). If a formula is specified, it will be evaluated using data and then blocking will be based on the mahalanobis distance of the resulting model matrix. In this case, users may want to specify n.block to avoid creating blocks that have too few observations.

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 quantile of the blocking variable.

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 mahalanobis distance of the resulting model matrix will be used.

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, complete has to equal TRUE.

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 Politics, Princeton University [email protected], http://imai.princeton.edu;


experiment documentation built on May 2, 2019, 9:42 a.m.