Using Mata to accelerate the familywise error rate calculation for multi-arm multi-stage clinical trial designs

More efficient trial designs are needed to combat the increasing cost of drug development. A class of trial designs that can help to accelerate this process, known as multi-arm multi-stage (MAMS) designs, has been proposed and used to much effect in oncology. To facilitate the design of these trials evaluating time to event outcomes, the nstage program was introduced for Stata in 2009. This program provides an estimate of the sample size requirement together with estimates of the pairwise operating characteristics and stage durations. An important quantity in a multi-arm trial is its familywise error rate (FWER), that is, the probability of incorrectly recommending at least one ineffective treatment at the end of a trial. Strong control of the FWER is often a requirement in any confirmatory multi-arm study. A subroutine was therefore recently added to nstage to calculate the FWER of a MAMS design by simulating trial-level data, specifically the z-test statistics for the treatment effect in each arm at each stage of the study. The calculation is relatively quick, taking less than 10 seconds for designs with up to 6 arms and 5 stages. However, it can be made more efficient by performing the calculation in Mata. This involves the use of three-dimensional matrices that, despite being unable to be used directly in Mata, can be generated through the use of pointers. The speed of the Mata calculation over that using only Stata increases with the number of arms and stages, with almost a 50% reduction in computing time for a 6-arm 5-stage design. Although just a few seconds are saved for a single design, the cumulative savings in time are considerable when searching over multiple designs to find the one most suitable or most efficient for the MAMS trial in question. In this talk, I describe the calculations in Stata and Mata and compare their speeds for designs with various numbers of arms and stages. The use of pointers in the FWER calculation in Mata is described, and I discuss their advantages and potential use in other areas.