createInterims: create the interim flag

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

View source: R/createInterims.R

Description

That function creates the INTERIM flag that identifies which subject is included in the analysis at every interim stage.

Usage

1
2
3
4
5
6
createInterims(subjects, 
  proportion, 
  seed = .deriveFromMasterSeed(), 
  idCol = getEctdColName("Subject"), 
  interimCol = getEctdColName("Interim"), 
  method = "Sample")

Arguments

subjects

(Required) Vector of subjects or number of subjects

proportion

(Required) Vector of proportions of subjects in each interim. This is a vector of cumulative proportions

seed

(Optional) The random number generation seed to use. By default, this is derived from the current random seed

idCol

(Optional) Name of the subject column ("SUBJ" by default)

interimCol

(Optional) Name of the interim column ("INTERIM" by default)

method

(Optional) Method to use. Must be one of Sample or Proportion. Default is Sample

Details

If the "method" argument is set to "Sample", the interim numbers should be assigned using the following algorithm: Store the number of subjects (nSubjects) and the number of interims (nInterims) Append a zero to the start of the proportions and take differences to get a vector of "non-cumulative" probabilities Take "nSubjects" samples from the values "1" to "nInterims" with probabilities set to the derived "non-cumulative" probabilities Replace the "interim" variable with these values.

If the "method" argument is set to "Proportion", the interim numbers should be assigned using the following algorithm: Store the number of subjects (nSubjects) and the number of interims (nInterims) Convert the cumulative proportions to "non-cumulative" probabilities Allocate a "base" number of subjects to each interim (found by multiplying nSubjects by the set of probabilities, then take the floor of the resulting values) If any subjects are left at this stage, use the "sample" method (below) to allocate the remaining subjects to interims "Shuffle" the interim variable so that the results are not ordered.

Value

A data frame containing the following variables:

SUBJ

Subject identifier, named after idCol.

INTERIM

Interim flag, named after interimCol.

Author(s)

Mike K Smith mstoolkit@googlemail.com

See Also

generateData

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
  # first interim with 10% of the subjects
  # second with 30%
  # third with 60%
  createInterims(100, proportion  = ".1,.3,.6" )
  
  ## Not run: 
    ## more examples in the unit tests
    file.show( system.file("Runit", "runit.data.interim.R",  package = "MSToolkit") )
  
## End(Not run)
  

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