g07cac computes a -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 and , of size and drawn from two Normal populations with means and , and variances and respectively. Denote the sample means by and and the sample variances by and respectively.
g07cac calculates a test statistic and its significance level to test the null hypothesis , together with upper and lower confidence limits for . 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 .
The test used is the two sample -test. The test statistic is defined by;
where is the pooled variance of the two samples.
Under the null hypothesis this test statistic has a -distribution with degrees of freedom.
The test of is carried out against one of three possible alternatives:
(i); the significance level, , i.e., a two tailed probability.
(ii); the significance level, , i.e., an upper tail probability.
(iii); the significance level, , i.e., a lower tail probability.
Upper and lower % confidence limits for are calculated as:
where is the percentage point of the -distribution with 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 -statistic no longer has a -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 is used where
where .
A -distribution with degrees of freedom is used to approximate the distribution of where
The test of is carried out against one of the three alternative hypotheses described above, replacing and .
Upper and lower % confidence limits for are calculated as:
where is the percentage point of the -distribution with degrees of freedom.
4References
Johnson M G and Kotz A (1969) The Encyclopedia of Statistics2 Griffin
Kendall M G and Stuart A (1979) The Advanced Theory of Statistics (3 Volumes) (4th Edition) Griffin
Snedecor G W and Cochran W G (1967) Statistical Methods Iowa State University Press
5Arguments
1: – Nag_TailProbabilityInput
On entry: indicates which tail probability is to be calculated, and thus which alternative hypothesis is to be used.
The two tail probability, i.e., .
The upper tail probability, i.e., .
The lower tail probability, i.e., .
Constraint:
, or .
2: – Nag_PopVarInput
On entry: indicates whether the population variances are assumed to be equal or not.
The population variances are assumed to be equal, that is .
The population variances are not assumed to be equal.
Constraint:
or .
3: – IntegerInput
On entry: the size of the sample, .
Constraint:
.
4: – IntegerInput
On entry: the size of the sample, .
Constraint:
.
5: – doubleInput
On entry: the mean of the sample, .
6: – doubleInput
On entry: the mean of the sample, .
7: – doubleInput
On entry: the standard deviation of the sample, .
Constraint:
.
8: – doubleInput
On entry: the standard deviation of the sample, .
Constraint:
.
9: – doubleInput
On entry: the confidence level, , for the specified tail. For example will give a 95% confidence interval.
Constraint:
.
10: – double *Output
On exit: contains the test statistic, or .
11: – double *Output
On exit: contains the degrees of freedom for the test statistic.
12: – double *Output
On exit: contains the significance level, that is the tail probability, , as defined by tail.
13: – double *Output
On exit: contains the lower confidence limit for .
14: – double *Output
On exit: contains the upper confidence limit for .
15: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
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: .
NE_REAL_ARG_LE
On entry, clevel must not be less than or equal to 0.0: .
On entry, xstd must not be less than or equal to 0.0: .
On entry, ystd must not be less than or equal to 0.0: .
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.