.- help for ^ralloc^ (STB-50: sxd1.1) .- 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^(1^|^2^|^3^|^4^|^5^|^6^|^7)^ ^eq^ual ^init(^#^)^ ^tr1^lab^(^string^)^ ^tr2^lab^(^string^)^ ^tr3^lab^(^string^)^ ^tr4^lab^(^string^)^ ^shap^e^(long^|^wide)^ ^sav^ing^(^filename^)^ Description ----------- ^ralloc^ provides a sequence of treatments randomly permuted in blocks of constant or varying size. If not constant, the size and order of the blocks is also random. A typical use is in a randomised 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, ^ratio(2)^ and ^ratio(3)^ may only be specified when ^ntreat(2)^ is chosen. These yield a 1:2 and 1:3 allocation respectively. ^osize(1^|^2^|^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 realise some block sizes if the number of subjects requested (^nsubj^) is low. ^osize(1)^ gives a constant block size. ^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. If ^osize^ is 1 or 2, then equality of distribution of block size(s) is forced. 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. ^tr1lab(^string^)^ - and similar for 2, 3 4 - allows specification of a value label for treatment 1,(2,(3,(4))). The label will be truncated after the first 8 characters. The default is A,(B,(C,(D))). ^shape(long^|^wide)^ allows specification of the output to the saved file in either long or wide form. In ^long^ form, the treatment listing is sequential down page within the defined block. In ^wide^ form, the treatment listing is sequential across page within the defined block. The default is ^long^. ^saving(^filename^)^ saves the results to a Stata .dta file. This "option" is NOT optional. Remarks ------- ^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 ^eq^ual 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. If, however, balance in the number of allocations to each treatment is more critical than increased protection against breaking the blind, ^osiz^e^(1)^ permits the choice of a constant block size. This may be desired in a trial with a small number of subjects. (4) Ensuring that a record is kept of the randomisation protocol. The program saves the allocation sequence into a user-named .dta file. It also writes a record of the options specified (seed, number of subjects requested etc) and certain other useful information (number of blocks used, number of subjects randomised) as notes into the data file. ^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 labelled as "A" "B" "C" and "D" respectively, unless labels are specified using the ^tr#^lab option. In addition, ^ralloc^ creates a fourth variable ^SeqInBlk^ that gives the order of the allocation within block. This variable is explicit if the ^shape^ option is ^long^, and implicit if ^shape^ is ^wide^. In ^long^ form, a subsequent ^sort^ ^SeqInBlk^ command will restore the original order of randomised allocations. In ^wide^ form, this will be achieved by a simple ^sort^ assuming the order of variables themselves in the data set has been undisturbed. If ^shape(^wide)^ is specified then each observation will be a block. ^ralloc^ will create k = max(blocksize) new variables named #, where # = 1...k to store the allocated tretaments for that block. Of course, if a block's size, j, is such that j < k, missing values are stored in variables j+1 through k. Note that ^ralloc^ issues a ^clear^ command immediately after it is invoked, so existing data in memory will be lost. 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 randomisation protocol. At the conclusion of the program, the user is invited to issue the ^notes^ command to review the stored information. Example 1 --------- ^. ralloc block size treat, seed(675) sav(mytrial) shape(wide)^ 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 in wide form. Example 2 --------- ^. 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 in default (long) form to mys.dta. Example 3 --------- ^. ralloc blknum blksiz Rx, ns(494) osiz(2) eq ntreat(2) sav(mywide)^ ^shap(wide) tr1lab(Placebo) tr2lab(Active)^ Allocates treatments labelled "Placebo" and "Active" equally in two block sizes, 2 and 4, to 494 subjects and saves the data in wide form to file mywide.dta. Output looks like this: ^. list in 1/7^ blknum blksiz Rx1 Rx2 Rx3 Rx4 1. 1 2 Active Placebo . . 2. 2 4 Placebo Placebo Active Active 3. 3 4 Active Placebo Active Placebo 4. 4 4 Active Active Placebo Placebo 5. 5 4 Placebo Placebo Active Active 6. 6 2 Placebo Active . . 7. 7 4 Placebo Active Placebo Active ^. reshape long^ ^. sort blknum SeqInBlk^ ^. drop if Rx == .^ ^. list in 1/10^ blknum SeqInBlk blksiz Rx 1. 1 1 2 Active 2. 1 2 2 Placebo 3. 2 1 4 Placebo 4. 2 2 4 Placebo 5. 2 3 4 Active 6. 2 4 4 Active 7. 3 1 4 Active 8. 3 2 4 Placebo 9. 3 3 4 Active 10. 3 4 4 Placebo Example 4 --------- ^. 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 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 ^sav^ed 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. Randomisation schema created on 4 Jun 1999 at 23:40 using ralloc.ado v2.2.1 2. Seed used = 123456789 3. There were 4 treatments defined 4. The treatments were allocated in the ratio 1:1:1:1 5. treatments are labelled A B C D 6. There were 496 blocks of 4 different sizes generated 7. The minimum block size is 4 maximum is 16 8. Block sizes were allocated proportional to elements of Pascal's triangle 9. There were 4984 allocations requested 10. There were 4988 allocations provided 11. 4 extra allocations were provided to maintain integrity of final block 12. Sequence within block is stored in the variable 'SeqInBlk' If the ^shape(wide)^ option had been specified, an additional note would have been displayed: 13. Recover 'SeqInBlk' by issuing command at the dot prompt Author ------ Philip Ryan Department of Public Health University of Adelaide South Australia pryan@@medicine.adelaide.edu.au See also -------- STB: STB-50 sxd1.1, STB-41 sxd1 On-line: help for @seed@, @notes@