*! version 3.1.4 09oct2023
help tostpr

Title

tostpr -- One- and two-sample z tests of proportion-equivalence

Syntax

One-sample proportion-equivalence z test

tostpr varname == # [if] [in]
[, eqvtype(type)
eqvlevel(#)
uppereqvlevel(#)
alpha(#)
relevance]

Two-sample proportion-equivalence z test

tostpr 1 == 2 [if] [in]
[, eqvtype(type)
eqvlevel(#) yates ha
uppereqvlevel(#)
alpha(#)
relevance]

Two-group proportion-equivalence z test

tostpr varname [if] [in]
, by(varlist:groupvar)
[eqvtype(type)
eqvlevel(#)
uppereqvlevel(#)
yates ha
alpha(#)
relevance]

Immediate form of one-sample z test of proportion-equivalence

tostpri #obs1 #p1 #p2
[, eqvtype(type)
eqvlevel(#)
uppereqvlevel(#)
count
alpha(#)
relevance]

Immediate form of two-sample z test of proportion-equivalence

tostpri #obs1 #p1 #obs2 #p2
[, eqvtype(type)
eqvlevel(#)
uppereqvlevel(#)
count
yates
ha
alpha(#)
relevance]

by is allowed with the non-immediate form of tostpri; see
[D] by.

tostpr & tostpri options

Miscellaneous
eqvtype(string) specify equivalence threshold with Delta or epsilon

eqvlevel(#) the level of tolerance defining the equivalence interval

uppereqvlevel(#) the upper value of an asymmetric equivalence interval

by(varlist:groupvar) variable defining the two groups

count integers, not proportions are used with tostpri

yates use the Yates continuity correction

ha use the Hauck-Anderson continuity correction

alpha(#) set nominal type I level; default is alpha(0.05)

relevance perform & report combined tests for difference and equivalence

Description

tostpr tests for the equivalence of proportions within a symmetric
equivalence interval defined by eqvtype and eqvlevel using a two
one-sided z tests approach (Hauck and Anderson, 1984;
Schuirmann, 1987). Typically null hypotheses are
framed from an assumption of a lack of difference between two quantities, and
reject this assumption only with sufficient evidence. When performing tests
for equivalence, one frames a null hypothesis with the assumption that two
quantities are different within an equivalence interval defined by some chosen
level of tolerance (as specified by eqvlevel).

With respect to a z test of proportions, an equivalence null hypothesis takes
one of the following two forms depending on whether equivalence is defined in
terms of Delta (equivalence expressed in the same units as prop(x) and prop(y)
or in terms of epsilon (equivalence expressed in the units of the z
distribution):

Ho: |prop(x) - prop(y)| >= Delta,

where the equivalence interval ranges from diff-Delta to diff+Delta, and
where diff is the difference in proportions. This translates directly into two
one-sided null hypotheses:

Ho1: Delta - [prop(x) - prop(y)] <= 0; and

Ho2: [prop(x) - prop(y)] + Delta <= 0

-OR-

Ho: |z| >= epsilon,

where the equivalence interval ranges from -epsilon to epsilon. This also
translates directly into two one-sided null hypotheses:

Ho1: epsilon - Z <= 0; and

Ho2: Z + epsilon <= 0

When an asymmetric equivalence interval is defined using the uppereqvlevel option
the general negativist null hypothesis becomes:

Ho: [prop(x) - prop(y)] <= Delta_lower, or [prop(x) - prop(y)] >= Delta_upper,

where the equivalence interval ranges from [prop(x) - prop(y)]+Delta_lower to
[prop(x) - prop(y)]+Delta_upper. This also translates directly into two
one-sided null hypotheses:

Ho1: Delta_upper - [prop(x) - prop(y)] <= 0; and

Ho2: [prop(x) - prop(y)] - Delta_lower <= 0

-OR-

Ho: Z <= epsilon_lower, or Z >= epsilon_upper, and

Ho1: epsilon_upper - Z <= 0; and

Ho2: Z - epsilon_lower <= 0

NOTE: the appropriate level of alpha is precisely the same as in the
corresponding two-sided test of proportion difference, so that, for example, if
one wishes to make a type I error %5 of the time, one simply conducts both of
the one-sided tests of Ho1 and Ho2 by comparing the resulting p-value to 0.05
(Wellek, 2010).

Options

Main

eqvtype(string) defines whether the equivalence interval will be
defined in terms of Delta or epsilon (delta, or epsilon). These
options change the way that evqlevel is interpreted: when delta is
specified, the evqlevel is measured in the units of the proportion of the
variable being tested, and when epsilon is specified, the evqlevel
is measured in multiples of the standard deviation of the Z distribution; put
another way epsilon = Delta/standard error. The default is delta.

Defining tolerance in terms of epsilon means that it is not possible to reject
any test of mean equivalence Ho if epsilon <= the critical value of z for a
given alpha. Because epsilon = Delta/standard error, we can see that it is not
possible to reject any Ho if Delta <= the product of the standard error and
critical value of z for a given alpha. tostpr and tostpri now report
when either of these conditions obtain.

eqvlevel(#) defines the equivalence threshold for the tests depending on
whether eqvtype is delta or epsilon (see above). Researchers
are responsible for choosing meaningful values of Delta or epsilon. The default
value is 0.1 when delta is the type, and is 2 when epsilon is the type.

uppereqvlevel(#) defines the upper equivalence threshold for the test,
and transforms the meaning of eqvlevel to mean the lower equivalence
threshold for the test. Also, eqvlevel is assumed to be a negative value.
Taken together, these are analogous to Schuirmann's (1987)
asymmetric equivalence intervals. If uppereqvlevel==|eqvlevel|, then
uppereqvlevel will be ignored.

by(varlist:groupvar) specifies the groupvar that defines the two
groups that tostpr will use to test the hypothesis that their proportions
are different. Specifying by(groupvar) implies a two sample z test.
Do not confuse the by() option with the by prefix; you can specify
both.

count specifies that integer counts instead of proportions be used in tostpri. In
the first syntax, tostpri expects that #obs1 and #p1 are counts -- #p1 < #obs1
-- and #p2 is a proportion. In the second syntax, tostpri expects that all
four numbers are integer counts, that #obs1 > #p1, and that #obs2 > #p2.

yates specifies that the test statistics incorporate the Yates continuity
correction (Yates 1934). This option is included for convenience
although the Hauck-Anderson correction (see ha) is preferred (Tu 1997). This
continuity correction is only applied to the two one-sided z test statistics,
and not to any of the Wald confidence intervals.

ha specifies that the test statistics incorporate the Hauck-Anderson
continuity correction (Hauck and Anderson 1986). This is the preferred
continuity correction option (Tu 1997). This continuity
correction is only applied to the two one-sided z test statistics, and not to
any of the Wald confidence intervals.

alpha(#) specifies the nominal type I error rate. The default is alpha(0.05).

relevance reports results and inference for combined tests for difference
and equivalence for a specific alpha, eqvtype, and eqvlevel.
See the Remarks section more details on inference from combined tests.

Remarks

As described by Tryon and Lewis (Tryon and Lewis 2008), when both
tests for difference and equivalence are taken together, there are four possible
interpretations:

1. One may reject the null hypothesis of no difference, but fail to reject the
null hypothesis of difference, and conclude that there is a relevant difference
in proportions at least as large as Delta or epsilon.

2. One may fail to reject the null hypothesis of no difference, but reject the
null hypothesis of difference, and conclude that the proportions are equivalent
within the equivalence range (i.e. defined by Delta or epsilon).

3. One may reject both the null hypothesis of no difference and the null
hypothesis of difference, and conclude that the proportions are trivially different,
within the equivalence range (i.e. defined by Delta or epsilon).

4. One may fail to reject both the null hypothesis of no difference and the
null hypothesis of difference, and draw an indeterminate conclusion, because
the data are underpowered to detect difference or equivalence.

Examples

These examples correspond to those written in the help file for
prtest:

. sysuse auto (setup)
. tostpr foreign==.4, eqvt(delta) eqvl(.15) upper(.2) (one-sample proportion-equivalence test)

. webuse cure (setup)
. tostpr cure1==cure2, eqvt(epsilon) eqvl(2.5) rel (two-sample proportion-relevance test)

. webuse cure2 (setup)
. tostpr cure, by(sex) ha (two-group proportion-equivalence test)
(cure has same proportion for males and females)
(inlcudes Hauck-Anderson continuity correction)

. tostpri 50 .52 .70, eqvt(delta) eqvl(.1) (immediate form of one-sample test of proportion-equivalence)
(note warning about value of Delta!)

. tostpri 30 4 .7, count eqvt(epsilon) eqvl(2) rel (first two numbers are counts)

. tostpri 30 .4 45 .67, eqvt(delta) eqvl(.2) (immediate form of two-sample test of proportion-equivalence)

. tostpri 30 4 45 17, count eqvt(delta) eqvl(.2) (all numbers are counts)

Saved results

The one-sample forms of tostpr and tostpri saves the following in
r():

Scalars

r(z2) z statistic under Ho2

r(z1) z statistic under Ho1

r(P_1) proportion for variable 1

r(N_1) number of observations for variable 1

r(Delta) Delta, tolerance level defining the equivalence interval; OR

r(Du) Delta_upper, tolerance level defining the equivalence interval's upper side; AND

r(Dl) Delta_lower, tolerance level defining the equivalence interval's lower side; OR

r(epsilon) epsilon, tolerance level defining the equivalence interval

r(eu) epsilon_upper, tolerance level defining the equivalence interval's upper side; AND

r(el) epsilon_lower, tolerance level defining the equivalence interval's lower side

r(relevance) Relevance test conclusion for given alpha and Delta/epsilon

The two-sample and two-group forms of tostpr and tostpri save the
following in r():

Scalars

r(z2) z statistic under Ho2

r(z1) z statistic under Ho1

r(P_2) proportion for variable 2

r(N_2) number of observations for variable 2

r(P_1) proportion for variable 1

r(N_1) number of observations for variable 1

r(Delta) Delta, tolerance level defining the equivalence interval; OR

r(Du) Delta_upper, tolerance level defining the equivalence interval's upper side; AND

r(Dl) Delta_lower, tolerance level defining the equivalence interval's lower side; OR

r(epsilon) epsilon, tolerance level defining the equivalence interval

r(eu) epsilon_upper, tolerance level defining the equivalence interval's upper side; AND

r(el) epsilon_lower, tolerance level defining the equivalence interval's lower side

r(relevance) Relevance test conclusion for given alpha and Delta/epsilon

Author

Alexis Dinno

Portland State University

alexis.dinno@pdx.edu

Development of tost is
ongoing, please contact me with any questions, bug reports or suggestions for
improvement. Fixing bugs will be facilitated by sending along:

(1) a copy of the data (de-labeled or anonymized is fine),

(2) a copy of the command used, and

(3) a copy of the exact output of the command.

I am endebted to my winter 2013 students for their inspiration.

Suggested citation

Dinno A. 2017. tostpr: One- and two-sample z tests of
proportion-equivalence. Stata software package. URL:

References

Hauck, W. W. and S. Anderson. 1984. A new statistical procedure for testing equivalence in two-group comparative bioavailability trials.
Journal of Pharmacokinetics and Pharmacodynamics. 12: 83-91

Hauck, W. W. and Anderson, S. 1986. A comparison of large-sample confidence interval methods for the difference of two binomial probabilities. The American Statistician, 40: 318-322.

Schuirmann, D. A. 1987. A comparison of the two one-sided tests procedure and the power approach for assessing the equivalence of average bioavailability.
Journal of Pharmacokinetics and Biopharmaceutics. 15: 657-680

Tryon, W. W., and C. Lewis. 2008.
An inferential confidence interval method of establishing statistical equivalence that corrects Tryon’s (2001) reduction factor. Psychological Methods. 13: 272-277

Tu, D. 1997. Two one-sided tests procedures in establishing therapeutic equivalence with binary clinical endpoints: Fixed sample performances and sample size determination.
Journal of Statistical Computing and Simmulation. 59: 271-290

Yates, F. 1934. Contingency tables involving small numbers and the chi-squared test. Supplement to the Journal of the Royal Statistical Society. 1: 217-235

Wellek, S. 2010. Testing Statistical Hypotheses of Equivalence and Noninferiority,
second edition. Chapman and Hall/CRC Press. p. 31

Also See

Help: tost, pkequiv, prtest