## Stata 15 help for power

```
[PSS] power -- Power and sample-size analysis for hypothesis tests

Syntax

Compute sample size

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

Compute power

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

Compute effect size and target parameter

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

method                          Description
-------------------------------------------------------------------------
One sample
onemean                       One-sample mean test (one-sample t test)
oneproportion                 One-sample proportion test
onecorrelation                One-sample correlation test
onevariance                   One-sample variance test

Two independent samples
twomeans                      Two-sample means test (two-sample t test)
twoproportions                Two-sample proportions test
twocorrelations               Two-sample correlations test
twovariances                  Two-sample variances test

Two paired samples
pairedmeans                   Paired-means test (paired t test)
pairedproportions             Paired-proportions test (McNemar's test)

Analysis of variance
oneway                        One-way ANOVA
twoway                        Two-way ANOVA
repeated                      Repeated-measures ANOVA

Linear regression
oneslope                      Slope test in a simple linear regression
rsquared                      R^2 test in a multiple linear regression
pcorr                         Partial-correlation test in a multiple
linear regression

Contingency tables
cmh                           Cochran-Mantel-Haenszel test (stratified
2 x 2 tables)
mcc                           Matched case-control studies
trend                         Cochran-Armitage trend test (linear trend
in J x 2 table)

Survival analysis
cox                           Cox proportional hazards model
exponential                   Two-sample exponential test
logrank                       Log-rank test

Cluster randomized design (CRD)
onemean, cluster              One-sample mean test in a CRD
oneproportion, cluster        One-sample proportion test in a CRD
twomeans, cluster             Two-sample means test in a CRD
twoproportions, cluster       Two-sample proportions test in a CRD
logrank, cluster              Log-rank test in a CRD

User-define methods
-------------------------------------------------------------------------

power_options                   Description
-------------------------------------------------------------------------
Main
* alpha(numlist)                significance level; default is
alpha(0.05)
* power(numlist)                power; default is power(0.8)
* beta(numlist)                 probability of type II error; default is
beta(0.2)
* n(numlist)                    sample size; required to compute power or
effect size
* n1(numlist)                   sample size of the control group
* n2(numlist)                   sample size of the experimental group
* nratio(numlist)               ratio of sample sizes, N2/N1; default is
nratio(1), meaning equal group sizes
compute(N1|N2)                solve for N1 given N2 or for N2 given N1
nfractional                   allow fractional sample size
direction(upper|lower)        direction of the effect for effect-size
determination; default is
direction(upper), which means that the
postulated value of the parameter is
larger than the hypothesized value
onesided                      one-sided test; default is two sided
parallel                      treat number lists in starred options or
in command arguments as parallel when
multiple values per option or argument
are specified (do not enumerate all
possible combinations of values)

Table
[no]table[(tablespec)]        suppress table or display results as a
table; see [PSS] power, table
saving(filename [, replace])  save the table data to filename; use
replace to overwrite existing filename

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

Iteration
init(#)                       initial value of the estimated parameter;
default is method specific
iterate(#)                    maximum number of iterations; default is
iterate(500)
tolerance(#)                  parameter tolerance; default is
tolerance(1e-12)
ftolerance(#)                 function tolerance; default is
ftolerance(1e-12)
[no]log                       suppress or display iteration log
[no]dots                      suppress or display iterations as dots

notitle                       suppress the title
-------------------------------------------------------------------------
* Specifying a list of values in at least two starred options, or at
least two command arguments, or at least one starred option and one
argument results in computations for all possible combinations of the
values; see numlist.  Also see the parallel option.
Options n1(), n2(), nratio(), and compute() are available only for
two-independent-samples methods.
Iteration options are available only with computations requiring
iteration.
notitle does not appear in the dialog box.

Statistics > Power and sample size

Description

The power command is useful for planning studies.  It performs power and
sample-size analysis for studies that use hypothesis testing to form
inferences about population parameters.  You can compute sample size
given power and effect size, power given sample size and effect size, or
the minimum detectable effect size and the corresponding target parameter
given power and sample size.  You can display results in a table ([PSS]
power, table) and on a graph ([PSS] power, graph).

Options

+------+
----+ Main +-------------------------------------------------------------

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

power(numlist) sets the power of the test.  The default is power(0.8).
If beta() is specified, this value is set to be 1 - beta().  Only one
of power() or beta() may be specified.

beta(numlist) sets the probability of a type II error of the test.  The
default is beta(0.2).  If power() is specified, this value is set to
be 1 - power().  Only one of beta() or power() may be specified.

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

n1(numlist) specifies the number of subjects in the control group to be
used for power or effect-size determination.

n2(numlist) specifies the number of subjects in the experimental group to
be used for power or effect-size determination.

nratio(numlist) specifies the sample-size ratio of the experimental group
relative to the control group, N2/N1, for power or effect-size
determination for two-sample tests.  The default is nratio(1),
meaning equal allocation between the two groups.

compute(N1|N2) requests that the power command compute one of the group
sample sizes given the other one instead of the total sample size for
two-sample tests.  To compute the control-group sample size, you must
specify compute(N1) and the experimental-group sample size in n2().
Alternatively, to compute the experimental-group sample size, you
must specify compute(N2) and the control-group sample size in n1().

nfractional specifies that fractional sample sizes be allowed.  When this
option is specified, fractional sample sizes are used in the
intermediate computations and are also displayed in the output.

Also see the description and the use of options n(), n1(), n2(),
nratio(), and compute() for two-sample tests in [PSS] unbalanced
designs.

direction(upper|lower) specifies the direction of the effect for
effect-size determination.  For most methods, the default is
direction(upper), which means that the postulated value of the
parameter is larger than the hypothesized value.  For survival
methods, the default is direction(lower), which means that the
postulated value is smaller than the hypothesized value.

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

parallel requests that computations be performed in parallel over the
lists of numbers specified for at least two study parameters as
command arguments, starred options allowing numlist, or both.  That
is, when parallel is specified, the first computation uses the first
value from each list of numbers, the second computation uses the
second value, and so on.  If the specified number lists are of
different sizes, the last value in each of the shorter lists will be
used in the remaining computations.  By default, results are computed
over all combinations of the number lists.

For example, let a_1 and a_2 be the list of values for one study
parameter, and let b_1 and b_2 be the list of values for another
study parameter.  By default, power will compute results for all
possible combinations of the two values in two study parameters:
(a_1,b_1), (a_1,b_2), (a_2,b_1), and (a_2,b_2).  If parallel is
specified, power will compute results for only two combinations:
(a_1,b_1) and (a_2,b_2).

+-------+
----+ Table +------------------------------------------------------------

notable, table, and table() control whether or not results are displayed
in a tabular format.  table is implied if any number list contains
more than one element.  notable is implied with graphical output --
when either the graph or the graph() option is specified.  table() is
used to produce custom tables.  See [PSS] power, table for details.

saving(filename [, replace]) creates a Stata data file (.dta file)
containing the table values with variable names corresponding to the
displayed columns.  replace specifies that filename be overwritten if
it exists.  saving() is only appropriate with tabular output.

+-------+
----+ Graph +------------------------------------------------------------

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

The following options control an iteration procedure used by the power
command for solving nonlinear equations.

+-----------+
----+ Iteration +--------------------------------------------------------

init(#) specifies an initial value for the estimated parameter.  Each
power method sets its own default value.  See the documentation entry
of the method for details.

iterate(#) specifies the maximum number of iterations for the Newton
method.  The default is iterate(500).

tolerance(#) specifies the tolerance used to determine whether successive
parameter estimates have converged.  The default is tolerance(1e-12).
See Convergence criteria in [M-5] solvenl() for details.

ftolerance(#) specifies the tolerance used to determine whether the
proposed solution of a nonlinear equation is sufficiently close to 0
based on the squared Euclidean distance.  The default is
ftolerance(1e-12).  See Convergence criteria in [M-5] solvenl() for
details.

log and nolog specify whether an iteration log is to be displayed.  The
iteration log is suppressed by default.  Only one of log, nolog,
dots, or nodots may be specified.

dots and nodots specify whether a dot is to be displayed for each
iteration.  The iteration dots are suppressed by default.  Only one
of dots, nodots, log, or nolog may be specified.

The following option is available with power but is not shown in the
dialog box:

notitle prevents the command title from displaying.

Examples

Examples: One-sample mean test

Compute the required sample size for a two-sided test of Ho: mu=2 versus
Ha: mu=2.5 assuming a standard deviation of 0.8, significance level of 5%
(the default) and power of 0.80 (also the default)
. power onemean 2 2.5, sd(0.8)

Compute the power of the test in the previous example, assuming a sample
size of 50
. power onemean 2 2.5, sd(0.8) n(50)

Same as above, reporting output in a table
. power onemean 2 2.5, sd(0.8) n(50) table

Produce a table showing the power of the test for sample sizes 25, 50,
and 100, using a significance level of 1% (0.01)
. power onemean 2 2.5, sd(0.8) n(25 50 100) alpha(0.01)

Compute the required sample size for a one-sided test
. power onemean 2 2.5, sd(0.8) onesided

Examples: Two-sample means test

Compute the required sample size for a two-sided two-sample means test
assuming a control-group mean of 12, an experimental-group mean of 16, a
significance level of 5%, and desired power of 80%; assume both groups
have a standard deviation of 5
. power twomeans 12 16, sd(5)

Same as above but assuming a control-group standard deviation of 5 and an
experimental-group standard deviation of 7
. power twomeans 12 16, sd1(5) sd2(7)

Same as above, assuming our experimental group is one-half the size of
the control group
. power twomeans 12 15, sd1(5) sd2(7) nratio(0.5)

Same as first example, using the diff() option to specify the mean
difference under Ha
. power twomeans 12, sd(5) diff(4)

Examples: ANOVA

Consider power and sample-size analysis for an overall F test of the
equality of group means for a three-group one-way ANOVA model.  For power
and sample-size computations, the postulated group means are 260, 289,
and 295; and the error variance is assumed to be 4900.  The significance
level is set at 5%.

Compute the required sample size given power of 80%, the default
. power oneway 260 289 295, varerror(4900)

Compute power given a sample size of 300
. power oneway 260 289 295, n(300) varerror(4900)

Compute the minimum effect size detectable with a power of 80% given a
sample size of 300 equally allocated among 3 groups
. power oneway, n(300) power(0.8) ngroups(3)

Specify error variance to compute the corresponding between-group
variance
. power oneway, n(300) power(0.8) ngroups(3) varerror(4900)

Stored results

power stores the following in r():

Scalars
r(alpha)            significance level
r(power)            power
r(beta)             probability of a type II error
r(delta)            effect size
r(N)                total sample size
r(N_a)              actual sample size
r(N1)               sample size of the control group
r(N2)               sample size of the experimental group
r(nratio)           ratio of sample sizes, N2/N1
r(nratio_a)         actual ratio of sample sizes
r(nfractional)      1 if nfractional is specified, 0 otherwise
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
r(init)             initial value of the estimated parameter
r(maxiter)          maximum number of iterations
r(iter)             number of iterations performed
r(tolerance)        requested parameter tolerance
r(deltax)           final parameter tolerance achieved
r(ftolerance)       requested distance of the objective function from
zero
r(function)         final distance of the objective function from zero
r(converged)        1 if iteration algorithm converged, 0 otherwise

Macros
r(type)             test
r(method)           the name of the specified method
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

Matrices
r(pss_table)        table of results

Also see Stored results in the method-specific manual entries for

```