g07cac computes a $t$-test statistic to test for a difference in means between two Normal populations, together with a confidence interval for the difference between the means.
The function may be called by the names: g07cac, nag_univar_ttest_2normal or nag_2_sample_t_test.
3Description
Consider two independent samples, denoted by $X$ and $Y$, of size ${n}_{x}$ and ${n}_{y}$ drawn from two Normal populations with means ${\mu}_{x}$ and ${\mu}_{y}$, and variances ${\sigma}_{x}^{2}$ and ${\sigma}_{y}^{2}$ respectively. Denote the sample means by $\overline{x}$ and $\overline{y}$ and the sample variances by ${s}_{x}^{2}$ and ${s}_{y}^{2}$ respectively.
g07cac calculates a test statistic and its significance level to test the null hypothesis ${H}_{0}:{\mu}_{x}={\mu}_{y}$, together with upper and lower confidence limits for ${\mu}_{x}-{\mu}_{y}$. The test used depends on whether or not the two population variances are assumed to be equal.
1.It is assumed that the two variances are equal, that is ${\sigma}_{x}^{2}={\sigma}_{y}^{2}$.
The test used is the two sample $t$-test. The test statistic $t$ is defined by;
where ${t}_{1-\alpha /2}$ is the $100(1-\alpha /2)$ percentage point of the $t$-distribution with $({n}_{x}+{n}_{y}-2)$ degrees of freedom.
2.It is not assumed that the two variances are equal.
If the population variances are not equal the usual two sample $t$-statistic no longer has a $t$-distribution and an approximate test is used.
This problem is often referred to as the Behrens–Fisher problem, see Kendall and Stuart (1979). The test used here is based on Satterthwaites procedure. To test the null hypothesis the test statistic ${t}^{\prime}$ is used where
The test of ${H}_{0}$ is carried out against one of the three alternative hypotheses described above, replacing $t\times {t}^{\prime}$ and ${t}_{\mathrm{obs}}\times {t}_{\mathrm{obs}}^{\prime}$.
Upper and lower $100(1-\alpha )$% confidence limits for ${\mu}_{x}-{\mu}_{y}$ are calculated as:
On entry, ${\mathbf{nx}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{nx}}\ge 2$.
On entry, ${\mathbf{ny}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{ny}}\ge 2$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_REAL_ARG_GE
On entry, clevel must not be greater than or equal to 1.0: ${\mathbf{clevel}}=\u27e8\mathit{\text{value}}\u27e9$.
NE_REAL_ARG_LE
On entry, clevel must not be less than or equal to 0.0: ${\mathbf{clevel}}=\u27e8\mathit{\text{value}}\u27e9$.
On entry, xstd must not be less than or equal to 0.0: ${\mathbf{xstd}}=\u27e8\mathit{\text{value}}\u27e9$.
On entry, ystd must not be less than or equal to 0.0: ${\mathbf{ystd}}=\u27e8\mathit{\text{value}}\u27e9$.
7Accuracy
The computed probability and the confidence limits should be accurate to approximately five significant figures.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
g07cac is not threaded in any implementation.
9Further Comments
The sample means and standard deviations can be computed using g01atc.
10Example
The following example program reads the two sample sizes and the sample means and standard deviations for two independent samples. The data is taken from page 116 of Snedecor and Cochran (1967) from a test to compare two methods of estimating the concentration of a chemical in a vat. A test of the equality of the means is carried out first assuming that the two population variances are equal and then making no assumption about the equality of the population variances.