help rct_minim -------------------------------------------------------------------------------


rct_minim - Allocation of treatments to balance prognostic factors in controlled trials


rct_minim , filestub(filenamestub) nt(#) nf(#) nl(#1 [#2 [...]) pchoice(a|b|c) [options]

options Description ------------------------------------------------------------------------- Main filestub(filenamestub) filename prefix for allocations and factor balance files; required option nt(#) number of treatment groups; required option nf(#) number of prognostic factors; required option nl(#1 #2 ...) number of levels in factor1 factor2 etc; required option pchoice(a|b|c) method to calculate treatment assignment probabilities; required option

Options *p(#) specify probability p for pchoice method a *q(#) specify parameter q for pchoice method b *t(#) specify parameter t for pchoice method c treatvar(varname) name of treatment group variable factnames(name1 name2...) names of prognostic factors pattern(#1 #2 ...) current subject's levels on each prognostic factor w(#1 #2...) weights for each prognostic factor mchoice(range|var|sd|thresh) method for measuring imbalance in prognostic factors limit(#) limit of acceptable imbalance (specified when mchoice(thresh) is specified) delay(#) specify first # subjects are allocated treatments at random warn user response required between re-display of command and treatment assignment showdetail display detailed output

------------------------------------------------------------------------- * one of p, q or t must be specified


rct_minim assigns subjects to treatment groups so as to balance categorical or ordered categorical prognostic factors across the treatments using a process called minimization (see Pocock and Simon (1975)). This is a form of "covariate adaptive randomisation", the assignment for the current subject depends inter alia on (i) all previous subjects' treatment assignments, (ii) all previous subjects' patterns of prognostic factors, and (iii) the current subject's pattern of prognostic factors.

Treatment assignment by minimization may be useful in smaller trials, when the number of strata is large relative to the sample size, and/or when balance of prognostic factors is judged to be critically important. [See ralloc for a more common method of randomisation using randomly permuted blocks and stratification.]


+------+ ----+ Main +-------------------------------------------------------------

filestub(filenamestub) specifies the prefix of the names of 2 files that rct_minim will create on its first invocation and use on each subsequent treatment assignment.

The first file will be named filenamestub_rand.dta; for each subject it stores the treatment assignment, the factor levels, a system-generated _SeqNum variable giving the sequential number of that subject's allocation, and a system-generated binary variable, _minim, indicating whether (1=yes) or not (0=no) the minimising algorithm was invoked for that subject (see option delay below).

The second file will be named filenamestub_factbal.dta; it stores summary count data on the distribution of treatment assignments and prognostic factor levels in a layout similar to Table 1 of Pocock and Simon. Data from this file are used within rct_minim to construct a factor balance matrix.

nt(#) specifies the number of treatment groups; # must be at least 2.

nf(#) specifies the number of prognostic factors; # must be at least 1.

nl(#1 #2 ...) specifies the number of levels of factor1 factor2 etc; # must be at least 2 for each factor. Separate the #s by one or more spaces.

pchoice(a|b|c) specifies how to calculate probabilities that will determine the extent of the bias in treatment assignments. Minimization seeks to assign a treatment based on minimising the prognostic factor imbalance. This imbalance is reflected in function Di that measures the extent of variation across treatments for levels of factor i. By default, rct_minim specifies Di as the range in the counts of each level of factor i across treatments (see option mchoice below for alternative methods of measuring imbalance in factors), and then calculates Gk, a sum (perhaps weighted) of the Di for each treatment k (k = 1..nt). We may then deterministically assign the subject to the treatment that will minimise G, or, perhaps in an effort to better protect the blinding, assign the subject to treatments in a random fashion following an empirical probability distribution. This distribution will of course assign more probability to the treatment minimizing G. Pocock and Simon discuss 3 methods, denoted "a", "b" and "c" for setting up the probability distribution (see section 3.3 of their paper).

Method a specifies p as the probability for the assignment to the treatment with the lowest value of G, and pk = (1-p)/(nt-1) for every other treatment (k = 2...nt) where k is ordered for increasing values of Gk. If p = 1 then the assignment is automatically to the treatment minimizing G. If p = 1/nt then each treatment has equal probability of being assigned. Commonly, p = 2/3 is chosen as a compromise between maintaining the blinding and affording a bias in the assignments to achieve factor balance.

Method b specifies q as some constant such that the probability distribution takes account of the ranking of Gk for all k (and not just for k = 1 as is the case in Method a). pk = q - [2k((nt*q)-1)/(nt(nt+1))] (k = 1...nt). Pocock and Simon give an example using q = 1/2 in a 4 treatment trial, yielding p1 = 0.4, p2 = 0.3, p3 = 0.2 and p4 = 0.1. That is, the subject will be assigned to the treatment for which G is minimized with probability 0.4, to the treatment for which G is next in ordered value with probability 0.3 and so on.

Method c specifies t as some constant such that the probability distribution takes account of the actual value of Gk for all k (and not just for the ranking of Gk as is the case in Method b). The higher the value of t the more bias in treatment assignment. Under this method pk = (1/(nt - t)) * [1 - (t*Gk/sum(Gk)] (k = 1...nt).

The three methods and their associated probability distributions do not apply to the first subject's treatment assignment. This is determined by simple randomisation with assignment to each group equally likely.

+---------+ ----+ Options +----------------------------------------------------------

p(#) specifies value of p when pchoice(a) has been chosen. # must lie between 1/nt and 1.

q(#) specifies value of q when pchoice(b) has been chosen. # must lie between 1/nt and 2/(nt-1).

t(#) specifies value of t when pchoice(c) has been chosen. # must lie between 0 and 1.

mchoice(string) specifies the method of measuring the imbalance in prognostic factors across treatments. The default is range. Alternatives are var (variance of the counts within a factor level across treatments), sd (standard deviation of the counts), and thresh which signals that a bias in treatment assignment will only proceed if the imbalance in the range of counts exceeds a specified limit.

limit(#) specifies the maximum acceptable (integer) imbalance in prognostic factor levels before a bias in treatment assignment (designed to correct the imbalance) will be invoked. Used with option mchoice(thresh). Default is 1.

treatvar(varname)} specifies the name of the treatment group variable; default is "_group".

factnames(name1 name2...) specifies the names of the prognostic factors; default is "factor1", "factor2" etc

pattern(#1 #2 ...) specifies this subject's levels on each prognostic factor. If pattern is not specified the user is prompted to enter the levels one factor at a time at the cursor. This is simply a convenience feature, as the factor levels may be the only option to change for each subject.

w(#1 #2...) specifies the relative importance weights for each prognostic factor. These are used in the linear combination of the Di to form the Gk. Higher relative weights are given to factors for which an imbalance would be most unwelcome. The #i should each exceed 0.

delay(#) specifies that the first # subjects are allocated treatments purely at random (with equal probabilities) - the minimisation algorithm is not used for these subjects. [Note that the first subject is always allocated his/her treatment at random, since no factor balance matrix yet exists.] The default is delay(1), implying that the minimisation algorithm will be used for the second and subsequent subjects.

warn specifies that a user confirmation will be required between re-display of the command and the actual treatment assignment; by default no warning is given. Because sequential invocations of rct_minim may occur after some time has elapsed, it is important for the integrity of the study design that certain options are specified consistently, especially filestub, nt, nf and nl. On each invocation rct_minim saves two characteristics to the data files. The first, named _dta[TD_n] (where n is the sequential number of the current subject), stores the time and date of the assignment. (See also Note below). The second characteristic, named _dta[minim_n] stores the command and options that were issued. Specifying warn causes rct_minim to re-display the current command and also the contents of _dta[TD_n-1] and of _dta[alloc_n-1] (that is, the command as issued for the previous assignment) so that the user can compare these and decide whether or not to proceed with the current randomisation. This is in addition to other error traps within the program.

Note: The characteristic _dta[TD_n] stores the time and date of the assignment. rct_minim uses the date and time, in that order, concatenated and stripped of any non-numeric characters to form the seed for the current assignment. (This seed is also displayed when option showdetail is specified.)

showdetail specifies that detailed output is displayed. The default is minimal output, but it would be prudent to both open a log file and specify showdetail for each treatment assignment. showdetail will cause the following to be displayed:

the seed (set from the date and time) the method chosen for measuring imbalance in prognostic factors the weight vector the status of the progostic factor balance matrix from the previous assignment the sequential number of the subject about to be assigned treatment the status of the progostic factor balance matrix for each possible treatment assignment for the current subject the values of weighted G for each treatment group the values of weighted G for each treatment group, sorted in ascending order (with ties broken at random) the smallest value of G and the treatment group it represents the random number u used to determine the actual treatment allocation the cumulative probability distribution (set up by either p, q or t); the value of u with respect to this distribution determines the assignment. the final treatment group assignment the updated prognostic factor balance matrix


Basic setup for 2-arm trial with 3 prognostic factors; the first subject is at level 1 for factor1, level 3 for factor2, and level 2 for factor3. The second subject is at level 2 for each factor. Use the default range method to measure imbalance.

. rct_minim, filestub(my_trial) nt(2) nf(3) nl(2 4 3) pchoice(a) p(.66667) showdet warn pattern(1 3 2) . rct_minim, filestub(my_trial) nt(2) nf(3) nl(2 4 3) pchoice(a) p(.66667) showdet warn pattern(2 2 2)

3-arm trial with 2 user-named prognostic factors, sex has 2 levels, age_group has 5 levels; no warnings and no detail displayed; program will request current subject's levels on each factor

. rct_minim, filestub(your_trial) nt(3) nf(2) factnames(sex age_group) nl(2 5) pchoice(a) p(.75)

Same design as previous example but this time, in an effort to better protect the blind, delay the minimization process until the 11th subject is randomized; the first 10 subjects will have their treatments allocated at random.

. rct_minim, filestub(her_trial) nt(3) nf(2) factnames(sex age_group) nl(2 5) pchoice(a) p(.75) delay(10)

Mimic example from section 3.4 of Pocock and Simon. Ensure that files pocock_simon_v3_rand.dta and pocock_simon_v3_factbal.dta (available with the rct_minim package from SSC) are installed in the current path. 50 subjects have already been randomised, whither the 51st?

. rct_minim, filestub(pocock_simon_v3) w(2 1 1) nt(3) nf(3) nl(2 2 3) pchoice(a) p(`=2/3') pattern(1 2 2) treatv(treatment) showd


Pocock, S.J. and Simon, R. [1975]. Sequential treatment assignment with balancing for prognostic factors in the controlled clinical trial. Biometrics 31, 103-115.


Thanks to Kit Baum, Boston College Economics and DIW Berlin, for suggesting some useful Mata code. Thanks also to Tom Sullivan, DMAC, University of Adelaide, for helping test and debug rct_minim.


Philip Ryan Data Management & Analysis Centre Discipline of Public Health Faculty of Health Sciences University of Adelaide South Australia

See also

STB: ralloc in STB-54 sxd1.2, STB-50 sxd1.1, STB-41 sxd1 SJ: ralloc in SJ 8(4):594, SJ 8(1):146