.- help for ^ralloc^ (STB-41: sxd1) .- Random allocation of treatments balanced in blocks -------------------------------------------------- ^ralloc^ [BlockIdvar] [BlockSizevar] [Treatmentvar] [^, se^ed^(^#^)^ ^ns^ubj^(^#^)^ ^nt^reat^(^2 | 3 | 4^)^ ^ra^tio^(^1 | 2 | 3^)^ ^osiz^e^(^3 | 4 | 5 | 6 | 7^)^ ^eq^ual ^init(^#^)^ ^sav^ing^(^filename^)^ Description ----------- ^ralloc^ provides a sequence of treatments randomly permuted in blocks of several sizes. The size and order of the blocks is also random. A typical use is in a randomized controlled clinical trial (RCT). Options ------- ^seed(^#^)^ specifies the random number seed. If unspecified, the default is 1234567879. ^nsubj(^#^)^ specifies the total number of subjects requiring a random treatment allocation. If unspecified, the default is 100. ^ralloc^ may yield a number greater than ^nsubj^ if this is required to complete the final block. ^ntreat(^2^|^3^|^4^)^ specifies the number of treatment arms in the trial. Currently, ^ralloc^ supports 2, 3 or 4 arms. If unspecified, the default is 2. ^ratio(^1^|^2^|^3^)^ specifies the ratio of treatment allocations to the arms of the trial. If unspecified, the default is 1:1 (:1(:1)). Currently, ^ra(^2^)^ and ^ra(^3^)^ may only be specified when ^ntreat(^2^)^ is chosen. These yield a 1:2 and 1:3 allocation respectively. ^osize(^3^|^4^|^5^|^6^|^7^)^ specifies the number of different size blocks. For example, if 3 treatment arms are chosen, then ^osize(^5^)^ will yield possible block sizes of 3, 6, 9, 12, and 15. The default value is 5. Note that it is quite possible not to realize some block sizes if the number of subjects requested (^nsubj^) is low. ^equal^ specifies that block sizes will be allocated in equal proportions. In the example given under the ^osize^ option, each block would appear on roughly 20% of occasions. This may not be desirable: too many small blocks may allow breaking the blind; too many large blocks may compromise balance of treatments in the event of premature closure. The default choice is to allocate treatments in proportion to elements of Pascal's triangle. In the above example, if ^equal^ were not specified, or ^noequal^ appeared, allocation of block sizes would be in the ratio of 1:4:6:4:1. That is, the relative frequency of small and large block sizes is down-weighted. See the ^init^ option below for another way to limit the number of small blocks, albeit at the cost of increasing the number of large blocks. The number and proportions of the different block sizes is shown on-screen as a table at the end of the program. ^init(^#^)^ specifies the initiating value of the sequence defining the block sizes. When not specified the default is the number of treatments given by ^ntreat^, except when a ^ratio^ > 1 has been specified for a 2 treatment trial, when the default initiating value of the block size is 2+(^ratio^-1). When specified, ^init(^#^)^ must be an integer multiple of ^ntreat^ or (2+(^ratio^-1)). The default may also be specified by ^init(^0^)^. For example, in a 3 treatment trial, ^init(^9^)^ would, if the default ^osize^=5 is chosen, yield block sizes of 9, 12, 15, 18 and 21. If ^init^ were unspecified, the block sizes would be 3, 6, 9, 12 and 15. Currently, ^ralloc.ado^ does not provide a choice of the increments in block sizes. ^saving(^filename^)^ saves the results to a Stata .dta file. This "option" is NOT optional. Remarks ------- ^ralloc^ requires specification of 3 variables that will appear in the data set that the command creates and saves: : Variable identifying each block. : Variable storing the block size. : Variable storing the randomly allocated treatment; these are 1, 2, 3, 4 labeled as "A" "B" "C" and "D" respectively. In addition, ^ralloc^ creates a fourth variable ^Order^ which stores the original random allocation sequence. This variable may later be used with Stata's ^sort^ command to recover the sequence should this ever be disturbed. Note that ^ralloc^ issues a ^clear^ command immediately after it is invoked, so data in memory will be lost. ^ralloc^ addresses 4 (of the many) objectives of the design of a RCT: (1) Random allocation of treatments to subjects. Each block represents a random permutation of the 2, 3 or 4 treatments specified. (2) Avoiding unnecessary imbalance in the number of subjects allocated to each treatment. Allocation within blocks of reasonable size achieves this. In the case of a trial with k treatments, even in the event of unexpected termination of the trial, the imbalance will be at most 1/k times the size of the largest block used. (3) Maintenance of blinding by concealing the pattern of the blocks. A limited number of block sizes are chosen, the number depending on the ^osize^ option. Treatments are balanced within blocks; by default, equal numbers of each treatment in each block, although the ratio may be varied (1:2 or 1:3) in a 2 treatment trial. Block sizes are chosen at random with equal or unequal probabilities (depending on the presence of the ^equal^ option) and then the order of block sizes is randomly shuffled. Such a scheme makes "breaking the blind" by working out the block pattern extremely difficult. (4) Ensuring that a record is kept of the randomization protocol. The program saves the allocation sequence into a user-named .dta file. It also uses program fragments borrowed from Stata's ^notes.ado^ and ^note.ado^ to write a record of the options specified (seed, number of subjects requested etc) and certain other useful information (number of blocks used, number of subjects randomized) as notes into the data file. It does this by copying the options into global macros that can be used by ^xmknote.ado^ (a subprogram called by ^notes.ado^). [The clue that this is possible - that is, saving other than just straight text as a note - comes from the fact that one can time-and-date stamp a note by specifying the TS option.] It is good practice for the user to open a log file before issuing a command such as ^ralloc^. However, even if the log file is lost, the data file itself contains the information needed to reproduce the randomization protocol. At the conclusion of the program, the user is invited to issue the ^notes^ command to review the stored information. Examples -------- . ^ralloc^ block size treat, seed(675) sav(mytrial) Allocates treatments A and B at random in a ratio of 1:1 in blocks of sizes 2 4 6 8 and 10 to 100 subjects. Block sizes are allocated unequally in the ratio 1:4:6:4:1 (Pascal's triangle). Seed is set at 675. Sequence is saved to mytrial.dta. . ^ralloc^ bn bs Rx, nsubj(920) nt(2) osiz(4) ra(3) init(8) eq sav(mys) Allocates treatments A and B at random in ratio of 1:3 in blocks of sizes 8 12 16 and 20 to 920 subjects using Stata's default seed of 123456789. Roughly 25% of blocks will be of each size. Data saved to mys.dta. . ^ralloc^ blknum blksiz Rx, ns(4984) osiz(4) ntreat(4) sav(mys) Allocates treatments A B C and D at random in ratio of 1:1:1:1 in blocks of sizes 4 8 12 and 16 to 4984 subjects using the default seed. Block sizes are roughly in ratio of 1:3:3:1. For this last example, the following table will appear on-screen: ^Frequency of block sizes:^ block size | Freq. Percent Cum. ------------+----------------------------------- 4 | 62 12.50 12.50 8 | 183 36.90 49.40 12 | 185 37.30 86.69 16 | 66 13.31 100.00 ------------+----------------------------------- Total | 496 100.00 [Ideally, this would be captured in the user's log file. Otherwise, the table can subsequently be reproduced from the saved file by issuing the following commands: . sort blknum . by blknum: keep if _n==1 . display in b "Frequency of block sizes:" . tab blksiz Do NOT save this reduced file over the original!] In addition, since the allocation file is now in memory, if one were to issue the command: . tab blksiz Rx a table showing the frequency of treatment allocations would be produced: | treatment block size | A B C D | Total -----------+--------------------------------------------+---------- 4 | 62 62 62 62 | 248 8 | 366 366 366 366 | 1464 12 | 555 555 555 555 | 2220 16 | 264 264 264 264 | 1056 -----------+--------------------------------------------+---------- Total | 1247 1247 1247 1247 | 4988 Note that 4988 subjects were allocated (cf 4984 requested). The data set would show that the 4984th subject was the fourth in a block of size 8. This final block's allocation was completed. If the ^notes^ command were issued, we would see: _dta: 1. Randomization schema created on 2 Sep 1997 23:40 using ralloc.ado v1.1.2 2. Seed used = 123456789 3. There were 4 treatments defined 4. The treatments were allocated in the ratio 1:1:1:1 5. There were 496 blocks of 4 different sizes generated 6. The minimum block size is 4 maximum is 16 7. Block sizes were allocated proportional to elements of Pascal's triangle 8. There were 4984 allocations requested 9. There were 4988 allocations provided to maintain integrity of final block 10. The original order of allocation is stored in the variable 'Order' Author ------ Philip Ryan Department of Public Health University of Adelaide South Australia email: pryan@@medicine.adelaide.edu.au See also -------- STB: STB-41 sxd1 On line: help for @seed@, @notes@