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

NAG Library Routine Document

G02CEF

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

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:
x-1,x-2,x-3,,x-n,  
where n is the number of input variables.
(b) A vector of standard deviations:
s1,s2,s3,,sn.  
(c) A matrix of sums of squares and cross-products of deviations from means:
S11 S12 S13 . . . S1n S21 S22 S2n S31 . . . . . . . Sn1 Sn2 . . . . Snn .  
(d) A matrix of correlation coefficients:
R11 R12 R13 . . . R1n R21 R22 R2n R31 . . . . . . . Rn1 Rn2 . . . . Rnn .  
(e) The number of variables, m, in the required subset, and their row/column numbers in the input data, i1,i2,i3,,im,
iikn  for k=1,2,,mn2,m1  and  mn.  
New vectors and matrices are output containing the following information:
(i) A vector of means:
x-i1,x-i2,x-i3,,x-im.  
(ii) A vector of standard deviations:
si1,si2,si3,,sim.  
(iii) A matrix of sums of squares and cross-products of deviations from means:
Si1i1 Si1i2 Si1i3 . . . Si1im Si2i1 Si2i2 . Si3i1 . . . . . . . Simi1 Simi2 . . . . Simim .  
(iv) A matrix of correlation coefficients:
Ri1i1 Ri1i2 Ri1i3 . . . Ri1im Ri2i1 Ri2i2 . Ri3i1 . . . . . . . Rimi1 Rimi2 . . . . Rimim .  
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:     XBARN – REAL (KIND=nag_wp) arrayInput
On entry: XBARi must be set to x-i, the mean of variable i, for i=1,2,,n.
3:     STDN – REAL (KIND=nag_wp) arrayInput
On entry: STDi must be set to si, the standard deviation of variable i, for i=1,2,,n.
4:     SSPLDSSPN – REAL (KIND=nag_wp) arrayInput
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.
5:     LDSSP – INTEGERInput
On entry: the first dimension of the array SSP as declared in the (sub)program from which G02CEF is called.
Constraint: LDSSPN.
6:     RLDRN – REAL (KIND=nag_wp) arrayInput
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.
7:     LDR – INTEGERInput
On entry: the first dimension of the array R as declared in the (sub)program from which G02CEF is called.
Constraint: LDRN.
8:     M – INTEGERInput
On entry: the number of variables m, required in the reduced vectors and matrices.
Constraint: 1MN.
9:     KORDERM – INTEGER arrayInput
On entry: KORDERi must be set to the number of the original variable which is to be the ith variable in the output vectors and matrices, for i=1,2,,m.
Constraint: 1KORDERiN, for i=1,2,,m.
10:   XBAR2M – REAL (KIND=nag_wp) arrayOutput
On exit: the mean of variable i, XBARi, where i=KORDERk, for k=1,2,,m. (The array XBAR2 must differ from XBAR and STD.)
11:   STD2M – REAL (KIND=nag_wp) arrayOutput
On exit: the standard deviation of variable i, STDi, where i=KORDERk, for k=1,2,,m. (The array STD2 must differ from both XBAR and STD.)
12:   SSP2LDSSP2M – REAL (KIND=nag_wp) arrayOutput
On exit: SSP2kl contains the value of SSPij, where i=KORDERk and j=KORDERl, for k=1,2,,m and l=1,2,,m. (The array SSP2 must differ from both SSP and R.)
That is to say: on exit, SSP2kl contains the sum of cross-products of deviations from means Sij (or about zero, S~ij).
13:   LDSSP2 – INTEGERInput
On entry: the first dimension of the array SSP2 as declared in the (sub)program from which G02CEF is called.
Constraint: LDSSP2M.
14:   R2LDR2M – REAL (KIND=nag_wp) arrayOutput
On exit: R2kl contains the value of Rij, where i=KORDERk and j=KORDERl, for k=1,2,,m and l=1,2,,m. (The array R2 must differ from both SSP and R.)
That is to say: on exit, R2kl contains the Pearson product-moment coefficient Rij (or the correlation-like coefficient, R~ij).
15:   LDR2 – INTEGERInput
On entry: the first dimension of the array R2 as declared in the (sub)program from which G02CEF is called.
Constraint: LDR2M.
16:   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,
orM<1.
IFAIL=2
On entry,N<M.
IFAIL=3
On entry,LDSSP<N,
orLDR<N,
orLDSSP<M,
orLDR2<M.
IFAIL=4
On entry,KORDERi<1,
orKORDERi>N for some i=1,2,,m.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

Not applicable.

8  Parallelism and Performance

Not applicable.

9  Further Comments

The time taken by G02CEF depends on n and m.
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.

10  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.

10.1  Program Text

Program Text (g02cefe.f90)

10.2  Program Data

Program Data (g02cefe.d)

10.3  Program Results

Program Results (g02cefe.r)


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

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