help rct_minim

Title

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

Syntax

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

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

sleep(#) introduce a pause before program ends

* one of p, q or t must be specified

Description

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.]

rct_minim sets the random number generator to kiss32

Options

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. We consider in turn what would happen if the subject currently facing
randomisation were to be assigned to each of the nt treatments. For the first treatment, for the first factor,
at just the level of that factor the subject enjoys, we count the numbers of randomisations to each of the
nt treatments that would result if that subject were assigned to the first treatment, and calculate the
range of those nt counts. Do the same for each factor in turn, yielding nf ranges for the first treatment.
Then repeat this process for the second treatment, and so on. (See option mchoice below for alternative methods
of measuring imbalance in factors). We then calculate Gk (k = 1..nt), a sum (perhaps weighted) of the
nf ranges for each treatment. Gk measures the imbalance in treatment allocations at the appropriate
factor levels were treatment k assigned. 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. (Note: Section 3.4 of Pocock and Simon has a simple worked example that
makes this seemingly complex process much easier to follow. Their example is reproduced in the Examples section
at the end of this help file, wherein use of the showdetail option will be of great assistance.)

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

sleep(#) specifies that a pause of # milliseconds will be introduced into the program before it ends. This would
rarely be specified but may be useful in the context of an automated simulation when very rapid repeated invocations of
rct_minim might occur within the 1 second spacing of the seed being set (see Note under option warn above). In that
circumstance the same numeric seed would be set for several/many randomisations with potentially unhappy results.
Specifying # > 1000 will avoid this. The default is sleep(0), implying that no pause is introduced before the program ends.

Examples

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? First, we reproduce TABLE 1, Section 3.4, of Pocock and Simon:

. use pocock_simon_v3_rand, clear

. reshape long factor, i(_SeqNum) j(level)

. table treatment factor level, row col

--------------------------------------------------------------------------------------------------
| level and factor
| ------------ 1 ----------- ------------ 2 ----------- ------------ 3 -----------
treatment | 1 2 3 Total 1 2 3 Total 1 2 3 Total
----------+---------------------------------------------------------------------------------------
1 | 9 8 17 8 9 17 8 4 5 17
2 | 10 7 17 6 11 17 8 5 4 17
3 | 9 7 16 7 9 16 8 3 5 16
|
Total | 28 22 50 21 29 50 24 12 14 50
--------------------------------------------------------------------------------------------------

Now randomise the 51st subject:

. 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

Reference

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

Acknowledgements

Thanks to Kit Baum, Boston College Economics and DIW Berlin, for suggesting some useful Mata code.

Thanks also to Tom Sullivan, University of Adelaide, for helping test and debug rct_minim and to
Ben Leiby and Nooreen Dabbish at TJU, Philadelphia, who spotted and helped correct a bug involving the random seed.
Karla Hemming at the University of Birmingham, UK, alerted me to the potential for duplicated seeds using rct_minim
in simulations. I thank her also for helping to clarify the text in the help on option pchoice() above.

Author

Philip Ryan

Emeritus Professor

School of Public Health

Faculty of Health Sciences

University of Adelaide

South Australia

philip.ryan@adelaide.edu.au

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