NAG Library Manual, Mark 26
NAG AD Library Manual, Mark 26
NAG C Library Manual, Mark 26
G03 (mv) Chapter Contents
G03 (mv) Chapter Introduction
NAG Library Routine Document
g03zaf (z_scores)
Keyword Search:
NAG Library Manual, Mark 26
NAG AD Library Manual, Mark 26
NAG C Library Manual, Mark 26
G03 (mv) Chapter Contents
G03 (mv) Chapter Introduction
▸
▿
Contents
1
Purpose
2
Specification
3
Description
4
References
5
Arguments
6
Error Indicators and Warnings
7
Accuracy
8
Parallelism and Performance
9
Further Comments
▸
▿
10
Example
10.1
Program Text
10.2
Program Data
10.3
Program Results
© The Numerical Algorithms Group Ltd. 2018
1
Purpose
g03zaf
produces standardized values (
z
-scores) for a data matrix.
2
Specification
Fortran Interface
Subroutine g03zaf (
n
,
m
,
x
,
ldx
,
nvar
,
isx
,
s
,
e
,
z
,
ldz
,
ifail
)
Integer, Intent (In)
::
n
,
m
,
ldx
,
nvar
,
isx(m)
,
ldz
Integer, Intent (Inout)
::
ifail
Real (Kind=nag_wp), Intent (In)
::
x(ldx,m)
,
s(m)
,
e(m)
Real (Kind=nag_wp), Intent (Inout)
::
z(ldz,nvar)
C Header Interface
#include <nagmk26.h>
void
g03zaf_ (
const Integer *
n
,
const Integer *
m
,
const double
x
[]
,
const Integer *
ldx
,
const Integer *
nvar
,
const Integer
isx
[]
,
const double
s
[]
,
const double
e
[]
,
double
z
[]
,
const Integer *
ldz
,
Integer *
ifail
)
3
Description
For a data matrix,
X
, consisting of
n
observations on
p
variables, with elements
x
i
j
,
g03zaf
computes a matrix,
Z
, with elements
z
i
j
such that:
z
i
j
=
x
i
j
-
μ
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
j
th variable and therefore the elements in column
j
of
Z
will have zero mean and unit variance.
4
References
None.
5
Arguments
1:
n
– Integer
Input
On entry
:
n
, the number of observations in the data matrix.
Constraint
:
n
≥
1
.
2:
m
– Integer
Input
On entry
: the number of variables in the data array
x
.
Constraint
:
m
≥
nvar
.
3:
x
ldx
m
– Real (Kind=nag_wp) array
Input
On entry
:
x
i
j
must contain the
i
th sample point for the
j
th variable,
x
i
j
, for
i
=
1
,
2
,
…
,
n
and
j
=
1
,
2
,
…
,
m
.
4:
ldx
– Integer
Input
On entry
: the first dimension of the array
x
as declared in the (sub)program from which
g03zaf
is called.
Constraint
:
ldx
≥
n
.
5:
nvar
– Integer
Input
On entry
:
p
, the number of variables to be standardized.
Constraint
:
nvar
≥
1
.
6:
isx
m
– Integer array
Input
On entry
:
isx
j
indicates whether or not the observations on the
j
th variable are included in the matrix of standardized values.
If
isx
j
≠
0
, the observations from the
j
th variable are included.
If
isx
j
=
0
, the observations from the
j
th variable are not included.
Constraint
:
isx
j
≠
0
for
nvar
values of
j
.
7:
s
m
– Real (Kind=nag_wp) array
Input
On entry
: if
isx
j
≠
0
,
s
j
must contain the scaling (standard deviation),
σ
j
, for the
j
th variable.
If
isx
j
=
0
,
s
j
is not referenced.
Constraint
: if
isx
j
≠
0
,
s
j
>
0.0
, for
j
=
1
,
2
,
…
,
m
.
8:
e
m
– Real (Kind=nag_wp) array
Input
On entry
: if
isx
j
≠
0
,
e
j
must contain the location shift (mean),
μ
j
, for the
j
th variable.
If
isx
j
=
0
,
e
j
is not referenced.
9:
z
ldz
nvar
– Real (Kind=nag_wp) array
Output
On exit
: the matrix of standardized values (
z
-scores),
Z
.
10:
ldz
– Integer
Input
On entry
: the first dimension of the array
z
as declared in the (sub)program from which
g03zaf
is called.
Constraint
:
ldz
≥
n
.
11:
ifail
– Integer
Input/Output
On entry
:
ifail
must be set to
0
,
-
1
or
1
. If you are unfamiliar with this argument you should refer to
Section 3.4
in How to Use the NAG Library and its Documentation 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 argument, 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,
ldx
=
value
and
n
=
value
.
Constraint:
ldx
≥
n
.
On entry,
ldz
=
value
and
n
=
value
.
Constraint:
ldz
≥
n
.
On entry,
m
=
value
and
nvar
=
value
.
Constraint:
m
≥
nvar
.
On entry,
n
=
value
.
Constraint:
n
≥
1
.
On entry,
nvar
=
value
.
Constraint:
nvar
≥
1
.
ifail
=
2
On entry,
nvar
=
value
and
value
values of
isx
>
0
.
Constraint: exactly
nvar
elements of
isx
>
0
.
ifail
=
3
On entry,
j
=
value
and
s
i
≤
0.0
.
Constraint:
s
j
>
0.0
.
ifail
=
-
99
An unexpected error has been triggered by this routine. Please contact
NAG
.
See
Section 3.9
in How to Use the NAG Library and its Documentation for further information.
ifail
=
-
399
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8
in How to Use the NAG Library and its Documentation for further information.
ifail
=
-
999
Dynamic memory allocation failed.
See
Section 3.7
in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
Standard accuracy is achieved.
8
Parallelism and Performance
g03zaf
is not threaded in any implementation.
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)
NAG Library Manual, Mark 26
NAG AD Library Manual, Mark 26
NAG C Library Manual, Mark 26
G03 (mv) Chapter Contents
G03 (mv) Chapter Introduction
© The Numerical Algorithms Group Ltd. 2018