G02CFF (PDF version)
G02 Chapter Contents
G02 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G02CFF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

G02CFF reorders the elements in two vectors (typically vectors of means and standard deviations), and the rows and columns in 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).

2  Specification

SUBROUTINE G02CFF ( N, KORDER, XBAR, STD, SSP, LDSSP, R, LDR, KWORK, IFAIL)
INTEGER  N, KORDER(N), LDSSP, LDR, KWORK(N), IFAIL
REAL (KIND=nag_wp)  XBAR(N), STD(N), SSP(LDSSP,N), R(LDR,N)

3  Description

Input to the routine consists of:
(a) A list of the order in which the n variables are to be arranged on exit:
i1,i2,i3,,in.
(b) A vector of means:
x-1,x-2,x-3,,x-n .
(c) A vector of standard deviations:
s1,s2,s3,,sn.
(d) A matrix of sums of squares and cross-products of deviations from means:
S11 S12 S13 . . . S1n S21 S22 . S31 . . . . . . . Sn1 Sn2 . . . . Snn .
(e) A matrix of correlation coefficients:
R11 R12 R13 . . . R1n R21 R22 . R31 . . . . . . . Rn1 Rn2 . . . . Rnn .
On exit from the routine, these same vectors and matrices are reordered, in the manner specified, and contain the following information:
(i) The vector of means:
x-i1,x-i2,x-i3,,x-in .
(ii) The vector of standard deviations:
si1,si2,si3,sin.
(iii) The matrix of sums of squares and cross-products of deviations from means:
Si1i1 Si1i2 Si1i3 . . . Si1in Si2i1 Si2i2 . Si3i1 . . . . . . . Sini1 Sini2 . . . . Sinin .
(iv) The matrix of correlation coefficients:
Ri1i1 Ri1i2 Ri1i3 . . . Ri1in Ri2i1 Ri2i2 . Ri3i1 . . . . . . . Rini1 Rini2 . . . . Rinin .
Note:  for sums of squares of cross-products of deviations about zero and correlation-like coefficients Sij and Rij should be replaced by S~ij and R~ij in the description of the input and output above.

4  References

None.

5  Parameters

1:     N – INTEGERInput
On entry: n, the number of variables in the input data.
Constraint: N2.
2:     KORDER(N) – INTEGER arrayInput
On entry: KORDERi must be set to the number of the original variable which is to be the ith variable in the re-arranged data, for i=1,2,,n.
Constraint: 1KORDERiN, for i=1,2,,n.
3:     XBAR(N) – REAL (KIND=nag_wp) arrayInput/Output
On entry: XBARi must be set to the mean of variable i, for i=1,2,,n.
On exit: XBARi contains the mean of variable k where k=KORDERi, for i=1,2,,n.
4:     STD(N) – REAL (KIND=nag_wp) arrayInput/Output
On entry: STDi must be set to the standard deviation of variable i, for i=1,2,,n.
On exit: STDi contains the standard deviation of variable k where k=KORDERi, for i=1,2,,n.
5:     SSP(LDSSP,N) – REAL (KIND=nag_wp) arrayInput/Output
On entry: SSPij must be set to the sum of cross-products of deviations from means Sij (or about zero S~ij) for variables i and j, for i=1,2,,n and j=1,2,,n.
On exit: SSPij contains the sum of cross-products of deviations from means Skl (or about zero S~kl) for variables k and l, where k=KORDERi, and l=KORDERj, i,j=1,2,,n.
6:     LDSSP – INTEGERInput
On entry: the first dimension of the array SSP as declared in the (sub)program from which G02CFF is called.
Constraint: LDSSPN.
7:     R(LDR,N) – REAL (KIND=nag_wp) arrayInput/Output
On entry: Rij must be set to the Pearson product-moment correlation coefficient Rij (or the correlation-like coefficient R~ij) for variables i and j, for i=1,2,,n and j=1,2,,n.
On exit: Rij contains the Pearson product-moment correlation coefficient Rkl (or the correlation-like coefficient R~kl) for variables k and l, where k=KORDERi and l=KORDERj, for i=1,2,,n and j=1,2,,n.
8:     LDR – INTEGERInput
On entry: the first dimension of the array R as declared in the (sub)program from which G02CFF is called.
Constraint: LDRN.
9:     KWORK(N) – INTEGER arrayWorkspace
10:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. 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 -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry,N<2.
IFAIL=2
On entry,LDSSP<N,
orLDR<N.
IFAIL=3
On entry,KORDERi<1,
orKORDERi>N for some i=1,2,,n.
IFAIL=4
On entry, there is not a one-to-one correspondence between the old variables and the new variables; at least one of the original variables is not included in the new set, and consequently at least one other variable has been included more than once.

7  Accuracy

Not applicable.

8  Further Comments

The time taken by G02CFF depends on n and the amount of re-arrangement involved.
The routine is intended primarily for use when a set of variables is to be reordered for use in a regression, and is described accordingly. There is however no reason why the routine should not also be used to reorder vectors and matrices 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 three variables. The vectors and matrices are reordered so that they contain the means, standard deviations, sums of squares and cross-products, and correlation coefficients for the first, third and second variables (in that order). Finally the reordered vectors and matrices are printed.

9.1  Program Text

Program Text (g02cffe.f90)

9.2  Program Data

Program Data (g02cffe.d)

9.3  Program Results

Program Results (g02cffe.r)


G02CFF (PDF version)
G02 Chapter Contents
G02 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012