TWOMV
Computes statistics for mean and variance inferences using samples from two normal populations.
Required Arguments
X — Vector of length NROWX containing observations from the first sample. (Input)
Y — Vector of length NROWY containing observations from the second sample. (Input)
STAT — Vector of length 25 containing the statistics.
(Output, if IDO = 0 or 1; input/output, if IDO = 2 or 3.) These are:
I
STAT(I)
1
Mean of the first sample
2
Mean of the second sample
3
Variance of the first sample
4
Variance of the second sample
5
Number of observations in the first sample
6
Number of observations in the second sample
(STAT(7) through STAT(14) depend on the assumption of equal variances.)
I
STAT(I)
7
Pooled variance
8
t value, assuming equal variances
9
Probability of a larger t in absolute value, assuming normality, equal means, and equal variance
10
Degrees of freedom assuming equal variances
11
Lower confidence limit for the mean of the first population minus the mean of the second, assuming equal variances
12
Upper confidence limit for the mean of the first population minus the mean of the second, assuming equal variances
13
Lower confidence limit for the common variance
14
Upper confidence limit for the common variance
(STAT(15) through STAT(19) use approximations that do not depend on an assumption of equal variances.)
I
STAT(I)
15
t value, assuming unequal variances.
16
Approximate probability of a larger t in absolute value, assuming normality, equal means, and unequal variances
17
Degrees of freedom assuming unequal variances, for Satterthwaite’s approximation
18
Approximate lower confidence limit for the mean of the first population minus the mean of the second, assuming equal variances
19
Approximate upper confidence limit for the mean of the first population minus the mean of the second, assuming equal variances
20
F value (greater than or equal to 1.0)
21
Probability of a larger F in absolute value, assuming normality and equal variances
22
Lower confidence limit for the ratio of the variance of the first population to the second
23
Upper confidence limit for the ratio of the variance of the first population to the second
24
Number of missing values of first sample
25
Number of missing values of second sample
Optional Arguments
IDO — Processing option. (Input)
Default: IDO = 0.
IDO
Action
0
This is the only invocation of TWOMV for this data set, and all the data are input at once.
1
This is the first invocation, and additional calls to TWOMV will be made. Initialization and updating are performed. The means are output correctly, but most of the other quantities output in STAT are intermediate quantities.
2
This is an intermediate invocation of TWOMV, and updating for the data in X and Y is performed.
3
This is the final invocation of this routine. Updating for the data in X and Y and wrap-up computations are performed.
NROWX — Absolute value of NROWX is the number of observations currently input in X. (Input)
Default: NROWX = size (X,1).
NROWX may be positive, zero, or negative. Negative NROWX means delete the ‑NROWX observations in X from the analysis.
NROWY — Absolute value of NROWY is the number of observations currently input in Y. (Input)
Default: NROWY = size (Y,1).
NROWY may be positive, zero, or negative. Negative NROWY means delete the ‑NROWY observations in Y from the analysis.
CONPRM — Confidence level for two-sided interval estimate of the mean of X minus the mean of Y (assuming normality of both populations), in percent. (Input)
Default: CONPRM = 95.0.
If CONPRM = 0, no confidence interval for the difference in the means is computed; otherwise, a CONPRM percent confidence interval is computed, in which case CONPRM must be between 0.0 and 100.0. CONPRM is often 90.0, 95.0, or 99.0. For a one-sided confidence interval with confidence level ONECL, set CONPRM = 100.0  2.0 * (100.0  ONECL).
CONPRV — Confidence level for inference on variances. (Input)
Default: CONPRV = 95.0.
Under the assumption of equal variances, the pooled variance is used to obtain a two-sided CONPRV percent confidence interval for the common variance in STAT(13) and STAT(14). Without making the assumption of equal variances, the ratio of the variances is of interest. A two-sided CONPRV percent confidence interval for the ratio of the variance of the first population (X) to that of the second population (assuming normality of both populations) is computed and stored in STAT(22) and STAT(23). The confidence intervals are symmetric in probability. See also the description of CONPRM.
IPRINT — Printing option. (Input)
If IPRINT = 0, no printing is performed; otherwise, various statistics in STAT are printed when IDO = 0 or 3.
Default: IPRINT = 0.
IPRINT
Action
0
No printing.
1
Simple statistics (STAT (1) to STAT(6), STAT(24), and STAT(25)).
2
Statistics for means, assuming equal variances.
3
Statistics for means, not assuming equal variances.
4
Statistics for variances.
5
All statistics.
FORTRAN 90 Interface
Generic: CALL TWOMV (X, Y, STAT [])
Specific: The specific interface names are S_TWOMV and D_TWOMV.
FORTRAN 77 Interface
Single: CALL TWOMV (IDO, NROWX, X, NROWY, Y, CONPRM, CONPRV, IPRINT, STAT)
Double: The double precision name is DTWOMV.
Description
The routine TWOMV computes the statistics for making inferences about the means and variances of two normal populations, using independent samples in X and Y. For inferences concerning parameters of a single normal population, see routine UVSTA. For two samples that are paired, see routine ATWOB (see Chapter 3, “Correlation”), since the pairs can be considered to be blocks.
Let μX and
be the mean and variance, respectively, of the first population, and μY and
be the corresponding quantities of the second population. The routine TWOMV is used for testing μX = μY and
or for setting confidence intervals for μX  μY and
The basic quantities in STAT(1) through STAT(4) are
where nx and ny are the respective sample sizes (in STAT(5) and STAT(6)).
Inferences about the Means
The test for the equality of means of two normal populations depends on whether or not the variances of the two populations can be considered equal. If the variances are equal, the test is the two-sample t test, which is equivalent to an analysis of variance test see (Chapter 4, “Analysis of Variance”). In this case, the statistics returned in STAT(7) through STAT(12) are appropriate for testing μX = μY. The pooled variance (in STAT(7)) is
The t statistic (in STAT(8)) is
For testing μX = μY + c, for some constant c, the confidence interval for μ X  μY can be used. (If the confidence interval includes c, the null hypothesis would not be rejected at the significance level 1  CONPRM/100.)
If the population variances are not equal, the ordinary t statistic does not have a t distribution; and several approximate tests for the equality of means have been proposed. (See, for example, Anderson and Bancroft 1952, and Kendall and Stuart 1979.) The name Fisher-Behrens is associated with this problem, and one of the earliest tests devised for this situation is the Fisher-Behrens test, based on Fisher’s concept of fiducial probability. Another test is called Satterthwaite’s procedure. The routine TWOMV computes the statistics for this approximation, which was suggested by H.F. Smith and modified by F.E. Satterthwaite (Anderson and Bancroft 1952, page 83). The test statistic is
where
Under the null hypothesis of equal population means, this quantity has an approximate t distribution with degrees of freedom f (in STAT(17)), given by
Inferences about the Variances
The F statistic for testing the equality of variances is given by
is the larger of
is the smaller. If the variances are equal, this quantity has an F distribution with nx  1 and ny  1 degrees of freedom.
It is generally not recommended that the results of the F test be used to decide whether to use the regular t test or the modified tʹ on a single set of data. The more conservative approach is to use the modified tʹ (Satterthwaite’s procedure) if there is doubt about the equality of the variances.
Examples
Example 1
This example is taken from Conover and Iman (1983, page 294). It involves scores on arithmetic tests of two grade school classes. The question is whether a group taught by an experimental method has a higher mean score. The data are shown below.
Scores for
Standard Group
Scores for
Experimental Group
72
111
75
118
77
128
80
138
104
140
110
150
125
163
 
164
 
169
It is assumed that the variances of the two populations are equal so the statistics of interest are in STAT(8) and STAT(9). It is seen from the output below that there is strong reason to believe that the two means are different (t-value of 4.804). Since the lower 97.5% confidence limit does not include zero, the null hypothesis that μx μy would be rejected at the 0.05 significance level. (The closeness of the values of the sample variances provides some qualitative substantiation of the assumption of equal variances.)
 
USE TWOMV_INT
 
IMPLICIT NONE
INTEGER IPRINT
REAL CONPRV, STAT(25), X(7), Y(9)
!
DATA X/72., 75., 77., 80., 104., 110., 125./Y/111., 118., 128., &
138., 140., 150., 163., 164., 169./
!
 
IPRINT = 2
CONPRV = 0.0
CALL TWOMV (X, Y, STAT, IPRINT=IPRINT, CONPRV=CONPRV)
END
Output
 
Mean Inferences Assuming Equal Variances
Pooled Variance 434.633
t Value -4.804
Probability of a Larger t in Abs. Value 0.000
Degrees of Freedom 14.000
Lower Confidence Limit Difference in Means -73.010
Upper Confidence Limit Difference in Means -27.942
Example 2
For a second example, the same data set is used to illustrate the use of the IDO parameter to bring in the data one observation at a time. Since there are more “Y” values than “X” values, NROWX is set to zero on the later calls to TWOMV.
 
USE TWOMV_INT
 
IMPLICIT NONE
INTEGER I, IDO, IPRINT, NROWX, NROWY
REAL STAT(25), X(7), Y(9)
!
DATA X/72., 75., 77., 80., 104., 110., 125./Y/111., 118., 128., &
138., 140., 150., 163., 164., 169./
!
IPRINT = 5
IDO = 1
NROWX = 1
NROWY = 1
DO 10 I=1, 7
! Bring in first seven observations
! on X and Y, one at a time.
CALL TWOMV (X(I:), Y(I:), STAT, IDO=IDO, NROWX=NROWX, &
NROWY=NROWY, IPRINT=IPRINT)
IDO = 2
10 CONTINUE
! Now bring in remaining observations
! on Y.
NROWX = 0
CALL TWOMV (X(1:), Y(8:), STAT, IDO=IDO, NROWX=NROWX, &
NROWY=NROWY, IPRINT=IPRINT)
! Set IDO to indicate last observation.
IDO = 3
CALL TWOMV (X(1:), Y(9:), STAT, IDO=IDO, NROWX=NROWX, &
NROWY=NROWY, IPRINT=IPRINT)
END
Output
 
Statistics from TWOMV
First Sample Mean 91.857
Second Sample Mean 142.333
First Sample Variance 435.810
Second Sample Variance 433.750
First Sample Valid Observations 7.000
Second Sample Valid Observations 9.000
First Sample Missing Values 0.000
Second Sample Missing Values 0.000
 
Mean Inferences Assuming Equal Variances
Pooled Variance 434.63
t Value -4.80
Probability of a Larger t in Abs. Value 0.00
Degrees of Freedom 14.00
Lower Confidence Limit Difference in Means -73.01
Upper Confidence Limit Difference in Means -27.94
Lower Confidence Limit for Common Variance 232.97
Upper Confidence Limit for Common Variance 1081.04
 
Mean Inferences Assuming Unequal Variances
t Value -4.8028
Approx. Prob. of a Larger t in Abs. Value 0.0003
Degrees of Freedom 13.0290
Lower Confidence Limit -73.1758
Upper Confidence Limit -27.7766
 
Variance Inferences
F Value 1.00475
Probability of a Larger F in Abs. Value 0.96571
Lower Confidence Limit for Variance Ratio 0.21600
Upper Confidence Limit for Variance Ratio 5.62621
Published date: 03/19/2020
Last modified date: 03/19/2020