hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_mv_z_scores (g03za)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


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


[z, ifail] = g03za(x, nvar, isx, s, e, 'n', n, 'm', m)
[z, ifail] = nag_mv_z_scores(x, nvar, isx, s, e, 'n', n, 'm', m)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 22: n was made optional


For a data matrix, X, consisting of n observations on p variables, with elements xij, nag_mv_z_scores (g03za) 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.




Compulsory Input Parameters

1:     xldxm – double array
ldx, the first dimension of the array, must satisfy the constraint ldxn.
xij must contain the ith sample point for the jth variable, xij, for i=1,2,,n and j=1,2,,m.
2:     nvar int64int32nag_int scalar
p, the number of variables to be standardized.
Constraint: nvar1.
3:     isxm int64int32nag_int array
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.
4:     sm – double array
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.
5:     em – double array
If isxj0, ej must contain the location shift (mean), μj, for the jth variable.
If isxj=0, ej is not referenced.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the first dimension of the array x.
n, the number of observations in the data matrix.
Constraint: n1.
2:     m int64int32nag_int scalar
Default: the dimension of the arrays isx, s, e and the second dimension of the array x. (An error is raised if these dimensions are not equal.)
The number of variables in the data array x.
Constraint: mnvar.

Output Parameters

1:     zldznvar – double array
The matrix of standardized values (z-scores), Z.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
On entry,n<1,
On entry,there are not precisely nvar elements of isx0.
On entry,isxj0 and sj0.0 for some j.
An unexpected error has been triggered by this routine. Please contact NAG.
Your licence key may have expired or may not have been installed correctly.
Dynamic memory allocation failed.


Standard accuracy is achieved.

Further Comments

Means and standard deviations may be obtained using nag_stat_summary_onevar (g01at) or nag_correg_corrmat (g02bx).


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.
function g03za_example

fprintf('g03za example results\n\n');

x = [15, 0, 1500;
     12, 1, 1000;
     18, 2, 1200;
     14, 3, 500];
nvar = int64(2);
isx = [int64(1);0;1];

% shift and scaling
s = [ 2.50;     0;    420.3];
e = [14.75;    0;    1050.0];

% Standardize
[z, ifail] = g03za( ...
		    x, nvar, isx, s, e);

mtitle = 'Standardized values';
matrix = 'General';
diag   = ' ';
[ifail] = x04ca( ...
                 matrix, diag, z, mtitle);

g03za example results

 Standardized values
             1          2
 1      0.1000     1.0707
 2     -1.1000    -0.1190
 3      1.3000     0.3569
 4     -0.3000    -1.3086

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

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