Artbin: Extended Sample Size For Randomized Trials With Binary Outcomes
Artbin: Extended Sample Size For Randomized Trials With Binary Outcomes
Artbin: Extended Sample Size For Randomized Trials With Binary Outcomes
Abdel G. Babiker
MRC Clinical Trials Unit
University College London
London, U.K.
[email protected]
Abstract. We describe the command artbin, which offers various new facilities for
the calculation of sample size for binary outcome variables that are not otherwise
available in Stata. While artbin has been available since 2004, it has not been
previously described in the Stata Journal. artbin has been recently updated
to include new options for different statistical tests, methods and study designs,
improved syntax, and better handling of noninferiority trials. In this article, we
describe the updated version of artbin and detail the various formulas used within
artbin in different settings.
Keywords: st0013_3, artbin, sample size, power, binary outcome, randomized
clinical trial, superiority trial, noninferiority trial
1 Introduction
Sample-size calculation is essential in the design of a randomized clinical trial to ensure
that there is adequate power to evaluate treatment. It is also used in the design of
randomized experiments in other fields such as education, international development
(Attanasio, Kugler, and Meghi 2011), and criminology (Braga et al. 1999). It can also
be used in the design of nonrandomized comparative studies (Quigley et al. 2019).
In Stata, several standard sample-size calculations are available in the inbuilt power
family. More-advanced sample-size calculations are provided in the Analysis of Re-
sources for Trials (ART) package (Barthel, Royston, and Babiker 2005; Barthel et al.
2006; Royston and Barthel 2010). ART is primarily aimed at trials with a time-to-event
outcome, but it also includes the command artbin for trials with a binary outcome.
artbin differs from the official power command by allowing many statistical tests, such
as score, Wald, conditional, and trend across K groups, and by offering calculations
under local or distant alternatives with or without continuity correction.
The calculations in artbin are based on a set of anticipated probabilities of the
binary outcome, one in each treatment group. If the unknown probabilities of the binary
outcome equal the anticipated probabilities, then artbin tells us the power achieved
for a specified sample size or the sample size required to achieve the specified power.
The basic idea of sample-size calculation with a binary outcome is well known. We
define the power 1 − β to be the probability of rejecting the null hypothesis at the
two-sided α level of significance.
In a two-group superiority trial, the null hypothesis is that the outcome probabilities
in the two groups are equal and the alternative hypothesis is that they take the unequal
anticipated probabilities π1a and π2a . If the trial has equal sample sizes n in each group,
then a popular formula for the total sample size required is
n p p o2
z1−α/2 2π a (1 − π a ) + z1−β π1a (1 − π1a ) + π2a (1 − π2a )
2n = 2
(π2a − π1a )2
where zc = Φ−1 (c) is the standard normal deviate and π a = (π1a + π2a )/2 (Julious and
Campbell 2012). Extensions are well known for unequal sample sizes.
However, several complications arise that are tackled by artbin. Some trials have
more than two groups, and in these cases we may test for trend across the groups or for
heterogeneity between the groups. There are variants of the sample-size formulas for
different versions of the test applied to the data (for example, Pearson’s χ2 or Wald),
and there are “local” variants that are valid only when the treatment effect is small.
A loss to follow-up option is useful for the replication of sample-size calculations, as
advocated by Clark, Berger, and Mansmann (2013).
Further, some two-group trials are noninferiority trials, in which the null hypothesis
is that the experimental treatment is no worse than the control treatment by a prespec-
ified amount m, termed the margin. They are used when the experimental treatment
is not expected to be superior, but they do have other benefits, such as being cheaper,
less toxic, or easier to administer, for example. Substantial-superiority trials are now
increasingly used, especially in vaccine trials, where the null hypothesis states that the
experimental treatment is better than the control treatment by at least m (see Krause
et al. [2020]).
The latest upgrade of artbin substantially improves the original version released in
2004. The option to specify a margin for noninferiority or substantial-superiority trials
has been included to enable sample-size and power calculations for more-complex two-
group trials. New options for statistical tests and methods are now available, such as the
Wald test, which is commonly used for sample-size calculation in noninferiority trials in
26 Sample size with binary outcomes
medicine. The syntax and output have been improved, with more options available and
clearer output. artbin does not require the anticipated event probabilities to be the
same in the two groups for noninferiority or substantial-superiority trials, unlike any
other software packages currently available in Stata. Previous users of artbin will need
to alter existing artbin code to accommodate the changes. Please see the description
of what has changed (appendix 1) for further details.
This article has three aims. First, it clearly lays out the scope of the artbin package
and its dialog boxes and exemplifies its use. Second, it describes the updates made.
Third, it clarifies the formulas used.
The article comprises a description of the new syntax (section 3.1), illustrative ex-
amples (section 3), a description of the updated menus and dialogs (section 4), details
of the methods used (section 5), a description of how the software has been tested
(section 6), and conclusions (section 7).
artbin calculates the power or total sample size for various tests comparing K
anticipated probabilities. Power is calculated if n() is specified; otherwise, total sam-
ple size is estimated. artbin can be used in designing superiority, noninferiority, and
substantial-superiority trials.
artbin makes comparisons on the scale of difference in probabilities. The results
on other scales, such as odds ratios, will be very similar for superiority trials but po-
tentially very different for noninferiority and substantial-superiority trials (Quartagno
et al. 2020).
In a multigroup trial, artbin is based on a test of the global null hypothesis that
the probabilities are equal in all groups. The alternative hypothesis is that there is a
difference between two or more of the groups.
In a two-group superiority trial, artbin is based on a test of the null hypothesis that
the probabilities in the two groups are equal. The alternative hypothesis is that they
take unequal values, such that the experimental treatment is better than the control
treatment.
In a noninferiority trial, artbin is based on a test of the null hypothesis that the
experimental treatment is worse than the control treatment by at least a prespecified
Marley-Zagar et al. 27
amount, termed the margin. artbin supports the design of more-complex noninferiority
trials in which π1a and π2a are unequal. Substantial-superiority trials are increasingly
used; here the null hypothesis is that the experimental treatment is better than the
control treatment by the margin at most.
To minimize the risk of error in two-group trials, the user is advised to identify
whether the trial outcome is favorable or unfavorable. By default, artbin infers
favorability status from the pr() and margin() options. If π2a > π1a + margin(), the
outcome is assumed to be favorable; otherwise, it is assumed to be unfavorable.
2.2 Options
pr(#1 . . . #K) specifies the anticipated outcome probabilities in the groups that will be
compared. #1 is the anticipated probability in the control group (π1a ), and #2, . . . ,
#K are the anticipated probabilities in the treatment groups (π2a , . . . , πK
a
). pr() is
required.
margin(#) is used with two-group trials and must be specified if a noninferiority or
substantial-superiority trial is being designed. The default is margin(0), denoting
a superiority trial. If the event of interest is unfavorable, the null hypothesis for all
of these designs is π2 − π1 ≥ m, where m is the prespecified margin. The alternative
hypothesis is π2 − π1 < m. m > 0 denotes a noninferiority trial, whereas m < 0
denotes a substantial-superiority trial. On the other hand, if the event of interest
is favorable, the above inequalities are reversed. The null hypothesis for all of these
designs is then π2 − π1 ≤ m, and the alternative hypothesis is π2 − π1 > m. m < 0
denotes a noninferiority trial, while m > 0 denotes a substantial-superiority trial.
The hypothesized margin for the difference in anticipated probabilities, #, must lie
between −1 and 1.
unfavourable | unfavorable or favourable | favorable are used with two-group trials
to specify whether the outcome is unfavorable or favorable. If either option is used,
artbin checks the assumptions; otherwise, it infers the favorability status. American
and English spellings are both allowed.
power(#) specifies the required power of the trial at the alpha() significance level and
computes the total sample size. power() cannot be used with n(). The default is
power(0.8).
n(#) specifies the total sample size available and computes the corresponding power.
n() cannot be used with power(). The default is to calculate the sample size for
power 0.8.
aratios(aratio_list) specifies the allocation ratios. The allocation ratio for group k
is #k, k = 1, . . . , K; for example, aratios(1 2) means that two participants are
randomized to the experimental group for each one randomized to the control group.
With two groups, aratios(#) is taken to mean aratios(1 #). The default is equal
allocation to all groups.
28 Sample size with binary outcomes
local specifies that the calculation should use the variance of the difference in propor-
tions only under the null. This approximation is valid when the treatment effect is
small. The default uses the variance of the difference in proportions both under the
null and under the alternative hypothesis. The local method is not recommended and
is only included to allow comparisons with other software. The Wald test inherently
allows for distant alternatives, so wald and local cannot be used together.
noround prevents rounding of the calculated sample size in each group up to the nearest
integer. The default is to round.
force can be used with two-group studies to override the program’s inference of the
favorable or unfavorable outcome type. This may be needed, for example, when
designing an observational study with a harmful risk factor; the favorability types
would be reversed and the force option applied.
3 Examples
3.1 Binary outcome and comparison with published sample size
We reproduce the sample-size calculation in Pocock (1983) for a two-group superiority
trial comparing the efficacy of therapeutic doses of Anturan in patients after a myocar-
dial infarction with the placebo standard treatment. The primary outcome was death
from any cause within one year of first treatment. The control (placebo) group was
anticipated to have a 10% probability of death within one year and the Anturan treat-
ment group a 5% probability, with the trial powered at 90%. The patient outcome was
binary: either failure (death in a year) or success (survival). The published sample size
was 578 patients per group (1,156 patients in total).
In the below artbin example, we do not specify in the syntax whether the outcome
is favorable or unfavorable; rather, we let the program infer it. The aim of a clinical
trial is always to improve patient outcome. Therefore, because the experimental-group
anticipated probability (π2a = 0.05) is less than the control-group anticipated probability
(π1a = 0.1), it can be inferred that the outcome is unfavorable (that is, the trial is aiming
to reduce the probability of the event occurring, in this case, death).
30 Sample size with binary outcomes
The artbin output table shows the trial setup information, including the study
design, statistical tests, and methods used. The hypothesis tests are shown with the
calculated sample size and events based on the selected power. A total sample size of
1,156 participants is required, as per the published sample size given by Pocock (1983).
The same result is achieved by the command artbin, pr(0.9 0.95) alpha(0.05)
power(0.9) wald, assuming a favorable outcome (survival) instead. The Wald test
is used instead of the default score test because Pocock used the sample estimate in
the method of estimating the variance of the difference in proportions under the null
hypothesis H0 .
Marley-Zagar et al. 31
The noninferiority trial required a total sample size of 399 (133 in control and 266
in treatment), assuming 20% of patients were not assessable in primary analysis. When
the STREAM trial concluded, it estimated that a shorter, more intensive treatment for
multidrug-resistant tuberculosis was only 1% less effective than the lengthier treatment
recommended by the World Health Organization and demonstrated significant evidence
of noninferiority.
artsurv and artpep are described in Barthel, Royston, and Babiker (2005) and
Royston and Barthel (2010), respectively.
Compared with previous versions, new options such as Margin, Favourable or Un-
favourable, Loss to follow-up, Score test, Wald test, Continuity correction, and Do not
round have now been included within an updated layout design.
Figure 1 illustrates the dialog box for binary outcomes. The artbin dialog box allows
the user to input the parameters for the trial setup. Options are deselected based on
the user’s choices; for example, if the Conditional test (Peto) checkbox is selected, then
the Wald test checkbox will be grayed out.
The dialog box output is the same as the output in section 3.5 and corresponds to
the inputs shown in the figure 1 menu box. The detailed display enables the user to
check that the trial design has been inputted correctly.
36 Sample size with binary outcomes
Wald Qw = N U0 A
b −1 U χ2K−1 N Cχ2 (K − 1, λ)
A = N var
b c (U|Ha ) λ = N µ0 A−1 µ
K groups, trend
Score Tu = c0 U N(0, c0 Vu c/N ) N(c0 µ, c0 Vu c/N )
local ck = rk (dk − d1 )
where d1 , d2 , . . . , dk are
doses for groups 1, 2, . . . , k
Score same same N(c0 µ, c0 Ac/N )
distant
Wald same N(0, c0 Ac/N ) N(c0 µ, c0 Ac/N )
Conditional Tc = c0 X/M N(0, c0 Vc c/M ) N(c0 Vc η, c0 Vc c/M )
local
The following statistics are approximated as χ2K−1 under the null. Let xα (m) be the
(1−α)100th percentile of the (central) χ2 distribution with m degrees of freedom. Then,
for a test statistic for which we write SN to emphasize its dependence on sample size
N , power is related to the total sample size N by the equation
The distributions under the alternative hypothesis are all of the form cX, where c is
a constant depending on N and X is a noncentral χ2 random variable with K − 1
degrees of freedom and noncentrality parameter λ depending on N and the anticipated
probabilities. Then (1) gives the key equation
where FK−1,λ (x) is the cumulative distribution function of the noncentral χ2 distribu-
tion with K − 1 degrees of freedom and noncentrality parameter λ. We can directly
evaluate this for power given N . Solving for N given power involves iterative methods
in some cases.
These statistics SN are all approximated as N(0, σ02 /N ) under H0 and N(µ1 , σ12 /N )
under Ha , where σ1 depends on the anticipated probabilities. Let za denote the (1 −
a)100th percentile of the standard normal distribution, where, for a one-sided test,
a = α, and for a two-sided test, a = α/2. Then (1) gives the key equation
√ !
√ µ1 − za σ0 / N
power = Pr SN > za σ0 / N |Ha = Φ √
σ1 / N
6 Software testing
artbin is for use in the design of randomized trials, so we have tested it extensively. The
program was modified by Ella Marley-Zagar and tested by Ella Marley-Zagar, Ian R.
White, Patrick Royston, and Abdel G. Babiker. We report the testing methods below
to verify both the sample-size and the power results. We ran the test scripts with the
default variable type (set type) as float and as double.
Marley-Zagar et al. 39
1. We compared results for noninferiority trials with those given by Julious and
Owen (2011), Blackwelder (1982), Pocock (2003), and the online calculator Sealed
Envelope (2012). Exact agreement was achieved.
2. We compared results for a superiority binary outcome with those given by Pocock
(1983) and the online calculator Sealed Envelope (2012). Exact agreement was
achieved.
3. We tested several scenarios including continuity correction results given by artbin
and those given by the Stata program power. The results from both programs
were in agreement.
4. We checked the results given by artbin using the margin() option against Julious
and Owen (2011). Exact agreement was achieved.
5. The output of artbin was compared with Cytel’s software EAST, which is a so-
phisticated package able to produce sample-size and power calculations for several
binary outcomes in clinical trial settings. We achieved perfect agreement in all
but a handful of cases where the sample size differed by 1, which we believe is due
to the difference in the way the packages round sample size.
6. For the new syntax options, we tested onesided for a one-sided test and ccorrect
to apply a continuity correction.
7. We tested every permutation of two-group and more than two-group and noninfe-
riority, substantial-superiority, and superiority trials with margin, local or distant,
conditional or unconditional, trend, and Wald test options to check that the results
were as expected and that sample size was increased or decreased accordingly.
8. We checked error messages in several impossible cases to ensure that we obtained
error messages as required.
9. We tested the dialog box menu options to verify that the results were as required.
7 Conclusions
We have written artbin to include new syntax with additional options, including ex-
tensions to the tests and methods offered by previous versions of the software. We have
also refreshed the layout of the dialog box for artbin, with mutually exclusive options
grayed out for clarity. The updated artbin program compares well with Stata’s power
program, as well as other commercially available products such as Cytel’s EAST and the
Sealed Envelope Calculator. One of the main features of artbin that sets it apart from
the other available software in Stata is the range of trial types, statistical tests, and
methods that it offers for sample-size calculation. Notably, Stata’s power can provide
sample size for superiority trials only.
As noted in section 2.2, artbin reports power as the probability of rejecting the
null hypothesis in the direction of interest, whereas power reports the probability of
40 Sample size with binary outcomes
8 Acknowledgments
This work was supported by the Medical Research Council Unit Programme number
MC_UU_00004/09. We thank Henry Bern and Tim Morris for their very helpful
comments and for testing the program.
Marley-Zagar et al. 41
. net sj 23-1
. net install st0013_3 (to install program files, if available)
. net get st0013_3 (to install ancillary files, if available)
All the code we used for testing and the output testing files are included in the
package. The files are also available along with the program itself on the GitHub
repository https: // github.com / UCL / artbin.
10 References
Attanasio, O., A. D. Kugler, and C. Meghi. 2011. Subsidizing vocational training for
disadvantaged youth in Colombia: Evidence from a randomized trial. American
Economic Journal: Applied Economics 3: 188–220. https: // doi.org / 10.1257 / app.3.
3.188.
Barthel, F. M.-S., P. Royston, and A. Babiker. 2005. A menu-driven facility for com-
plex sample size calculation in randomized controlled trials with a survival or a
binary outcome: Update. Stata Journal 5: 123–129. https: // doi.org / 10.1177 /
1536867X0500500114.
Box, G. E. P. 1954. Some theorems on quadratic forms applied in the study of analysis
of variance problems, I. Effect of inequality of variance in the one-way classification.
Annals of Mathematical Statistics 25: 290–302. https: // doi.org / 10.1214 / aoms /
1177728786.
Clark, T., U. Berger, and U. Mansmann. 2013. Sample size determinations in origi-
nal research protocols for randomised clinical trials submitted to UK research ethics
committees: Review. BMJ 346: f1135. https: // doi.org / 10.1136 / bmj.f1135.
Farrington, C., and G. Manning. 1990. Test statistics and sample size formulae for
comparative binomial trials with null hypothesis of non-zero risk difference or non-
unity relative risk. Statistics in Medicine 9: 1447–1454. https: // doi.org / 10.1002 /
sim.4780091208.
Fleiss, J. L., A. Tytun, and H. K. Ury. 1980. A simple approximation for calculating
sample sizes for comparing independent proportions. International Biometric Society
36: 343–346. https: // doi.org / 10.2307 / 2529990.
Julious, S. A., and M. J. Campbell. 2012. Tutorial in biostatistics: Sample sizes for
parallel group clinical trials with binary data. Statistics in Medicine 31: 2904–2936.
https: // doi.org / 10.1002 / sim.5381.
Julious, S. A., and R. J. Owen. 2011. A comparison of methods for sample size estima-
tion for non-inferiority studies with binary outcomes. Statistical Methods in Medical
Research 20: 595–612. https: // doi.org / 10.1177 / 0962280210378945.
Krause, P., T. R. Fleming, I. Longini, A. M. Henao-Restrepo, and R. Peto. 2020. COVID-
19 vaccine trials should seek worthwhile efficacy. Lancet 396: 741–743. https: // doi.
org / 10.1016 / S0140-6736(20)31821-3.
Mathai, A., and S. Provost. 1992. Quadratic Forms in Random Variables: Theory and
Applications. New York: Dekker.
McCullagh, P., and J. A. Nelder. 1989. Generalized Linear Models. 2nd ed. London:
Chapman & Hall/CRC.
Nunn, A. J., P. P. J. Phillips, S. K. Meredith, C.-Y. Chiang, F. Conradie, D. Dalai,
A. van Deun, et al. 2019. A trial of a shorter regimen for rifampin-resistant tubercu-
losis. New England Journal of Medicine 380: 1201–1213. https: // doi.org / 10.1056 /
NEJMoa1811867.
Pocock, S. J. 1983. Clinical Trials: A Practical Approach. Chichester, U.K.: Wiley.
. 2003. The pros and cons of noninferiority trials. Fundamental and Clinical
Pharmacology 17: 483–490. https: // doi.org / 10.1046 / j.1472-8206.2003.00162.x.
Quartagno, M., A. S. Walker, A. G. Babiker, R. M. Turner, M. K. B. Parmar, A. Co-
pas, and I. R. White. 2020. Handling an uncertain control group event risk in non-
inferiority trials: Non-inferiority frontiers and the power-stabilising transformation.
Trials 21: 145. https: // doi.org / 10.1186 / s13063-020-4070-4.
Quigley, J. M., J. C. Thompson, N. J. Halfpenny, and D. A. Scott. 2019. Critical
appraisal of nonrandomized studies—A review of recommended and commonly used
tools. Journal of Evaluation in Clinical Practice 25: 44–52. https://doi.org/10.1111/
jep.12889.
Marley-Zagar et al. 43
Rencher, A. C., and G. B. Schaalje. 2008. Linear Models in Statistics. 2nd ed. Hoboken,
NJ: Wiley.
Royston, P., and F. M.-S. Barthel. 2010. Projection of power and events in clinical trials
with a time-to-event outcome. Stata Journal 10: 386–394. https://doi.org/10.1177/
1536867X1001000306.
Sealed Envelope. 2012. Power calculator for binary outcome non-inferiority trial. https:
// www.sealedenvelope.com / power / binary-noninferior / .
Welch, B. L. 1938. The significance of the difference between two means when the
population variances are unequal. Biometrika 29: 350–362. https://doi.org/10.2307/
2332010.
Yuan, K.-H., and P. M. Bentler. 2010. Two simple approximations to the distributions
of quadratic forms. British Journal of Mathematical and Statistical Psychology 63:
273–291. https: // doi.org / 10.1348 / 000711009X449771.
Mahesh Parmar is a professor of medical statistics and epidemiology and the director of the
MRC Clinical Trials Unit at University College London and the Institute of Clinical Trials
and Methodology at University College London. The unit he directs is at the forefront of
resolving internationally important questions, particularly in infectious diseases, cancer, and
more recently neurodegenerative diseases, and it also aims to deliver swifter and more effective
translation of scientific research into patient benefits by carrying out challenging and inno-
vative studies and by developing and implementing methodological advances in study design,
conduct, and analysis. Examples of his methodological contributions include the development
and implementation of the MAMS platform and DURATIONS designs.
Abdel Babiker is a professor of epidemiology and medical statistics at the MRC Clinical Trials
Unit at University College London. He works on clinical trials in infectious diseases, including
HIV, influenza, and COVID-19, and associated methodology.
New syntax
Some improvements have been made to artbin. The user will need to alter previous
coding using artbin to accommodate the following changes.
The syntax for artbin has been updated to include a margin() option for two-
group trials. For a noninferiority or substantial-superiority trial, the program will
use pr(p1 p2) and the new option margin(). For example, in the previous version
(artbin version 1.1.2), the syntax artbin, pr(.2 .3) ni(1) would now be speci-
fied as artbin, pr(.2 .2) margin(.1). The option ni() is now redundant.
Previously, local was taken as the default in superiority trials. Now it is distant;
the distant() option has been replaced by local in the syntax. Previous syntax (up
to version 1.1.2) will need to be altered so that artbin, pr(.1 .2) distant(1) will
now be artbin, pr(.1 .2) and artbin, pr(.1 .2) distant(0) will now be artbin,
pr(.1 .2) local, for example.
The user may identify whether the outcome is favorable or unfavorable in the con-
text of a two-group trial. With this information plus the margin, the program will then
determine the type of trial (that is, noninferiority, substantial superiority, or superi-
ority). If the user does specify favorable or unfavorable, the program will check the
assumptions. If not, then the program will infer it. The force option can be used to
override the program’s inference of the favorability status, for example, in the design of
observational studies.
Marley-Zagar et al. 45
The wald option has also been included for the Wald test as an alternative to the
default score test.
Sample size per group is now reported, and rounding up to the nearest integer is
performed per group. A noround option has been included for the case when the user
does not want artbin to round the calculated sample size up to the nearest integer. A
loss to follow-up option is now available.
The option condit always implies the local option because there is no conditional
distant option available in artbin. If the conditional option is selected, then local will
be used (instead of the default distant).
The allocation ratio reflects the fact that sample size is now rounded upward in each
group rather than overall, and the expected number of events is calculated using the
rounded sample size (unless the noround option for calculated sample size is used).
Earlier versions of artbin required several yes or no options to be specified numer-
ically, for example, onesided(1) or onesided(0). In updating the syntax, we have
enabled the more standard options, for example, onesided and ccorrect, but the nu-
merical version of the syntax is retained if the user wishes to use it.
The number of groups is taken as the number of anticipated probabilities in all cases,
and the ngroups() option is now redundant. The required option pr() now takes a
numlist instead of a string.
Changes have been made to the output table so that results are presented in the
same format whether art2bin was called. Now included in the description table are
whether the trial is noninferiority, substantial superiority, or superiority; the trial out-
come type; the statistical test assumed (including score or Wald); whether local or
distant alternatives were used and the hypothesis tests; and whether the continuity cor-
rection was used. Minor formatting was also made to the existing allocation ratio, alpha,
linear trend output, and version numbering output. Sample size per group is reported,
and the returned values have been streamlined to include only results as opposed to
user-inputted options.
The text output has been changed from p0 and p1 to π1 and π2 . Therefore, the
control-group anticipated outcome probability for noninferiority trials is π1 . The corre-
sponding hypotheses tests (included in the output table) are
H0 : π2 − π1 >= / <= m
Ha : π2 − π1 < / > m
46 Sample size with binary outcomes
The program will now produce error or warning messages for disallowed or uncoded
combinations of options, namely,
Also, an error message will be produced for > 2 groups if the user specifies fewer
numbers in aratios() than in pr().
There is no analytic solution to this equation for K > 2. We consider two ways
to approximate the asymptotic distribution of Qu under Ha in terms of a noncentral
χ2 distribution with K − 1 degrees of freedom and noncentrality parameter λ, whose
cumulative distribution function we denote as FK−1,λ (x).
Local alternative method. If max |πia − πja | is small, the asymptotic distribution of
Qu may be approximated by a noncentral χ2 P with K − 1 degrees of freedom and
noncentrality parameter λ = N µ0 Vu−1 µ = N k µ2k rk /s.
Then the key equation is
Wald test. The Wald test statistic is Qw = N U0 A b −1 U, and the formulas for power
and sample size are like those for the score test but with the covariance matrix
Vu replaced by A. Thus, the asymptotic distribution of Qw is noncentral χ2 with
K − 1 degrees of freedom and noncentrality parameter λ = N µ0 Vu−1 µ.
48 Sample size with binary outcomes
c = (c2 , . . . , cK ) . The mean and variance of T under the null and alternative hypotheses
0
are
Let za denote the (1 − a)100th percentile of the standard normal distribution. For a
one-sided test, let a = α, and for a two-sided test, let a = α/2. The total sample size
to achieve power 1 − β for a distant test is
√ 0 √ 2
za c Vu c + zβ c0 Ac
N=
c0 µ
Conditional test
Some analyses condition on the margins of the contingency table of outcome by treat-
ment group, for example, Fisher’s exact test. For such analyses, a conditional cal-
culation is preferred. As noted in the main text, this PKuses a different score vector
X = (X2 , . . . , XK )0 , where Xk = Yk − rk Y. and Y. = k=1 Yk is the total number of
events.
Let ηk = log{πk /(1 − πk )} − log{π1 /(1 − π1 )} denote the log odds-ratio for the
occurrence of the event in group k relative to group 1, η = (η2 , . . . , ηK )0 . Conditional
on Y. = y. , Y = (Y2 , . . . , YK )0 has a multivariate noncentral hypergeometric distribution
with support
( K
)
X
D= (y2 , . . . , yK ) : 0 ≤ yk ≤ nk , 0 ≤ y. − yk ≤ n 1
k=2
where y1 = y. − yk , η1 = 0, and
PK
k=2
X K nk
P = Π exp(yk ηk )
k=1 yk
{(y2 ,...,yK )D}
Marley-Zagar et al. 49
Denote by e(η) and C(η) the conditional mean and covariance matrix of Y. Differenti-
ating the log of f (y2 , . . . , yK ) in (3) with respect to η yields the score (gradient vector
of the log-likelihood function) for η
def
S(η) = ∂ log{f (y)}/∂η 0 = y − E(Y|y. , η)
the observed minus the (conditionally) expected number of events in groups 2, . . . , K
given y. , η. Under the null hypothesis H0 : η = 0, and conditional on y. , Y has a (cen-
tral) hypergeometric distribution with the elements of the mean vector and covariance
matrix
def
ek (0) = E(Yk |y. , η = 0) = rk y.
(4)
C(0)kl = cov(Yk , Yl |y. , η = 0) = M vkl
def
where
M = y. (N − y. )/(N − 1) (5)
and vkl = rk (δkl − rl ) (McCullagh and Nelder 1989, chap. 7).
The score statistic Qc = S(0)0 C(0)−1 S(0) is a quadratic form based on the score
vector S(0) and its covariance matrix C(0) under the null hypothesis. Denote the kth
element of S(0) by Xk = Yk −rk y. , X = (X2 , . . . , XK )0 , and let Vc be the (K−1)×(K−1)
matrix with elements vkl . Using (4), the score statistic can be written as
√ √
Qc = (X/ M )0 Vc−1 X/ M = X0 Vc−1 X/M
Now let the anticipated value of η be η a with ηka = log{πka /(1 − πka )} − log{π1a /(1 −
for all k. Under a local alternative, the asymptotic distribution of Qc is noncentral
π1a )}
χ with K − 1 degrees of freedom and noncentrality parameter
2
λ = M q(η a )
where q(η) = η 0 Vc η. We therefore have this equation relating power to M and hence
to N :
power = 1 − FK−1,λ {xα (K − 1)/c} (7)
50 Sample size with binary outcomes
Given N , we can compute M from (5) and hence compute power from (7). To
compute N from power, we first use (7) to compute λ. We then solve for N as follows.
Asymptotically, M = T (N − T )/(N − 1), where T = E(Y. ) = N π a is the expected total
number of events. It follows that
(1 − π a )q(η)T 2 − λT + λπ a = 0
For dose–response,
√ Pthe test for √
trend with dose scores d1 , . . . , dK is based on the statistic
Tc = c0 X/ M = k=1 ck Xk / M , where as before c = (c1 , . . . , cK )0 ; ck = rk (dk − d1 );
K
and M = y. (N −y. )/(N −1). The mean and variance of Tc under the null and alternative
hypotheses are
E(Tc |H0 ) = 0; var(Tc |H0 ) = c0 Vc c
√
E(Tc |Ha ) = M c0 Vc η; var(Tc |Ha ) = c0 Vc c
The total sample size to achieve power 1 − β is obtained from
√ 0 √ 2
z a c V c c + z β c0 V c c
M=
c0 V c η
e1a (1 − π
Vn = π e1a )/r1 + π
e2a (1 − π
e2a )/r2
where π
e1a and π
e2a are the values π1a and π2a modified so that π2a − π1a = m. They may be
computed in several ways (Farrington and Manning 1990):
• Score test with local approximation: like the score test, but Va is set to equal
Vn . Unlike in the case of a superiority trial, this approximation is not a simpler
calculation than the more appropriate distant calculation, so it should not be used.
• Wald test: π
e1a = π1a and π
e2a = π2a ; equivalently, Vn = Va .
the conditional test; however, the score test variant is not a conditional method,
because it is based on the risk difference, whereas the conditional test is based on
the odds ratio.
The score test variant is available (but not recommended) by setting the null vari-
ance method using the undocumented option nvmethod(2), where nvmethod(1)
corresponds to the Wald test and nvmethod(3) corresponds to the score test. The
nvmethod() option was used more widely in earlier versions of artbin.
Continuity correction
where Nun is the total unadjusted sample size and c = 1/(r1 r2 |δ − m|) (Fleiss, Tytun,
and Ury 1980).
The continuity-corrected power is estimated by deflating the given sample size Nadj
by a factor of
c c
1− 1−
Nadj 4Nadj
and then using the standard method on the deflated sample size.