NAG Library Routine Document
G02CEF
1 Purpose
G02CEF takes selected elements from two vectors (typically vectors of means and standard deviations) to form two smaller vectors, and selected rows and columns from two matrices (typically either matrices of sums of squares and cross-products of deviations from means and Pearson product-moment correlation coefficients, or matrices of sums of squares and cross-products about zero and correlation-like coefficients) to form two smaller matrices, allowing reordering of elements in the process.
2 Specification
SUBROUTINE G02CEF ( |
N, XBAR, STD, SSP, LDSSP, R, LDR, M, KORDER, XBAR2, STD2, SSP2, LDSSP2, R2, LDR2, IFAIL) |
INTEGER |
N, LDSSP, LDR, M, KORDER(M), LDSSP2, LDR2, IFAIL |
REAL (KIND=nag_wp) |
XBAR(N), STD(N), SSP(LDSSP,N), R(LDR,N), XBAR2(M), STD2(M), SSP2(LDSSP2,M), R2(LDR2,M) |
|
3 Description
Input to the routine consists of:
(a) |
A vector of means:
where is the number of input variables. |
(b) |
A vector of standard deviations:
|
(c) |
A matrix of sums of squares and cross-products of deviations from means:
|
(d) |
A matrix of correlation coefficients:
|
(e) |
The number of variables, , in the required subset, and their row/column numbers in the input data, ,
|
New vectors and matrices are output containing the following information:
(i) |
A vector of means:
|
(ii) |
A vector of standard deviations:
|
(iii) |
A matrix of sums of squares and cross-products of deviations from means:
|
(iv) |
A matrix of correlation coefficients:
|
Note: for sums of squares of cross-products of deviations about zero and correlation-like coefficients
and
should be replaced by
and
in the description of the input and output above.
4 References
None.
5 Parameters
- 1: N – INTEGERInput
On entry: , the number of variables in the input data.
Constraint:
.
- 2: XBAR(N) – REAL (KIND=nag_wp) arrayInput
On entry: must be set to , the mean of variable , for .
- 3: STD(N) – REAL (KIND=nag_wp) arrayInput
On entry: must be set to , the standard deviation of variable , for .
- 4: SSP(LDSSP,N) – REAL (KIND=nag_wp) arrayInput
On entry: must be set to the sum of cross-products of deviations from means (or about zero, ) for variables and , for and .
- 5: LDSSP – INTEGERInput
On entry: the first dimension of the array
SSP as declared in the (sub)program from which G02CEF is called.
Constraint:
.
- 6: R(LDR,N) – REAL (KIND=nag_wp) arrayInput
On entry: must be set to the Pearson product-moment correlation coefficient (or the correlation-like coefficient, ) for variables and , for and .
- 7: LDR – INTEGERInput
On entry: the first dimension of the array
R as declared in the (sub)program from which G02CEF is called.
Constraint:
.
- 8: M – INTEGERInput
On entry: the number of variables , required in the reduced vectors and matrices.
Constraint:
.
- 9: KORDER(M) – INTEGER arrayInput
On entry: must be set to the number of the original variable which is to be the th variable in the output vectors and matrices, for .
Constraint:
, for .
- 10: XBAR2(M) – REAL (KIND=nag_wp) arrayOutput
On exit: the mean of variable
,
, where
, for
. (The array
XBAR2 must differ from
XBAR and
STD.)
- 11: STD2(M) – REAL (KIND=nag_wp) arrayOutput
On exit: the standard deviation of variable
,
, where
, for
. (The array
STD2 must differ from both
XBAR and
STD.)
- 12: SSP2(LDSSP2,M) – REAL (KIND=nag_wp) arrayOutput
On exit:
contains the value of
, where
and
, for
and
. (The array
SSP2 must differ from both
SSP and
R.)
That is to say: on exit, contains the sum of cross-products of deviations from means (or about zero, ).
- 13: LDSSP2 – INTEGERInput
On entry: the first dimension of the array
SSP2 as declared in the (sub)program from which G02CEF is called.
Constraint:
.
- 14: R2(LDR2,M) – REAL (KIND=nag_wp) arrayOutput
On exit:
contains the value of
, where
and
, for
and
. (The array
R2 must differ from both
SSP and
R.)
That is to say: on exit, contains the Pearson product-moment coefficient (or the correlation-like coefficient, ).
- 15: LDR2 – INTEGERInput
On entry: the first dimension of the array
R2 as declared in the (sub)program from which G02CEF is called.
Constraint:
.
- 16: 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).
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:
On entry, | , |
or | , |
or | , |
or | . |
On entry, | , |
or | for some . |
7 Accuracy
Not applicable.
The time taken by G02CEF depends on and .
The routine is intended primarily for use when a subset of variables from a larger set of variables is to be used in a regression, and is described accordingly. There is however no reason why the routine should not also be used to select specific rows and columns from vectors and arrays which contain any other non-statistical information; the matrices need not be symmetric.
The routine may be used either with sums of squares and cross-products of deviations from means and Pearson product-moment correlation coefficients in connection with a regression involving a constant, or with sums of squares and cross-products about zero and correlation-like coefficients in connection with a regression with no constant.
9 Example
This example reads in the means, standard deviations, sums of squares and cross-products, and correlation coefficients for four variables. New vectors and matrices are created containing the means, standard deviations, sums of squares and cross-products, and correlation coefficients for the fourth, first and second variables (in that order). Finally these new vectors and matrices are printed.
9.1 Program Text
Program Text (g02cefe.f90)
9.2 Program Data
Program Data (g02cefe.d)
9.3 Program Results
Program Results (g02cefe.r)