G02BGF computes means and standard deviations, sums of squares and cross-products of deviations from means, and Pearson product-moment correlation coefficients for selected variables.
SUBROUTINE G02BGF ( |
N, M, X, LDX, NVARS, KVAR, XBAR, STD, SSP, LDSSP, R, LDR, IFAIL) |
INTEGER |
N, M, LDX, NVARS, KVAR(NVARS), LDSSP, LDR, IFAIL |
REAL (KIND=nag_wp) |
X(LDX,M), XBAR(NVARS), STD(NVARS), SSP(LDSSP,NVARS), R(LDR,NVARS) |
|
The input data consist of
observations for each of
variables, given as an array
where
is the
th observation on the
th variable, together with the subset of these variables,
, for which information is required.
The quantities calculated are:
(a) |
Means:
|
(b) |
Standard deviations:
|
(c) |
Sums of squares and cross-products of deviations from zero:
|
(d) |
Pearson product-moment correlation coefficients:
If or is zero, is set to zero. |
None.
- 1: N – INTEGERInput
On entry: , the number of observations or cases.
Constraint:
.
- 2: M – INTEGERInput
On entry: , the number of variables.
Constraint:
.
- 3: X(LDX,M) – REAL (KIND=nag_wp) arrayInput
On entry: must be set to , the value of the th observation on the th variable, for and .
- 4: LDX – INTEGERInput
On entry: the first dimension of the array
X as declared in the (sub)program from which G02BGF is called.
Constraint:
.
- 5: NVARS – INTEGERInput
On entry: , the number of variables for which information is required.
Constraint:
.
- 6: KVAR(NVARS) – INTEGER arrayInput
On entry:
must be set to the column number in
X of the
th variable for which information is required, for
.
Constraint:
, for .
- 7: XBAR(NVARS) – REAL (KIND=nag_wp) arrayOutput
On exit: the mean value,
, of the variable specified in , for .
- 8: STD(NVARS) – REAL (KIND=nag_wp) arrayOutput
On exit: the standard deviation,
, of the variable specified in , for .
- 9: SSP(LDSSP,NVARS) – REAL (KIND=nag_wp) arrayOutput
On exit: is the cross-product of deviations, , for the variables specified in and , for and .
- 10: LDSSP – INTEGERInput
On entry: the first dimension of the array
SSP as declared in the (sub)program from which G02BGF is called.
Constraint:
.
- 11: R(LDR,NVARS) – REAL (KIND=nag_wp) arrayOutput
On exit: is the product-moment correlation coefficient, , between the variables specified in and , for and .
- 12: LDR – INTEGERInput
On entry: the first dimension of the array
R as declared in the (sub)program from which G02BGF is called.
Constraint:
.
- 13: IFAIL – 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).
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
The routine uses a two pass algorithm.
This example reads in a set of data consisting of five observations on each of four variables. The means, standard deviations, sums of squares and cross-products of deviations from means, and Pearson product-moment correlation coefficients for the fourth, first and second variables are then calculated and printed.