RandomExp {tigerstats} | R Documentation |
Randomized Experimental Designs
Description
Randomizes subjects into treatment groups according to specified criteria.
Usage
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
|
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
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"))