In clinical trials there is sometimes the need to examine emerging data as the trial progresses to make decisions about curtailing the trial early, either due to lack of efficacy or because statistical significance is achieved and it would be unethical to continue allocating patients to inferior treatments. These interim assessments are usually performed after a specified proportion of subjects have completed treatment. Thus, there is a cumulative proportion of patients eligible at each interim assessment. MSToolkit allows the user to specify this cumulative proportion and then allocates subjects to each interim assessment.
Usage
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
Value
A data frame containing the following variables:
- SUBJ
Subject identifier, named after
idCol
.- INTERIM
Interim flag, named after
interimCol
.
Details
This function creates the INTERIM flag that identifies which interim analysis is the FIRST for each subject
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.
Examples
# first interim with 10% of the subjects
# second with 30%
# third with 60%
interims <- createInterims(100, proportion = ".1,.3,.6" )
prop.table(table(interims$INTERIM))
#>
#> 1 2 3 4
#> 0.14 0.20 0.32 0.34
if (FALSE) {
## more examples in the unit tests
file.show( system.file("Runit", "runit.data.interim.R",
package = "MSToolkit") )
}