assignment {blockTools}R Documentation

Randomly assign blocked units to treatment conditions

Description

Using an output object from block, assign elements of each row to treatment condition columns. Each element is equally likely to be assigned to each column.

Usage

 assignment(block.obj, seed = NULL, namesCol = NULL) 

Arguments

block.obj

an output object from block, or a user-specified block object.

seed

a user-specified random seed.

namesCol

an optional vector of column names for the output table.

Details

block.obj can be specified directly by the user. It can be a single dataframe or matrix with blocks as rows and treatment conditions as columns. assignment is designed to take a list with two elements. The first element should be named $blocks, and should be a list of dataframes. Each dataframe should have blocks as rows and treatment conditions as columns. The second element should be a logical named $level.two. A third element, such as $call in a block output object, is currently ignored.

Specifying the random seed yields constant assignment, and thus allows for easy replication of experimental protocols.

If namesCol = NULL, then “Treatment 1”, “Treatment 2”, ... are used. If namesCol is supplied by the user and is of length n.tr (or 2*n.tr, where level.two = TRUE), then either "Distance" or "Max Distance" is appended to it as appropriate (consistent with namesCol usage in block). If namesCol is supplied and is of length n.tr+1 (or 2*n.tr+1, where level.two = TRUE), then the last user-supplied name is used for the last column of each dataframe.

Value

A list with elements

assg

a list of dataframes, each containing a group's blocked units assigned to treatment conditions. If there are two treatment conditions, then the last column of each dataframe displays the multivariate distance between the two units. If there are more than two treatment conditions, then the last column of each dataframe displays the largest of the multivariate distances between all possible pairs in the block.

call

the orginal call to assignment.

Author(s)

Ryan T. Moore

See Also

block, diagnose

Examples

data(x100)

# First, block
out <- block(x100, groups = "g", n.tr = 2, id.vars = c("id"), block.vars
             = c("b1", "b2"), algorithm="optGreedy", distance =
             "mahalanobis", level.two = FALSE, valid.var = "b1",
             valid.range = c(0,500), verbose = TRUE)

# Second, assign
assigned <- assignment(out, seed = 123)

# assigned$assg contains 3 data frames

[Package blockTools version 0.6.4 Index]