RandomExp: Randomized Experimental Designs

Description Usage Arguments Value Author(s) Examples

View source: R/RandomExp.R

Description

Randomizes subjects into treatment groups according to specified criteria.

Usage

1
RandomExp(data,sizes=NULL,groups=NULL,block=NULL,seed=NULL)

Arguments

data

A data frame containing the subjects to be randomized

sizes

a numeric vector indicating the sizes of the treatment groups. Vector must sum to the number of subjects. If not provided, subjects will be randomized into two groups of size as nearly equal as possible.

groups

a character vector giving the names of the groups. Names correspond to sizes specified in previous sizes. Length of groups must equal length of sizes.

block

Variable(s) in the data frame with respect to which blocking is performed. In order to block with respect to more than one variable at once, enter as character vector, e.g.: c("Var1","Var2").

seed

randomization seed, for reproducibility of results.

Value

A data frame: the input frame data augmented with a variable treat.grp indicating the assignment of subjects to groups.

Author(s)

Homer White hwhite0@georgetowncollege.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(SmallExp) #small hypothetical list of subjects

#completely randomized design
RandomExp(SmallExp)  

#Block with reppect to sex:
RandomExp(SmallExp,sizes=c(8,8),groups=letters[1:2],block="sex")

#Block for both sex and athletic status:
RandomExp(SmallExp,sizes=c(8,8),groups=letters[1:2],block=c("sex","athlete"))

homerhanumat/tigerstats documentation built on Sept. 27, 2020, 3:21 a.m.