*! version 1.0.0 05Aug2022

Title

power pairspec -- Power and sample-size analysis for specificity between two diagnostic tests in a paired-sample

Syntax

Compute sample size

power pairspec spec1 spec2
[, power(numlist) alpha(numlist) prev(numlist) onesided
graph[(graphopts)] ]

Compute power

power pairspec sens1 sens2
[, n(numlist) alpha(numlist) prev(numlist) onesided
graph[(graphopts)] ]

where spec1 is the specificity of the first diagnostic test and
spec2 is the specificity of the second diagnostic test.
spec1 and spec2 may each be specified either as one
number or as a list of values in parentheses (see numlist).

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

* power(numlist) power; default is power(0.80)

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

* prev(numlist) prevalence rate of disease in the population under study; default is prev(0.50)

onesided one-sided test; default is two sided

graph[(graphopts)] graph results; see [PSS-2] power, graph

init(#) initial value of the estimated power; default is init(10)

* Specifying a list of values in at least two starred options, or
two command arguments, or at least one starred option and one argument
results in computations for all possible combinations of the values; see
numlist.

Description

power pairspec computes sample size or power for specificity between two diagnostic tests in paired data,
accounting for the prevalence of the disease in the clinical population. Specificity is the ability
of a test to correctly identify non-diseased patients.

power pairspec computes sample size according to Miettinen (1968), then implements the naive prevalence inflation method
introduced by Obuchowski and Zhou (2002). Li and Fine (2004) found this method (which they refer to as "Method 0") to be a
useful approximation to exact sample-size calculations based on unconditional power, which are more computationally intensive.

Options

alpha(numlist) sets the significance level of the test. The
default is alpha(0.05).

power(numlist) specifies the desired power at which sample size is to be computed.
The default is power(0.80). If power() is specified in conjunction with n(),
then the actual power of the test is presented.

n(numlist) specifies the total number of subjects in the study to be used for determining power.

prev(numlist) specifies the conjectured prevalence of the disease in the clinical population. The default is prev(0.50).

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

graph, graph(); see [PSS-2] power, graph.

init(#) specifies an initial value for estimating power.
The default value is init(10) which is a rescaled value of power = 0.001 (10/10,000).
Increasing the initial value may be helpful if the reported power appears unreasonably low (e.g. 0.001).

Examples

Examples: Computing sample size

Compute the sample size required to detect a statistical difference in specificity between
two tests, where the first test is hypothesized to have a specificity of 0.70 and the second
test is hypothesized to have a specificity of 0.90 using a two-sided test;
assume a 5% significance level, 80% power, a conjectured disease prevalence of 0.50,
and 50% of the sample assigned to test 1 (the defaults)

. power pairspec 0.70 0.90

Same as above, using a power of 90% and a prevalence of 0.10

. power pairspec 0.70 0.90, power(0.90) prev(0.10)

Computing sample size for a range of prevalence rates

. power pairspec 0.70 0.90, power(0.90) prev(0.10(.10).90)

Applying a range of specificity values for test 1
and setting alpha levels to 0.05 and 0.01 with a disease prevalence of 0.10. Here we graph the results

. power pairspec (0.60(0.05).80) 0.90, power(0.90) alpha(0.01 0.05) prev(0.10) graph

Examples: Computing power

For a total sample of 50 subjects, compute the power of a two-sided test to
detect a specificity of 0.90 given a null specificity of 0.70; assume a 5%
significance level and a prevalence of 0.50 (the default)

. power pairspec 0.70 0.90, n(50)

Same as above, but change the prevalence to 0.20 and use a one-sided test

. power pairspec 0.70 0.90, n(50) prev(0.20) onesided

Same as above, but apply a range prevalence rates

. power pairspec 0.70 0.90, n(50) prev(0.20 0.50 0.70) onesided

Compute powers for a range of null specificities and total sample sizes,
graphing the results

. power pairspec (0.60(.10)0.80) 0.90, n(5(5)80) onesided graph

Stored results

power pairspec stores the following in r():

Scalars

r(alpha) significance level

r(power) power

r(beta) probability of a type II error

r(sens1) sensitivity of test 1

r(sens2) sensitivity of test 2

r(delta) effect size

r(prev) prevalence of disease

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

r(init) initial value of the estimated power

r(N) total sample size

r(N0) sample size of the non-diseased group

r(N1) sample size of the diseased group

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

Macros

r(type) test

r(method) pairspec

r(columns) displayed table columns

r(labels) table column labels

r(widths) table column widths

r(formats) table column formats

Matrices

r(pss_table) table of results

References

Li, J. and J. Fine. 2004. On sample size for sensitivity and specificity in prospective diagnostic accuracy studies. Statistics in Medicine 23:2537-2550.

Miettinen O.S. 1968. The matched pairs design in the case of all-or-none responses. Biometrics 24:339–352.

Obuchowski, N.A. and X.H. Zhou. 2002. Prospective studies of diagnostic test accuracy when disease prevalence is low. Biostatistics 3:477-492.

Citation of power twosens

power pairspec 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. 2022. POWER PAIRSPEC: Stata module to compute power and sample size for specificity between two diagnostic tests in a paired-sample

Authors

Ariel Linden

President, Linden Consulting Group, LLC

alinden@lindenconsulting.org

Also see

Online: estat classification, lsens, power, power onesens (if installed),
power onespec (if installed), power twosens (if installed), power twospec (if installed),
power pairspec (if installed)