This page is devoted to the edition of a randomisation list for a randomised clinical trial (RCT) comparing two arms. We focus here on randomisation within blocks, in order to provide a balance between arms throughout the study. R codes are proposed below.
RANDOMISATION WITHOUT STRATIFICATION
In order to edit a randomisation list for a RCT comparing an experimental treatment against placebo (2 arms), with 410 patients, using random block sizes of 6, 8, 10 and 12 (meaning that each block is defined with 3, 4, 5 or 6 occurrences of each arm), we can compute the following code:
library(blockrand)
randomisation_list <- function(myseed, n, labelArms = c("A","B"), block = 1:4)
{
set.seed(myseed)
mylist <- blockrand(n=n,
num.levels = length(labelArms),
levels = labelArms,
block.sizes = block)
}
edit_list <- randomisation_list(myseed=9478, n=410,
labelArms=c("Placebo","Experimental treatment"),
block=c(3,4,5,6))
table(edit_list$treatment)
# Experimental treatment Placebo
# 207 207
Input parameters:
- n : number of patients in the randomisation list
- labelArms : vector of labels for randomised arms (vector size = number of arms)
- block : vector of integers defining the block sizes (number of occurrences of each arm)
RANDOMISATION WITH STRATIFICATION
Stratification with one variable
In order to edit a randomisation list for a RCT comparing an experimental treatment against placebo (2 arms), with 128 patients, using random block sizes of 4, 6 and 8 (meaning that each block is defined with 2, 3, or 4 occurrences of each arm), and considering a randomisation stratified with gender (male, female), we can compute the following code:
library(blockrand)
randomisation_list_strat <- function(myseed, n, labelArms = c("A","B"), block = 1:4,
strat = c("Stratum1","Stratum2"))
{
set.seed(myseed)
n_strat <- n / length(strat)
for (i in 1:length(strat)) {
listrand <- blockrand(n=n_strat,
num.levels = length(labelArms),
levels = labelArms,
block.sizes = block,
stratum = strat[i])
if (i > 1) {
mylist <- rbind(mylist, listrand)
}
else {
mylist <- listrand
}
}
return(mylist)
}
edit_list <- randomisation_list_strat(myseed=72048, n=128,
labelArms=c("Placebo","Experimental treatment"),
block=2:4,
strat=c("Male","Female"))
table(edit_list$stratum, edit_list$treatment)
# Experimental treatment Placebo
# Female 32 32
# Male 34 34
Input parameters:
- n : number of patients in the randomisation list
- labelArms : vector of labels for randomised arms (vector size = number of arms)
- block : vector of integers defining the block sizes (number of occurrences of each arm)
- strat : vector of labels for stratum (vector size = number of stratum)
Stratification with more than one variable
In order to edit a randomisation list for a RCT comparing an experimental treatment against placebo (2 arms), with 372 patients, using random block sizes of 4, 6 and 8 (meaning that each block is defined with 2, 3, or 4 occurrences of each arm), and considering a randomisation stratified with age (< 40 years,
library(blockrand)
randomisation_list_strat <- function(myseed, n, labelArms = c("A","B"), block = 1:4,
strat = c("Stratum1","Stratum2"))
{
set.seed(myseed)
n_strat <- n / length(strat)
for (i in 1:length(strat)) {
listrand <- blockrand(n=n_strat,
num.levels = length(labelArms),
levels = labelArms,
block.sizes = block,
stratum = strat[i])
if (i > 1) {
mylist <- rbind(mylist, listrand)
}
else {
mylist <- listrand
}
}
return(mylist)
}
edit_list <- randomisation_list_strat(myseed=74792, n=372,
labelArms=c("Placebo","Experimental treatment"),
block=2:4,
strat=c("<40 and centre 1",
"<40 and centre 2",
"<40 and centre 3",
"40+ and centre 1",
"40+ and centre 2",
"40+ and centre 3"))
table(edit_list$stratum, edit_list$treatment)
# Experimental treatment Placebo
# <40 and centre 1 31 31
# <40 and centre 2 32 32
# <40 and centre 3 31 31
# 40+ and centre 1 31 31
# 40+ and centre 2 31 31
# 40+ and centre 3 32 32
Input parameters:
- n : number of patients in the randomisation list
- labelArms : vector of labels for randomised arms (vector size = number of arms)
- block : vector of integers defining the block sizes (number of occurrences of each arm)
- strat : vector of labels for stratum (vector size = number of stratum)
RANDOMISATION WITHOUT STRATIFICATION
In order to edit a randomisation list for a RCT comparing an experimental treatment against placebo (2 arms), with a 2:1 allocation ratio in favor of experimental treatment, with 510 patients, using random block sizes of 9, 12 and 15 (meaning that each block is defined with 3, 4 or 5 occurrences for placebo arm), we can compute the following code:
library(blockrand)
randomisation_list <- function(myseed, n, ratio = 1, labelArms = c("A","B"), block = 1:4)
{
set.seed(myseed)
vecArms <- c(rep(labelArms[1], times=ratio), labelArms[2])
mylist <- blockrand(n=n,
num.levels = length(vecArms),
levels = vecArms,
block.sizes = block)
}
edit_list <- randomisation_list(myseed=9478, n=510, ratio=2,
labelArms=c("Experimental treatment","Placebo"),
block=c(3,4,5))
table(edit_list$treatment)
# Experimental treatment Placebo
# 340 170
Input parameters:
- n : number of patients in the randomisation list
- ratio : number of patients randomised in the first arm divided by the number of patients randomised in the second arm
- labelArms : vector of labels for randomised arms (vector size = number of arms)
- block : vector of integers defining the block sizes (number of occurrences for the second arm)
RANDOMISATION WITH STRATIFICATION
Stratification with one variable
In order to edit a randomisation list for a RCT comparing an experimental treatment against placebo (2 arms), with a 3:1 allocation ratio in favor of placebo arm, with 128 patients, using random block sizes of 8, 12 and 16 (meaning that each block is defined with 2, 3, or 4 occurrences for experimental arm), and considering a randomisation stratified with gender (male, female), we can compute the following code:
library(blockrand)
randomisation_list_strat <- function(myseed, n, ratio = 1, labelArms = c("A","B"), block = 1:4,
strat = c("Stratum1","Stratum2"))
{
set.seed(myseed)
n_strat <- n / length(strat)
vecArms <- c(rep(labelArms[1], times=ratio), labelArms[2])
for (i in 1:length(strat)) {
listrand <- blockrand(n=n_strat,
num.levels = length(vecArms),
levels = vecArms,
block.sizes = block,
stratum = strat[i])
if (i > 1) {
mylist <- rbind(mylist, listrand)
}
else {
mylist <- listrand
}
}
return(mylist)
}
edit_list <- randomisation_list_strat(myseed=72048, n=128, ratio=3,
labelArms=c("Placebo","Experimental treatment"),
block=2:4,
strat=c("Male","Female"))
table(edit_list$stratum, edit_list$treatment)
# Experimental treatment Placebo
# Female 16 48
# Male 16 48
Input parameters:
- n : number of patients in the randomisation list
- ratio : number of patients randomised in the first arm divided by the number of patients randomised in the second arm
- labelArms : vector of labels for randomised arms (vector size = number of arms)
- block : vector of integers defining the block sizes (number of occurrences for the second arm)
- strat : vector of labels for stratum (vector size = number of stratum)
Stratification with more than one variable
In order to edit a randomisation list for a RCT comparing an experimental treatment against placebo (2 arms), with a 2:1 allocation ratio in favor of experimental treatment, with 477 patients, using random block sizes of 6, 9 and 12 (meaning that each block is defined with 2, 3, or 4 occurrences for placebo arm), and considering a randomisation stratified with age (< 40 years,
library(blockrand)
randomisation_list_strat <- function(myseed, n, ratio = 1, labelArms = c("A","B"), block = 1:4,
strat = c("Stratum1","Stratum2"))
{
set.seed(myseed)
n_strat <- n / length(strat)
vecArms <- c(rep(labelArms[1], times=ratio), labelArms[2])
for (i in 1:length(strat)) {
listrand <- blockrand(n=n_strat,
num.levels = length(vecArms),
levels = vecArms,
block.sizes = block,
stratum = strat[i])
if (i > 1) {
mylist <- rbind(mylist, listrand)
}
else {
mylist <- listrand
}
}
return(mylist)
}
edit_list <- randomisation_list_strat(myseed=74792, n=477, ratio=2,
labelArms=c("Experimental treatment","Placebo"),
block=2:4,
strat=c("<40 and centre 1",
"<40 and centre 2",
"<40 and centre 3",
"40+ and centre 1",
"40+ and centre 2",
"40+ and centre 3"))
table(edit_list$stratum, edit_list$treatment)
# Experimental treatment Placebo
# <40 and centre 1 60 30
# <40 and centre 2 60 30
# <40 and centre 3 54 27
# 40+ and centre 1 58 29
# 40+ and centre 2 56 28
# 40+ and centre 3 56 28
Input parameters:
- n : number of patients in the randomisation list
- ratio : number of patients randomised in the first arm divided by the number of patients randomised in the second arm
- labelArms : vector of labels for randomised arms (vector size = number of arms)
- block : vector of integers defining the block sizes (number of occurrences for the second arm)
- strat : vector of labels for stratum (vector size = number of stratum)