*! version 1.0.0 14Nov2025

Title

power abk -- power analysis for a balanced (AB)^k design with multiple cases

Syntax

Compute sample size:

power abk,
power(numlist)
delta(numlist)
phases(numlist)
mobs(numlist)
icc(numlist)
phi(numlist)
[alpha(numlist)
onesided
]

Compute power:

power abk,
n(numlist)
delta(numlist)
phases(numlist)
mobs(numlist)
icc(numlist)
phi(numlist)
[alpha(numlist)
onesided
]

Compute effect size:

power abk,
n(numlist)
power(numlist)
phases(numlist)
mobs(numlist)
icc(numlist)
phi(numlist)
[alpha(numlist)
onesided
]

* n(numlist) total sample size; required to compute power or effect size

* power(numlist) power; required to compute sample size or effect size

* delta(numlist) standardized mean difference between treatment and control phases; required to compute sample size or power

* phases(numlist) number of AB phase repetitions (k; required

* mobs(numlist) number of observations M per phase; required

* icc(numlist) intraclass correlation; required

* phi(numlist) autocorrelation; required

* alpha(numlist) significance level; default is alpha(0.05)

onesided one-sided test; default is two sided

* Specifying a list of values in at least two starred options results in computations for all possible combinations of the values; see numlist

Description

power abk computes power, sample size and effect size for tests that compare treatment and control means in
a balanced (AB)^k design with multiple cases, using the calculations given in Hedges, Shadish, and Batley (2022). In
the balanced (AB)^k design, A refers to a baseline (control or reference) phase, B refers to a treatment
phase, and k indicates the number of times (phases) the AB pair is repeated. During each phase, M measurements are
taken. For example, (AB)^2 indicates an ABAB design in which 4M measurements are taken on each subject. 2M
of these are control measurements and 2M are treatment measurements (i.e., the design is balanced with 2M measurements
in each phase). See the PASS Sample Size Software
entry for greater detail. Also, the paper by Hedges, Shadish, and Batley (2022) comes with an R program. The results produced by power abk are identical to those produced by the R code.

Options

n(numlist) specifies the total number of subjects in the study to be used for power or effect-size determination. If n() and
delta() are specified, the power is computed. If n() and power() are specified, the minimum effect size
(standardized mean difference) that is likely to be detected in a study is computed.

power(numlist) sets the power of the test; required to compute sample size or effect size.

delta(numlist) specifies the standardized mean difference between the control-phase mean and the treatment-phase mean; required
to compute sample size or power.

phases(numlist) the number of times (phases) the AB pair is repeated; phases() is required.

mobs(numlist) the number of measurements taken in each phase; mobs() is required.

icc(numlist) the intraclass correlation -- the proportion of the total variance of an observation that is between subjects; mobs()
is required.

phi(numlist) the autocorrelation between measurements of an individual within each phase; phi() is required.

alpha(numlist) significance level. The default is alpha(0.05).

onesided indicates a one-sided test. The default is two sided.

Examples

Computing sample-size:

Compute the total sample size required to detect a standardized mean difference between the control and treatment phases of 0.75,
assuming there will be two phases (ABAB), with three measurements taken in each phase, an ICC of 0.5 and autocorrelation of 0.5.
A two-sided test with a 5% significance level will be used, and power is set to 80%.

. power abk, phases(2) mobs(3) delta(0.75) icc(0.5) phi(0.5) alpha(0.05) power(0.80)

Same as above, but we now add an alpha level of 0.01 and an additional power of 0.90 and graph the results

. power abk, phases(2) mobs(3) delta(0.75) icc(0.5) phi(0.5) alpha(0.05 0.01) power(0.80 0.90) graph

Computing power:

Suppose we have a sample of 3 subjects, and we want to compute the power of a two-sided test to detect an standardized mean difference between control-phase
and treatment-phase means of 0.75; where three measurements will be taken in each of the 2 phases. The ICC and autocorrelation are both set to 0.5 and alpha is 0.05

. power abk, n(3) phases(2) mobs(3) delta(0.75) icc(0.5) phi(0.5) alpha(0.05)

We assess power for a range of sample sizes and graph the results

. power abk, n(2(1)15) phases(2) mobs(3) delta(0.75) icc(0.5) phi(0.5) alpha(0.05) graph

Same as above but add an additional alpha of 0.01

. power abk, n(2(1)15) phases(2) mobs(3) delta(0.75) icc(0.5) phi(0.5) alpha(0.05 0.01) graph

Computing effect size:

We are interested in finding the standardized mean difference between the 2 control and the treatment phases with a sample size of 3
subjects, each getting measured 3 times in each phase. The ICC and autocorrelation are both set to 0.5, power to 80% and alpha to 0.05.

. power abk, n(3) phases(2) mobs(3) icc(0.5) phi(0.5) alpha(0.05) power(0.80)

Same as above but we add power of 90% and alpha of 0.01

. power abk, n(3) phases(2) mobs(3) icc(0.5) phi(0.5) alpha(0.05 0.01) power(0.80 0.90)

We now determine effect sizes for a range of sample sizes and graph the results (note: this may take a minute or two to compute)

. power abk, n(3(1)10) phases(2) mobs(3) icc(0.5) phi(0.5) alpha(0.05) power(0.80) graph

Stored results

power abk stores the following in r():

Scalars

r(N) computed sample size

r(power) power for the computed sample size

r(beta) probability of a type II error

r(delta) effect size

r(alpha) significance level

r(phases) number of AB pairs

r(mobs) number of measurements taken in each phase

r(icc) intraclass correlation

r(phi) autocorrelation

r(onesided) 1 for a one-sided test, 0 otherwise

r(separator) number of lines between separator lines in the table

r(divider) 1 if divider is requested in the table, 0 otherwise

Macros

r(type) test

r(method) abk

r(direction) upper or lower

r(columns) displayed table columns

r(labels) table column labels

r(widths) table column widths

r(formats) table column formats

r(solve_for) N or power or delta

Matrices

r(pss_table) table of results

References

Hedges, L. V., Shadish, W. R., & P. N. Batley. 2023.
Power analysis for single-case designs: Computations of (AB)k designs.
Behavior Research Methods
55: 3494–3503

Citation of power abk

power abk is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Linden A. (2025). POWER ABK: Stata module to perform power analysis for a balanced (AB)^k design with multiple cases

Author

Ariel Linden

President, Linden Consulting Group, LLC

alinden@lindenconsulting.org

Also see

Online: power