dimanche 20 août 2023

How to define unequal allocation of groups in blockrand() in R

I want to design a randomized clinical trial using R v.4.0.3 and blockrand package. The following is my code:

library(blockrand)
library(writexl)
library(openxlsx)

set.seed(101)
Mos1<-blockrand(n=295, id.prefix= 'Mos -', block.prefix='B', block.sizes =1:2, stratum='XX-Y1')
set.seed(10)
Mos2<-blockrand(n=295, id.prefix= 'Mos -', block.prefix='B', block.sizes =1:2, stratum='XX-Y2')
set.seed(5)
Mos3<-blockrand(n=295, id.prefix= 'Mos -', block.prefix='B', block.sizes =1:2, stratum='XX-Y3')
set.seed(70)
Mos4<-blockrand(n=295, id.prefix= 'Mos -', block.prefix='B', block.sizes =1:2, stratum='NONXX-Y1')
set.seed(43)
Mos5<-blockrand(n=295, id.prefix= 'Mos -', block.prefix='B', block.sizes =1:2, stratum='NONXX-Y2')
set.seed(87)
Mos6<-blockrand(n=295, id.prefix= 'Mos -', block.prefix='B', block.sizes =1:2, stratum='NONXX-Y3')

dataset_names <- list('XX-Y1' = Mos1, 'XX-Y2' = Mos2,
                      'XX-Y3' = Mos3, 'NONXX-Y1' = Mos4,
                      'NONXX-Y2' = Mos5,'NONXX-Y3' = Mos6)

As you see the block.size in the function is defined as "1:2", and since the number of treatment groups is 2 (it is not written, it is default), this code produces the actual block sizes of 2 and 4 (it is multiplied). But I want the produced block sizes to be 3 and 6, while the number of groups be still 2. This means that for example in a block of 3, we will have two group A and one group B (total=3). But I could not find out how this will work out, as when I set the "block.size=3:1.5", the produced block sizes are 6 and 4. And it never goes to 6 and 3. Could anybody can help?




Aucun commentaire:

Enregistrer un commentaire