allocateTreatments: Allocate treatment to subjects

Description Usage Arguments Details Value Author(s) See Also Examples

Description

The Allocate component is responsible for allocating simulated subjects to a treatment group.

Usage

1
2
3
4
5
6
7
allocateTreatments(trts, 
  subjects, 
  prop = NULL, 
  ordered = FALSE, 
  seed = .deriveFromMasterSeed(), 
  idCol = getEctdColName("Subject"), 
  trtCol = getEctdColName("Trt"))

Arguments

trts

(Required) Maximum number of treatments to which subjects can be allocated. Subjects will be allocated to treatments "1:trts"

subjects

(Required) Number of subjects to be allocated to each treatment group

prop

(Optional) Proportion of subjects in each group. By default, equal proportions of subjects are assigned to each group

ordered

(Optional) Should treatments be allocated in order of subject number (ie. first N subjects gets treatment 1) as opposed to random assignment. Default is FALSE (random assignment)

seed

(Optional) Random seed to allocate interims. Based on the current random seed by default

idCol

(Optional) Subject variable name. "SUBJ" by default

trtCol

(Optional) Treatment variable name. "TRT" by default

Details

Subjects numbered "1" to "sum(subjects)" are allocated to a single treatment. The possible treatments are numbered "1" to "trts".

If "subjects" is a single number, the proportion argument is used to determine the proportion to be allocated to each treatment. By default, subjects are allocated to each treatment group with probability "1/trts".

If "subjects" is a vector with length "trts", this explicity defines the number of subjects to be allocate to each treatment group.

If "ordered" is TRUE, the allocation is done in order (eg. subject 1 gets treatment 1). If "FALSE", random allocation is performed.

Value

A data frame with subjects and treatment allocations. This data frame will contain 2 variables: SUBJThe Subjects identifier TRTThe Treatment numeric that the subject is allocated to ...

Author(s)

Mike K Smith mstoolkit@googlemail.com

See Also

createTreatments to create the set of possible treatments given a sequence matrix for a crossover design or a set of doses for a parallel design.

generateData that wraps this function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  # allocate 6 subsjects to 3 treatment groups in order
  # subjects 1 and 2 will be in treatment group 1, ...
  allocateTreatments(trts = 3, subjects = 6, ordered = TRUE)
  
  # allocate 2 subjects to group 1, 2 to group 2, 3 to group 3
  allocateTreatments(trts = 3, subjects = c(2, 2, 3))
  
  # allocation according to proportions
  # 6 subjects to allocate in total in 2 groups
  # 20% will be in group 1, 80% will be in group 2
  allocateTreatments(trts = 2, subjects = 6, prop = c(0.2, 0.8))

MSToolkit documentation built on May 2, 2019, 6:30 p.m.