Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Randomisation using blocks of varying size - ralloc-

    Hi Listers,

    I am interested in creating a randomisation list for a 2-arm study with 1:1 allocation ratio for N = 400. I plan to use block randomisation with blocks of varying size: 6, 8 and 10. I would like to have more blocks of size 6 rather than 8 and 10 as it would be more likely to ensure balance even in case of early termination.

    I know that the command -ralloc- allows to specify whether or not the frequency of block sizes is the same using the noequal option:

    ralloc block size treat, nsubj(400) seed(675) sav(mytrial) idvar(study_ID) init(6) osize(3) noequal

    However, it achieves this by using Pascal's triangle so it does not provide the solution I am after:

    block size 6: frequency = 78
    block size 8: frequency = 104
    block size 10: frequency = 220

    Is there any way I can modify -ralloc- to 'bias' the list to have a higher frequency of size 6 blocks? or is there another command that I could use?

    Thanks!


  • #2
    I don't understand what you want to do here. 78 + 104 + 220 = 402, not 400, and 78 is not a multiple of 6, nor is 104 a multiple of 8.

    I think the closest you can come to this is 14 blocks of 6 (N = 84), 12 blocks of 8 (N = 96), and 22 blocks of 10 (N = 220). You can do that as follows:

    Code:
    clear*
    
    set seed 675
    
    //  CREATE 14 BLOCKS OF SIZE 6, 12 OF SIZE 8, AND 22 OF SIZE 10
    set obs 3
    gen block_group = _n
    gen block_size = 6 in 1
    replace block_size = 8 in 2
    replace block_size = 22 in 3
    gen n_blocks = 14 in 1
    replace n_blocks = 12 in 2
    replace n_blocks = 10 in 3
    
    egen checksum = total(n_blocks*block_size)
    assert checksum == 400
    
    expand n_blocks
    tab block_size
    assert _N == 12 + 14 + 10
    
    gen double shuffle = runiform()
    sort shuffle
    drop shuffle
    gen int block_num = _n
    
    
    expand block_size
    assert _N == 400
    
    //  RANDOMIZE WITHIN BLOCKS
    sort block_num
    gen sequence = _n
    gen double shuffle = runiform()
    
    by block_num (shuffle), sort: gen byte assignment = 2*_n <= block_size
    
    keep sequence block_num block_size assignment
    sort sequence
    Last edited by Clyde Schechter; 12 Jan 2022, 14:54.

    Comment


    • #3
      Your code:
      ralloc block size treat, nsubj(400) seed(675) sav(mytrial) idvar(study_ID) init(6) osize(3) noequal
      delivers 78/6=13 blocks of size 6, 104/8=13 blocks of size 8, and 220/10 = 22 blocks of size 10. It seems that ralloc's algorithm (based on the binomial distribution) to reduce the relative numbers of small and large blocks hasn't worked very well. This is not altogether surprising: the small total number of subjects and the large size of the blocks makes a "long run" result harder to achieve.

      There is no easy way to tweak ralloc to allow a much more flexible choice of block sizes, and at this stage I would not contemplate doing this. Sorry.

      But Clyde points the way: unless there is another existing program to achieve what you want then you need to knit your own and he provides helpful code to start you off.

      Comment


      • #4
        Thanks both for your input on this.

        Philip Ryan thanks for considering ways to use -ralloc- although I do appreciate this may not be viable.

        Clyde Schechter thanks for providing helpful code to make my own randomisation. I will make a start on this route...

        Comment

        Working...
        X