The TTEST Procedure

Two-Independent-Sample Design

Define the following notation:

\begin{align*} n^\star _1 & = \mbox{number of observations at first class level} \\ n^\star _2 & = \mbox{number of observations at second class level} \\ y_{1i} & = \mbox{value of }i\mbox{th observation at first class level,} \; \; i \in \{ 1, \ldots , n^\star _1\} \\ y_{2i} & = \mbox{value of }i\mbox{th observation at second class level,} \; \; i \in \{ 1, \ldots , n^\star _2\} \\ f_{1i} & = \mbox{frequency of }i\mbox{th observation at first class level,} \; \; i \in \{ 1, \ldots , n^\star _1\} \\ f_{2i} & = \mbox{frequency of }i\mbox{th observation at second class level,} \; \; i \in \{ 1, \ldots , n^\star _2\} \\ w_{1i} & = \mbox{weight of }i\mbox{th observation at first class level,} \; \; i \in \{ 1, \ldots , n^\star _1\} \\ w_{2i} & = \mbox{weight of }i\mbox{th observation at second class level,} \; \; i \in \{ 1, \ldots , n^\star _2\} \\ n_1 & = \mbox{sample size for first class level} = \sum _ i^{n^\star _1} f_{1i} \\ n_2 & = \mbox{sample size for second class level} = \sum _ i^{n^\star _2} f_{2i} \end{align*}
Normal Difference (DIST=NORMAL TEST=DIFF)

Observations at the first class level are assumed to be distributed as $\mr{N}(\mu _1, \sigma _1^2)$, and observations at the second class level are assumed to be distributed as $\mr{N}(\mu _2, \sigma _2^2)$, where $\mu _1$, $\mu _2$, $\sigma _1$, and $\sigma _2$ are unknown.

The within-class-level mean estimates ($\bar{y}_1$ and $\bar{y}_2$), standard deviation estimates ($s_1$ and $s_2$), standard errors ($\mr{SE_1}$ and $\mr{SE_2}$), and confidence limits for means and standard deviations are computed in the same way as for the one-sample design in the section Normal Data (DIST=NORMAL).

The mean difference $\mu _1 - \mu _2 = \mu _ d$ is estimated by

\[ \bar{y}_ d = \bar{y}_1 - \bar{y}_2 \]

Under the assumption of equal variances ($\sigma _1^2 = \sigma _2^2$), the pooled estimate of the common standard deviation is

\[ s_ p = \left( \frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2} \right)^\frac {1}{2} \]

The pooled standard error (the estimated standard deviation of $\bar{y}_ d$ assuming equal variances) is

\[ \mr{SE}_ p = s_ p \left( \frac{1}{\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}} + \frac{1}{\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}} \right)^\frac {1}{2} \]

The pooled 100(1 – $\alpha $)% confidence interval for the mean difference $\mu _ d$ is

\begin{align*} \left( \bar{y}_ d - t_{1-\frac{\alpha }{2}, n_1+n_2-2} \mr{SE}_ p \; \; , \; \; \bar{y}_ d + t_{1-\frac{\alpha }{2}, n_1+n_2-2} \mr{SE}_ p \right) & , \; \; \mbox{SIDES=2} \\ \left( -\infty \; \; , \; \; \bar{y}_ d + t_{1-\alpha , n_1+n_2-2} \mr{SE}_ p \right) & , \; \; \mbox{SIDES=L} \\ \left( \bar{y}_ d - t_{1-\alpha , n_1+n_2-2} \mr{SE}_ p \; \; , \; \; \infty \right) & , \; \; \mbox{SIDES=U} \end{align*}

The t value for the pooled test is computed as

\[ t_ p = \frac{\bar{y}_ d - \mu _0}{\mr{SE}_ p} \]

The p-value of the test is computed as

\[ p\mbox{-value} = \left\{ \begin{array}{ll} P \left( t_ p^2 > F_{1-\alpha , 1, n_1+n_2-2} \right) \; \; , & \mbox{2-sided} \\ P \left( t_ p < t_{\alpha , n_1+n_2-2} \right) \; \; , & \mbox{lower 1-sided} \\ P \left( t_ p > t_{1-\alpha , n_1+n_2-2} \right) \; \; , & \mbox{upper 1-sided} \\ \end{array} \right. \]

Under the assumption of unequal variances (the Behrens-Fisher problem), the unpooled standard error is computed as

\[ \mr{SE}_ u = \left( \frac{s^2_1}{\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}} + \frac{s^2_2}{\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}} \right)^\frac {1}{2} \]

Satterthwaite’s (1946) approximation for the degrees of freedom, extended to accommodate weights, is computed as

\[ \mr{df}_ u = \frac{\mr{SE}^4_ u}{\frac{s^4_1}{(n_1-1)\left(\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}\right)^2} + \frac{s^4_2}{(n_2-1)\left(\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}\right)^2}} \]

The unpooled Satterthwaite 100(1 – $\alpha $)% confidence interval for the mean difference $\mu _ d$ is

\begin{align*} \left( \bar{y}_ d - t_{1-\frac{\alpha }{2}, \mr{df}_ u} \mr{SE}_ u \; \; , \; \; \bar{y}_ d + t_{1-\frac{\alpha }{2}, \mr{df}_ u} \mr{SE}_ u \right) & , \; \; \mbox{SIDES=2} \\ \left( -\infty \; \; , \; \; \bar{y}_ d + t_{1-\alpha , \mr{df}_ u} \mr{SE}_ u \right) & , \; \; \mbox{SIDES=L} \\ \left( \bar{y}_ d - t_{1-\alpha , \mr{df}_ u} \mr{SE}_ u \; \; , \; \; \infty \right) & , \; \; \mbox{SIDES=U} \end{align*}

The t value for the unpooled Satterthwaite test is computed as

\[ t_ u = \frac{\bar{y}_ d - \mu _0}{\mr{SE}_ u} \]

The p-value of the unpooled Satterthwaite test is computed as

\[ p\mbox{-value} = \left\{ \begin{array}{ll} P \left( t_ u^2 > F_{1-\alpha , 1, \mr{df}_ u} \right) \; \; , & \mbox{2-sided} \\ P \left( t_ u < t_{\alpha , \mr{df}_ u} \right) \; \; , & \mbox{lower 1-sided} \\ P \left( t_ u > t_{1-\alpha , \mr{df}_ u} \right) \; \; , & \mbox{upper 1-sided} \\ \end{array} \right. \]

When the COCHRAN option is specified in the PROC TTEST statement, the Cochran and Cox (1950) approximation of the p-value of the $t_ u$ statistic is the value of p such that

\[ t_ u = \frac{\left( \frac{s^2_1}{\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}} \right) t_1 + \left( \frac{s^2_2}{\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}} \right) t_2}{\left( \frac{s^2_1}{\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}} \right) + \left( \frac{s^2_2}{\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}} \right)} \]

where $t_1$ and $t_2$ are the critical values of the t distribution corresponding to a significance level of p and sample sizes of $n_1$ and $n_2$, respectively. The number of degrees of freedom is undefined when $n_1 \ne n_2$. In general, the Cochran and Cox test tends to be conservative (Lee and Gurland 1975).

The 100(1 – $\alpha $)% CI= EQUAL and CI= UMPU confidence intervals for the common population standard deviation $\sigma $ assuming equal variances are computed as discussed in the section Normal Data (DIST=NORMAL) for the one-sample design, except replacing $s^2$ by $s^2_ p$ and $(n-1)$ by $(n_1+n_2-1)$.

The folded form of the F statistic, $F^{\prime }$, tests the hypothesis that the variances are equal (Steel and Torrie 1980), where

\[ F^{\prime } = \frac{\max (s_1^2,s_2^2)}{\min (s_1^2,s_2^2)} \]

A test of $F^{\prime }$ is a two-tailed F test because you do not specify which variance you expect to be larger. The p-value (Steel and Torrie 1980) is equal-tailed and is computed as

\begin{align*} p\mbox{-value} & = 2 P\left(F^{\prime } > F_{1-\alpha , \mr{df}_ a, \mr{df}_ b}\right) \\ & = \left\{ \begin{array}{ll} P\left(s_1^2/s_2^2 > F_{1-\alpha , \mr{df}_1, \mr{df}_2}\right) + P\left(s_2^2/s_1^2 \le F_{1-\alpha , \mr{df}_2, \mr{df}_1}\right) \; \; , & s_1^2/s_2^2 \ge 1 \\ P\left(s_1^2/s_2^2 \le F_{1-\alpha , \mr{df}_1, \mr{df}_2}\right) + P\left(s_2^2/s_1^2 > F_{1-\alpha , \mr{df}_2, \mr{df}_1}\right) \; \; , & s_1^2/s_2^2 < 1 \\ \end{array} \right. \end{align*}

where $\mr{df}_1$, $\mr{df}_2$, $\mr{df}_ a$, and $\mr{df}_ b$ are the degrees of freedom that correspond to $s_1^2$, $s_1^2$, $\max (s_1^2,s_2^2)$, and $\min (s_1^2,s_2^2)$, respectively.

Note that the p-value is similar to the probability $p^\star $ of a greater $F^{\prime }$ value under the null hypothesis that $\sigma _1^2=\sigma _2^2$,

\[ p^\star = \left\{ \begin{array}{ll} P\left(s_1^2/s_2^2 > F_{1-\alpha , \mr{df}_1, \mr{df}_2}\right) + P\left(s_2^2/s_1^2 \le F_{1-\alpha , \mr{df}_1, \mr{df}_2}\right) \; \; , & s_1^2/s_2^2 \ge 1 \\ P\left(s_1^2/s_2^2 \le F_{1-\alpha , \mr{df}_1, \mr{df}_2}\right) + P\left(s_2^2/s_1^2 > F_{1-\alpha , \mr{df}_1, \mr{df}_2}\right) \; \; , & s_1^2/s_2^2 < 1 \\ \end{array} \right. \]

The $F^{\prime }$ test is not very robust to violations of the assumption that the data are normally distributed, and thus it is not recommended without confidence in the normality assumption.

Lognormal Ratio (DIST=LOGNORMAL TEST=RATIO)

The DIST= LOGNORMAL analysis is handled by log-transforming the data and null value, performing a DIST= NORMAL analysis, and then transforming the results back to the original scale. See the section Normal Data (DIST=NORMAL) for the one-sample design for details on how the DIST= NORMAL computations for means and standard deviations are transformed into the DIST= LOGNORMAL results for geometric means and CVs. As mentioned in the section Coefficient of Variation, the assumption of equal CVs on the lognormal scale is analogous to the assumption of equal variances on the normal scale.

Normal Ratio (DIST=NORMAL TEST=RATIO)

The distributional assumptions, equality of variances test, and within-class-level mean estimates ($\bar{y}_1$ and $\bar{y}_2$), standard deviation estimates ($s_1$ and $s_2$), standard errors ($\mr{SE_1}$ and $\mr{SE_2}$), and confidence limits for means and standard deviations are the same as in the section Normal Difference (DIST=NORMAL TEST=DIFF) for the two-independent-sample design.

The mean ratio $\mu _1 / \mu _2 = \mu _ r$ is estimated by

\[ \hat{\mu }_ r = \bar{y}_1 / \bar{y}_2 \]

No estimates or confidence intervals for the ratio of standard deviations are computed.

Under the assumption of equal variances ($\sigma _1^2 = \sigma _2^2$), the pooled confidence interval for the mean ratio is the Fieller (1954) confidence interval, extended to accommodate weights. Let

\begin{align*} a_ p & = \frac{s_ p^2 t^2_{1-\frac{\alpha }{2}, n_1+n_2-2}}{\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}} - \bar{y}^2_2 \\ b_ p & = \bar{y}_1 \bar{y}_2 \\ c_ p & = \frac{s_ p^2 t^2_{1-\frac{\alpha }{2}, n_1+n_2-2}}{\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}} - \bar{y}^2_1 \end{align*}

where $s_ p$ is the pooled standard deviation defined in the section Normal Difference (DIST=NORMAL TEST=DIFF) for the two-independent-sample design. If $a_ p \ge 0$ (which occurs when $\bar{y}_2$ is too close to zero), then the pooled two-sided 100(1 – $\alpha $)% Fieller confidence interval for $\mu _ r$ does not exist. If $a < 0$, then the interval is

\[ \left( -\frac{b_ p}{a_ p} + \frac{\left( b_ p^2 - a_ p c_ p \right)^\frac {1}{2}}{a_ p} \; \; , -\frac{b_ p}{a_ p} - \frac{\left( b_ p^2 - a_ p c_ p \right)^\frac {1}{2}}{a_ p} \; \; \right) \]

For the one-sided intervals, let

\begin{align*} a_ p^\star & = \frac{s_ p^2 t^2_{1-\alpha , n_1+n_2-2}}{\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}} - \bar{y}^2_2 \\ c_ p^\star & = \frac{s_ p^2 t^2_{1-\alpha , n_1+n_2-2}}{\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}} - \bar{y}^2_1 \end{align*}

which differ from $a_ p$ and $c_ p$ only in the use of $\alpha $ in place of $\alpha /2$. If $a_ p^\star \ge 0$, then the pooled one-sided 100(1 – $\alpha $)% Fieller confidence intervals for $\mu _ r$ do not exist. If $a_ p^\star < 0$, then the intervals are

\begin{align*} \left( -\infty \; \; , -\frac{b_ p}{a_ p^\star } - \frac{\left( b_ p^2 - a_ p^\star c_ p^\star \right)^\frac {1}{2}}{a_ p^\star } \; \; \right) & , \; \; \mbox{SIDES=L} \\ \left( -\frac{b_ p}{a_ p^\star } + \frac{\left( b_ p^2 - a_ p^\star c_ p^\star \right)^\frac {1}{2}}{a_ p^\star } \; \; , \; \; \infty \right) & , \; \; \mbox{SIDES=U} \end{align*}

The pooled t test assuming equal variances is the Sasabuchi (1988a, 1988b) test. The hypothesis $H_0\colon \mu _ r = \mu _0$ is rewritten as $H_0\colon \mu _1 - \mu _0\mu _2 = 0$, and the pooled t test in the section Normal Difference (DIST=NORMAL TEST=DIFF) for the two-independent-sample design is conducted on the original $y_{1i}$ values ($i \in \{ 1, \ldots , n_1^\star \} $) and transformed values of $y_{2i}$

\[ y^\star _{2i} = \mu _0 y_{2i} \; \; , \; \; i \in \{ 1, \ldots , n_2^\star \} \]

with a null difference of 0. The t value for the Sasabuchi pooled test is computed as

\[ t_ p = \frac{\bar{y}_1 - \mu _0 \bar{y}_2}{s_ p \left( \frac{1}{\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}} + \frac{\mu _0^2}{\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}} \right)^\frac {1}{2}} \]

The p-value of the test is computed as

\[ p\mbox{-value} = \left\{ \begin{array}{ll} P \left( t_ p^2 > F_{1-\alpha , 1, n_1+n_2-2} \right) \; \; , & \mbox{2-sided} \\ P \left( t_ p < t_{\alpha , n_1+n_2-2} \right) \; \; , & \mbox{lower 1-sided} \\ P \left( t_ p > t_{1-\alpha , n_1+n_2-2} \right) \; \; , & \mbox{upper 1-sided} \\ \end{array} \right. \]

Under the assumption of unequal variances, the unpooled Satterthwaite-based confidence interval for the mean ratio $\mu _ r$ is computed according to the method in Dilba, Schaarschmidt, and Hothorn (2007, the section "Two-sample Problem" on page 20), extended to accommodate weights. The degrees of freedom for the confidence interval are based on the same approximation as in Tamhane and Logan (2004) for the unpooled t test but with the null mean ratio $\mu _0$ replaced by the maximum likelihood estimate $\hat{\mu }_ r = \bar{y}_1 / \bar{y}_2$:

\[ \mr{df}_ u = \frac{\left( \frac{s^2_1}{\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}} + \frac{\hat{\mu }_ r^2 s^2_2}{\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}} \right)^2}{\frac{s^4_1}{(n_1-1)\left(\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}\right)^2} + \frac{\hat{\mu }_ r^4 s^4_2}{(n_2-1)\left(\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}\right)^2}} \]

Let

\begin{align*} a_ u & = \frac{s_2^2 t^2_{1-\frac{\alpha }{2}, \mr{df}_ u}}{\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}} - \bar{y}^2_2 \\ b_ u & = \bar{y}_1 \bar{y}_2 \\ c_ u & = \frac{s_1^2 t^2_{1-\frac{\alpha }{2}, \mr{df}_ u}}{\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}} - \bar{y}^2_1 \end{align*}

where $s_1$ and $s_2$ are the within-class-level standard deviations defined in the section Normal Difference (DIST=NORMAL TEST=DIFF) for the two-independent-sample design. If $a_ u \ge 0$ (which occurs when $\bar{y}_2$ is too close to zero), then the unpooled Satterthwaite-based two-sided 100(1 – $\alpha $)% confidence interval for $\mu _ r$ does not exist. If $a_ u < 0$, then the interval is

\[ \left( -\frac{b_ u}{a_ u} + \frac{\left( b_ u^2 - a_ u c_ u \right)^\frac {1}{2}}{a_ u} \; \; , -\frac{b_ u}{a_ u} - \frac{\left( b_ u^2 - a_ u c_ u \right)^\frac {1}{2}}{a_ u} \; \; \right) \]

The t test assuming unequal variances is the test derived in Tamhane and Logan (2004). The hypothesis $H_0\colon \mu _ r = \mu _0$ is rewritten as $H_0\colon \mu _1 - \mu _0\mu _2 = 0$, and the Satterthwaite t test in the section Normal Difference (DIST=NORMAL TEST=DIFF) for the two-independent-sample design is conducted on the original $y_{1i}$ values ($i \in \{ 1, \ldots , n_1^\star \} $) and transformed values of $y_{2i}$

\[ y^\star _{2i} = \mu _0 y_{2i} \; \; , \; \; i \in \{ 1, \ldots , n_2^\star \} \]

with a null difference of 0. The degrees of freedom are computed as

\[ \mr{df}_ u = \frac{\left( \frac{s^2_1}{\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}} + \frac{\mu _0^2 s^2_2}{\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}} \right)^2}{\frac{s^4_1}{(n_1-1)\left(\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}\right)^2} + \frac{\mu _0^4 s^4_2}{(n_2-1)\left(\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}\right)^2}} \]

The t value for the Satterthwaite-based unpooled test is computed as

\[ t_ u = \frac{\bar{y}_1 - \mu _0 \bar{y}_2}{\left( \frac{s^2_1}{\sum _{i=1}^{n^\star _1} f_{1i} w_{1i}} + \frac{\mu _0^2 s^2_2}{\sum _{i=1}^{n^\star _2} f_{2i} w_{2i}} \right)^\frac {1}{2}} \]

The p-value of the test is computed as

\[ p\mbox{-value} = \left\{ \begin{array}{ll} P \left( t_ u^2 > F_{1-\alpha , 1, \mr{df}_ u^\star } \right) \; \; , & \mbox{2-sided} \\ P \left( t_ u < t_{\alpha , \mr{df}_ u^\star } \right) \; \; , & \mbox{lower 1-sided} \\ P \left( t_ u > t_{1-\alpha , \mr{df}_ u^\star } \right) \; \; , & \mbox{upper 1-sided} \\ \end{array} \right. \]