G03ZAF (PDF version)
G03 Chapter Contents
G03 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G03ZAF

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

G03ZAF produces standardized values (z-scores) for a data matrix.

2  Specification

SUBROUTINE G03ZAF ( N, M, X, LDX, NVAR, ISX, S, E, Z, LDZ, IFAIL)
INTEGER  N, M, LDX, NVAR, ISX(M), LDZ, IFAIL
REAL (KIND=nag_wp)  X(LDX,M), S(M), E(M), Z(LDZ,NVAR)

3  Description

For a data matrix, X, consisting of n observations on p variables, with elements xij, G03ZAF computes a matrix, Z, with elements zij such that:
zij=xij-μjσj,  i=1,2,,n;  j=1,2,,p,  
where μj is a location shift and σj is a scaling factor. Typically, μj will be the mean and σj will be the standard deviation of the jth variable and therefore the elements in column j of Z will have zero mean and unit variance.

4  References

None.

5  Parameters

1:     N – INTEGERInput
On entry: n, the number of observations in the data matrix.
Constraint: N1.
2:     M – INTEGERInput
On entry: the number of variables in the data array X.
Constraint: MNVAR.
3:     XLDXM – REAL (KIND=nag_wp) arrayInput
On entry: Xij must contain the ith sample point for the jth variable, xij, for i=1,2,,n and j=1,2,,M.
4:     LDX – INTEGERInput
On entry: the first dimension of the array X as declared in the (sub)program from which G03ZAF is called.
Constraint: LDXN.
5:     NVAR – INTEGERInput
On entry: p, the number of variables to be standardized.
Constraint: NVAR1.
6:     ISXM – INTEGER arrayInput
On entry: ISXj indicates whether or not the observations on the jth variable are included in the matrix of standardized values.
If ISXj0, the observations from the jth variable are included.
If ISXj=0, the observations from the jth variable are not included.
Constraint: ISXj0 for NVAR values of j.
7:     SM – REAL (KIND=nag_wp) arrayInput
On entry: if ISXj0, Sj must contain the scaling (standard deviation), σj, for the jth variable.
If ISXj=0, Sj is not referenced.
Constraint: if ISXj0, Sj>0.0, for j=1,2,,M.
8:     EM – REAL (KIND=nag_wp) arrayInput
On entry: if ISXj0, Ej must contain the location shift (mean), μj, for the jth variable.
If ISXj=0, Ej is not referenced.
9:     ZLDZNVAR – REAL (KIND=nag_wp) arrayOutput
On exit: the matrix of standardized values (z-scores), Z.
10:   LDZ – INTEGERInput
On entry: the first dimension of the array Z as declared in the (sub)program from which G03ZAF is called.
Constraint: LDZN.
11:   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<1,
orNVAR<1,
orM<NVAR,
orLDX<N,
orLDZ<N.
IFAIL=2
On entry,there are not precisely NVAR elements of ISX0.
IFAIL=3
On entry,ISXj0 and Sj0.0 for some j.
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

Standard accuracy is achieved.

8  Parallelism and Performance

Not applicable.

9  Further Comments

Means and standard deviations may be obtained using G01ATF or G02BXF.

10  Example

A 4 by 3 data matrix is input along with location and scaling values. The first and third columns are scaled and the results printed.

10.1  Program Text

Program Text (g03zafe.f90)

10.2  Program Data

Program Data (g03zafe.d)

10.3  Program Results

Program Results (g03zafe.r)


G03ZAF (PDF version)
G03 Chapter Contents
G03 Chapter Introduction
NAG Library Manual

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