*! version 1.0.0 17Aug2022

Title

power diagnostic -- Power and sample-size analysis for sensitivity and specificity of a diagnostic test

Syntax

Compute sample size

power method
...
[, power(numlist)
power_options ...]

Compute power

power method
..., n(numlist)
[power_options ...]

method

One sample
onesens One-sample test for sensitivity

onespec One-sample test for specificity

Two independent samples
twosens Two-sample test for sensitivity

twospec Two-sample test for specificity

Two paired samples
pairsens paired test for sensitivity

pairspec paired test for specificity

power_options

Main
* 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)

* fraction(numlist) fraction of the sample assigned to test 1 in twosens and twospec; default is fraction(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

The power diagnostic suite of commands is useful for planning prospective studies evaluating the accuracy of diagnostic tests for a binary outcome
(e.g. diseased/not-diseased) and in which a test's sensitivity and specificity are the measures of interest. Sensitivity is the probability
of a test detecting disease when the patient actually has the disease, and specificity is the probability that the test is negative
when the patient is actually disease-free.

All power diagnostic commands implement 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.

Sample size can be computed given power, and power can be computed given sample size. Results can be displayed in a table (default) and on a graph
([PSS-2] power, graph).

Options

Main

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

fraction(numlist) specifies the fraction of the sample assigned to test 1 in twosens
and twospec. The default is fraction(0.50) (i.e. half the sample).

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

Graph

graph and graph() produce graphical output; see
[PSS-2] power, graph for details.

Iteration

init(#) specifies an initial value for estimating power in twosens,
twospec, pairsens, pairspec.
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: One-sample test of sensitivity

Compute the sample size required to detect a sensitivity of 0.90 given a
sensitivity of 0.70 under the null hypothesis using a two-sided test;
assume a 5% significance level, 80% power and a conjectured disease prevalence of 0.50 (the defaults)

. power onesens 0.70 0.90

For a total sample of 300 subjects, compute the power of a two-sided test to
detect a sensitivity of 0.90 given a null sensitivity of 0.70; assume a 1%
significance level and a prevalence of 0.20

. power onesens 0.70 0.90, n(300) prev(0.20) alpha(0.01)

Examples: One-sample test of specificity

Compute the sample size required to detect a specificity of 0.90 given a
specificity of 0.80 under the null hypothesis using a two-sided test;
assume a 5% significance level, 90% power and a conjectured disease prevalence of 0.10

. power onespec 0.80 0.90, power(0.90) prev(0.10)

For a total sample of 40 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.20

. power onespec 0.70 0.90, n(40) prev(0.20)

Examples: Two-sample test of sensitivity

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

. power twosens 0.70 0.90, prev(0.30)

For a total sample of 400 subjects, compute the power of a two-sided test to
detect a sensitivity of 0.90 given a null sensitivity of 0.70; assume a 5%
significance level, a prevalence of 0.30, and a 1:3 ratio of test 1 to test 2 (e.g. 0.25/0.75)

. power twosens 0.70 0.90, n(400) prev(0.30) fract(0.25)

Examples: Two-sample test of specificity

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.85 and the second
test is hypothesized to have a specificity of 0.95 using a two-sided test;
assume a 5% significance level, 90% power, a conjectured disease prevalence of 0.30,
and 50% of the sample assigned to test 1 (the default)

. power twospec 0.85 0.95, prev(0.30) power(0.90)

For a total sample of 500 subjects, compute the power of a two-sided test to
detect a specificity of 0.95 given a null specificity of 0.85; assume a 5%
significance level a prevalence of 0.25, and a 1:2 ratio of test 1 to test 2 (e.g. 0.3334/0.6667)

. power twospec 0.85 0.95, n(500) prev(0.25) fract(0.3334)

Examples: Paired-sample test of sensitivity

Compute the sample size required to detect a statistical difference in sensitivity between
two tests (where the same subjects take both tests), where the first test is hypothesized
to have a sensitivity of 0.82 and the second test is hypothesized to have a sensitivity
of 0.90 using a one-sided test; assume a 5% significance level, 80% power, and a conjectured
disease prevalence of 0.10

. power pairsens 0.82 0.90, prev(0.10) onesided

For a total sample of 3000 subjects, compute the power of a two-sided test to
detect a sensitivity of 0.90 given a null sensitivity of 0.82; assume a 5%
significance level and a prevalence of 0.10

. power pairsens 0.82 0.90, n(3000) prev(0.10)

Examples: Paired-sample test of specificity

Compute the sample size required to detect a statistical difference in specificity between
two tests (where the same subjects take both 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.80 using a two-sided test; assume a 1% significance level, 90% power, and a conjectured
disease prevalence of 0.09

. power pairspec 0.70 0.80, alpha(0.01) power(0.90) prev(0.09)

For a total sample of 550 subjects, compute the power of a two-sided test to
detect a specificity of 0.80 given a null specificity of 0.70; assume a 1%
significance level and a prevalence of 0.10

. power pairspec 0.70 0.80, n(550) prev(0.10) alpha(0.01)

Stored results

power diagnostic stores the following in r():

Scalars

r(alpha) significance level

r(power) power

r(beta) probability of a type II error

r(sens0) null sensitivity (only available in onesens)

r(sens1) sensitivity of test 1

r(sens2) sensitivity of test 2

r(spec0) null specificity (only available in onespec)

r(spec1) specificity of test 1

r(spec2) specificity of test 2

r(delta) effect size

r(prev) prevalence of disease

r(fraction) fraction of sample assigned to test 1 (available in twosens and twospec)

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

r(init) initial value of the estimated power (available in twosens, twospec, pairsens, pairspec)

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) method name

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.

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 diagnostic

power diagnostic 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 DIAGNOSTIC: Stata package to compute power and sample size for sensitivity and specificity of a diagnostic test

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 pairsens (if installed), power pairspec (if installed)