help tostt
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Title

    tostt -- Mean-equivalence t tests


Syntax

    One-sample mean-equivalence t test

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


    Two-sample unpaired mean-equivalence t test

        tostt varname1 == varname2 [if] [in] , unpaired [eqvtype(type) eqvlevel(#) uppereqvlevel(#) unequal welch xname(string) yname(string) alpha(#) relevance]



    Two-sample paired mean-equivalence t test


        tostt varname1 == varname2 [if] [in] [, eqvtype(type) eqvlevel(#) uppereqvlevel(#) xname(string) yname(string) alpha(#) relevance]


    Two-group unpaired mean-equivalence t test


        tostt varname [if] [in] , by(groupvar) [eqvtype(type) eqvlevel(#) uppereqvlevel(#) unequal welch xname(string) yname(string) byname(string) byvalues(string string) alpha(#) relevance]


    Immediate form of one-sample mean-equivalence t test

        tostti #obs #mean #sd #val [, eqvtype(type) eqvlevel(#) uppereqvlevel(#) xname(string) alpha(#) relevance]


    Immediate form of two-sample mean-equivalence t test

        tostti #obs1 #mean1 #sd1 #obs2 #mean2 #sd2 [, eqvtype(type) eqvlevel(#) uppereqvlevel(#) unequal welch xname(string) yname(string) alpha(#) relevance]


    options                       Description
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    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
      unpaired                    the data are unpaired
      by(groupvar)                variable defining the two groups (implies unpaired)
      unequal                     unpaired data have unequal variances
      welch                       use Welch's approximation (implies unequal)
      xname(string)               the name of the first variable
      yname(string)               the name of the second variable
      alpha(#)                    set nominal type I level; default is alpha(0.05)
      xname(string)customizes the 1st variable name in the output.
      yname(string)customizes the 2nd variable name in the output.
      byname(string)customizes the grouping variable name in the output.
      byvalue(string)two strings to customize group names.
      relevance                   perform & report combined tests for difference and equivalence
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Description

    tostt tests for the equivalence of means within a symmetric equivalence interval defined by eqvtype and eqvlevel using a two one-sided t tests approach (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 eqvtype and eqvlevel).

    With respect to an unpaired t test, 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 the x and y) or in terms of epsilon (equivalence expressed in the units of the T distribution with the given degrees of freedom):

        Ho: |mean(x) - mean(y)| >= Delta,
        where the equivalence interval ranges from diff-Delta to diff+Delta, and where diff is either the mean difference or the difference in means depending on whether the test is paired or unpaired.  This
        translates directly into two one-sided null hypotheses:

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

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

        -OR-

        Ho: |T| >= epsilon,
        where the equivalence interval ranges from -epsilon to epsilon.  This also translates directly into two one-sided null hypotheses:

            Ho1: epsilon - T <= 0; and

            Ho2: T + epsilon <= 0

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

        Ho: [mean(x) - mean(y)] <= Delta_lower, or [mean(x) - mean(y)] >= Delta_upper,
        where the equivalence interval ranges from [mean(x) - mean(y)] + Delta_lower to [mean(x) - mean(y)] + Delta_upper.  This also translates directly into two one-sided null hypotheses:

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

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

        -OR-

        Ho: T <= epsilon_lower, or T >= epsilon_upper,

            Ho1: epsilon_upper - T <= 0; and

            Ho2: T - epsilon_lower <= 0
 
    NOTE: the appropriate level of alpha is precisely the same as in the corresponding two-sided test of mean 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 (Tryon and Lewis, 2008).


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 variable being tested, and when epsilon is specified, the evqlevel is measured in multiples of the standard deviation of the T 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 t for a given alpha and degrees of freedom.  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 t for a given alpha and degrees of freedom.  tostt
        and tostti 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 1 when delta is the eqvtype and 2 when epsilon is the eqvtype.

    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 correspond to Schuirmann's (1987) asymmetric equivalence intervals.  If uppereqvlevel==|eqvlevel|, then uppereqvlevel will be ignored.

    by(groupvar) specifies the groupvar that defines the two groups that tostt will use to test the hypothesis that their means are different.  Specifying by(groupvar) implies an unpaired (two sample) t test.
        Do not confuse the by() option with the by prefix; you can specify both.

    unpaired specifies that the data be treated as unpaired.  The unpaired option is used when the two set of values to be compared are in different variables.

    unequal specifies that the unpaired data not be assumed to have equal variances.

    welch specifies that the approximate degrees of freedom for the test be obtained from Welch's formula (1947) rather than Satterthwaite's approximation formula (1946), which is the default when unequal is
        specified.  Specifying welch implies unequal.

    xname(string) specifies how the first variable will be labeled in the output.  The default value of xname is x.

    yname(string) specifies how the second variable will be labeled in the output.  The default value of yname is y.

    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 (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 means 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 means 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 means 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

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    The first four examples correspond to those written in the help file for ttest:

    Example 1 setup
    .  sysuse auto

    One-sample mean equivalence t test with asymmetric equivalence interval
    .  tostt mpg==20, eqvt(delta) eqvl(2.5) upper(3)


    Example 2 setup
    .  webuse fuel

    Two-sample paired relevance t test of means; equivalence interval is
    +/- 1.5 sd beyond the critical value of T with df = 11 for alpha = 0.05
    epsilon = invt(11, .95) + 1.5*sqrt(11/9) = 3.4541972
    .  tostt mpg1==mpg2, eqvt(epsilon) eqvl(3.4541972) alpha(0.05) rel


    Example 3 setup
    .  webuse fuel3

    3a Two-group unpaired mean equivalence t test assuming equal variances
    Notice warning about value of Delta!
    .  tostt mpg, by(treated) eqvt(delta) eqvl(1.5)


    3b Same example but customizing output labels
    .  tostt mpg, by(treated) eqvt(delta) eqvl(1.5) byname("Fuel") byvalues("Untreated Treated")
    

    Example 4
    Immediate one-sample mean equivalence test
    Note: n=24, m=62.6, sd=15.8; test m=75
    .  tostti 24 62.6 15.8 75, eqvt(delta) eqvl(20)


    Example 5
    Immediate two-sample relevance t test of means assuming unequal variances
    Note: n1=24 m1=62.6 sd1=15.8 n2=30 m2=76.6 sd2=16.6
    Satterthwaite's df = 50.3912, and equivalence interval is +/- 1.5 sd
    beyond the critical value of T with df = 50.3912 for alpha = 0.05
    epsilon = invt(50.3912, .95)+1.5*sqrt(50.3912/(50.3912-2)) = 3.206343
    . tostti 24 62.6 15.8 30 76.6 16.6, eqvt(epsilon) eqvl(3.206343) unequal xname("Intervention") yname("Control") a(0.05) rel
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Saved results

    The one-sample form of tostt saves the following in r():

    Scalars   
      r(sd_1)        standard deviation for the variable
      r(se)          estimate of standard error
      r(p2)          P(T >= t2); upper one-sided p-value under Ho2
      r(p1)          P(T >= t1); upper one-sided p-value under Ho1
      r(t2)          t statistic under Ho2
      r(t1)          t statistic under Ho1
      r(df_t)        degrees of freedom
      r(mu_1)        x_1 bar, mean for the population
      r(N_1)         sample size n_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 tostt save the following in r():

    Scalars   
      r(sd_2)        standard deviation for second variable
      r(sd_1)        standard deviation for first variable
      r(se)          estimate of standard error
      r(p2)          P(T >= t2); upper one-sided p-value under Ho2
      r(p1)          P(T >= t1); upper one-sided p-value under Ho1
      r(t2)          t statistic under Ho2
      r(t1)          t statistic under Ho1
      r(df_t)        degrees of freedom
      r(mu_2)        x_2 bar, mean for population 2
      r(N_2)         sample size n_2
      r(mu_1)        x_1 bar, mean for population 1
      r(N_1)         sample size n_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.  2025.  tostt: Mean-equivalence t tests.  In: tost Stata software package.  URL: https://www.alexisdinno.com/stata/tost.html


References

    Satterthwaite, F. E.  1946.  An approximate distribution of estimates of variance components.  Biometrics Bulletin 2: 110-114

    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 Lewis, C.  2008.  An inferential confidence interval method of establishing statistical equivalence that corrects Tryon's (2001) reduction factor.  Psychological Methods.  13: 272-277

    Welch, B. L.  1947.  The generalization of "Student's" problem when several different population variances are involved.  Biometrika 34: 28-35


Also See

      Help: tost, pkequiv, ttest
