NAG Library Routine Document
G01ABF
1 Purpose
G01ABF computes the means, standard deviations, corrected sums of squares and products, maximum and minimum values, and the product-moment correlation coefficient for two variables. Unequal weighting may be given.
2 Specification
INTEGER |
N, IWT, IFAIL |
REAL (KIND=nag_wp) |
X1(N), X2(N), WT(N), RES(13) |
|
3 Description
The data consist of two samples of observations, denoted by , and , for , with corresponding weights , for .
If no specific weighting is given, then each is set to in G01ABF.
The quantities calculated are:
(a) |
The sum of weights,
|
(b) |
The means,
|
(c) |
The corrected sums of squares and products
|
(d) |
The standard deviations
|
(e) |
The product-moment correlation coefficient
|
(f) |
The minimum and maximum elements in each of the two samples. |
(g) |
The number of pairs of observations, , for which , i.e., the number of valid observations. The quantities in (d) and (e) above will only be computed if . All other items are computed if . |
4 References
None.
5 Parameters
- 1: – INTEGERInput
-
On entry: , the number of pairs of observations.
Constraint:
.
- 2: – REAL (KIND=nag_wp) arrayInput
-
On entry: the observations from the first sample,
, for .
- 3: – REAL (KIND=nag_wp) arrayInput
-
On entry: the observations from the second sample,
, for .
- 4: – INTEGERInput/Output
-
On entry: indicates whether user-supplied weights are provided by you:
- Indicates that user-supplied weights are given in the array WT.
- Indicates that user-supplied weights are not given. In this case the routine assigns the value to each element of the weight array, WT.
On exit: is used to indicate the number of valid observations,
; see
Section 3(g), above.
- 5: – REAL (KIND=nag_wp) arrayInput/Output
-
On entry: if weights are being supplied then the elements of
WT must contain the weights associated with the observations,
, for
.
Constraint:
if , , for .
On exit: if
, the elements of
WT are unchanged, otherwise each element of
WT will be assigned the value
.
- 6: – REAL (KIND=nag_wp) arrayOutput
-
On exit: the elements of
RES contain the following results:
| mean of the first sample, ; |
| mean of the second sample, ; |
| standard deviation of the first sample, ; |
| standard deviation of the second sample, ; |
| corrected sum of squares of the first sample, ; |
| corrected sum of products of the two samples, ; |
| corrected sum of squares of the second sample, ; |
| product-moment correlation coefficient, ; |
| minimum of the first sample; |
| maximum of the first sample; |
| minimum of the second sample; |
| maximum of the second sample; |
| sum of weights, (, if
,
on entry). |
- 7: – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
-
-
The number of valid cases, , is , hence the standard deviation, 3(d), and the product-moment correlation coefficient, 3(e), cannot be calculated.
-
The number of valid cases, , is , or at least one of the weights is negative.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
The method used is believed to be stable.
8 Parallelism and Performance
Not applicable.
The time taken by G01ABF increases linearly with .
10 Example
In the program below, NPROB determines the number of datasets to be analysed. For each analysis, a set of observations and, optionally, weights, is read and printed. After calling G01ABF, all the calculated quantities are printed. In the example, there is one set of data, with (unweighted) pairs of observations.
10.1 Program Text
Program Text (g01abfe.f90)
10.2 Program Data
Program Data (g01abfe.d)
10.3 Program Results
Program Results (g01abfe.r)