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)

Purpose

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

Syntax

[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:
Mark 22: n has been made optional
.

Description

For a data matrix, XX, consisting of nn observations on pp variables, with elements xijxij, nag_mv_z_scores (g03za) computes a matrix, ZZ, with elements zijzij such that:
zij = (xijμj)/(σj),  i = 1,2,,n;  j = 1,2,,p,
zij=xij-μjσj,  i=1,2,,n;  j=1,2,,p,
where μjμj is a location shift and σjσj is a scaling factor. Typically, μjμj will be the mean and σjσj will be the standard deviation of the jjth variable and therefore the elements in column jj of ZZ will have zero mean and unit variance.

References

None.

Parameters

Compulsory Input Parameters

1:     x(ldx,m) – double array
ldx, the first dimension of the array, must satisfy the constraint ldxnldxn.
x(i,j)xij must contain the iith sample point for the jjth variable, xijxij, for i = 1,2,,ni=1,2,,n and j = 1,2,,mj=1,2,,m.
2:     nvar – int64int32nag_int scalar
pp, the number of variables to be standardized.
Constraint: nvar1nvar1.
3:     isx(m) – int64int32nag_int array
m, the dimension of the array, must satisfy the constraint mnvarmnvar.
isx(j)isxj indicates whether or not the observations on the jjth variable are included in the matrix of standardized values.
If isx(j)0isxj0, the observations from the jjth variable are included.
If isx(j) = 0isxj=0, the observations from the jjth variable are not included.
Constraint: isx(j)0isxj0 for nvar values of jj.
4:     s(m) – double array
m, the dimension of the array, must satisfy the constraint mnvarmnvar.
If isx(j)0isxj0, s(j)sj must contain the scaling (standard deviation), σjσj, for the jjth variable.
If isx(j) = 0isxj=0, s(j)sj is not referenced.
Constraint: if isx(j)0isxj0, s(j) > 0.0sj>0.0, for j = 1,2,,mj=1,2,,m.
5:     e(m) – double array
m, the dimension of the array, must satisfy the constraint mnvarmnvar.
If isx(j)0isxj0, e(j)ej must contain the location shift (mean), μjμj, for the jjth variable.
If isx(j) = 0isxj=0, e(j)ej is not referenced.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array x.
nn, the number of observations in the data matrix.
Constraint: n1n1.
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: mnvarmnvar.

Input Parameters Omitted from the MATLAB Interface

ldx ldz

Output Parameters

1:     z(ldz,nvar) – double array
ldznldzn.
The matrix of standardized values (zz-scores), ZZ.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,n < 1n<1,
ornvar < 1nvar<1,
orm < nvarm<nvar,
orldx < nldx<n,
orldz < nldz<n.
  ifail = 2ifail=2
On entry,there are not precisely nvar elements of isx0isx0.
  ifail = 3ifail=3
On entry,isx(j)0isxj0 and s(j)0.0sj0.0 for some jj.

Accuracy

Standard accuracy is achieved.

Further Comments

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

Example

function nag_mv_z_scores_example
x = [15, 0, 1500;
     12, 1, 1000;
     18, 2, 1200;
     14, 3, 500];
nvar = int64(2);
isx = [int64(1);0;1];
s = [2.5;
     0;
     420.3];
e = [14.75;
     0;
     1050];
[z, ifail] = nag_mv_z_scores(x, nvar, isx, s, e)
 

z =

    0.1000    1.0707
   -1.1000   -0.1190
    1.3000    0.3569
   -0.3000   -1.3086


ifail =

                    0


function g03za_example
x = [15, 0, 1500;
     12, 1, 1000;
     18, 2, 1200;
     14, 3, 500];
nvar = int64(2);
isx = [int64(1);0;1];
s = [2.5;
     0;
     420.3];
e = [14.75;
     0;
     1050];
[z, ifail] = g03za(x, nvar, isx, s, e)
 

z =

    0.1000    1.0707
   -1.1000   -0.1190
    1.3000    0.3569
   -0.3000   -1.3086


ifail =

                    0



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–2013