3 Description

Consider two independent samples, denoted by X and Y, of size nx and ny drawn from two Normal populations with means μx and μy, and variances σx2 and σy2 respectively. Denote the sample means by x- and y- and the sample variances by sx2 and sy2 respectively.

nag_2_sample_t_test (g07cac) calculates a test statistic and its significance level to test the null hypothesis H0:μx=μy, together with upper and lower confidence limits for μx-μ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 σx2=σy2.

The test used is the two sample t-test. The test statistic t is defined by;

tobs=x--y-s1/nx+1/ny

where s2=nx-1sx2+ny-1sy2nx+ny-2 is the pooled variance of the two samples.

Under the null hypothesis H0 this test statistic has a t-distribution with nx+ny-2 degrees of freedom.

The test of H0 is carried out against one of three possible alternatives:

(i)

H1:μx≠μy; the significance level, p=Pt≥tobs, i.e., a two tailed probability.

where t1-α/2 is the 1001-α/2 percentage point of the t-distribution with nx+ny-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′ is used where

tobs′=x--y-sex--y-

where sex--y-x--y-=sx2nx+sy2ny.

A t-distribution with f degrees of freedom is used to approximate the distribution of t′ where

f=se⁡x--y-4sx2/nx2nx-1+sy2/ny2ny-1.

The test of H0 is carried out against one of the three alternative hypotheses described above, replacing t by t′ and tobs by tobs′.

8 Parallelism and Performance

9 Further Comments

10 Example

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.