NAG FL Interface
g03faf (multidimscal_metric)
1
Purpose
g03faf performs a principal coordinate analysis also known as classical metric scaling.
2
Specification
Fortran Interface
Integer, Intent (In) |
:: |
n, ndim, ldx |
Integer, Intent (Inout) |
:: |
ifail |
Integer, Intent (Out) |
:: |
iwk(5*n) |
Real (Kind=nag_wp), Intent (In) |
:: |
d(n*(n-1)/2) |
Real (Kind=nag_wp), Intent (Inout) |
:: |
x(ldx,ndim) |
Real (Kind=nag_wp), Intent (Out) |
:: |
eval(n), wk(n*(n+17)/2-1) |
Character (1), Intent (In) |
:: |
roots |
|
C Header Interface
#include <nag.h>
void |
g03faf_ (const char *roots, const Integer *n, const double d[], const Integer *ndim, double x[], const Integer *ldx, double eval[], double wk[], Integer iwk[], Integer *ifail, const Charlen length_roots) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g03faf_ (const char *roots, const Integer &n, const double d[], const Integer &ndim, double x[], const Integer &ldx, double eval[], double wk[], Integer iwk[], Integer &ifail, const Charlen length_roots) |
}
|
The routine may be called by the names g03faf or nagf_mv_multidimscal_metric.
3
Description
For a set of
objects a distance matrix
can be calculated such that
is a measure of how ‘far apart’ are objects
and
(see
g03eaf for example). Principal coordinate analysis or metric scaling starts with a distance matrix and finds points
in Euclidean space such that those points have the same distance matrix. The aim is to find a small number of dimensions,
, that provide an adequate representation of the distances.
The principal coordinates of the points are computed from the eigenvectors of the matrix where
with denoting the average of over the suffix , etc.. The eigenvectors are then scaled by multiplying by the square root of the value of the corresponding eigenvalue.
Provided that the ordered eigenvalues,
, of the matrix
are all positive,
shows how well the data is represented in
dimensions. The eigenvalues will be non-negative if
is positive semidefinite. This will be true provided
satisfies the inequality:
for all
. If this is not the case the size of the negative eigenvalue reflects the amount of deviation from this condition and the results should be treated cautiously in the presence of large negative eigenvalues. See
Krzanowski (1990) for further discussion.
g03faf provides the option for all eigenvalues to be computed so that the smallest eigenvalues can be checked.
4
References
Chatfield C and Collins A J (1980) Introduction to Multivariate Analysis Chapman and Hall
Gower J C (1966) Some distance properties of latent root and vector methods used in multivariate analysis Biometrika 53 325–338
Krzanowski W J (1990) Principles of Multivariate Analysis Oxford University Press
5
Arguments
-
1:
– Character(1)
Input
-
On entry: indicates if all the eigenvalues are to be computed or just the
ndim largest.
- All the eigenvalues are computed.
- Only the largest ndim eigenvalues are computed.
Constraint:
or .
-
2:
– Integer
Input
-
On entry: , the number of objects in the distance matrix.
Constraint:
.
-
3:
– Real (Kind=nag_wp) array
Input
-
On entry: the lower triangle of the distance matrix stored packed by rows. That is must contain for .
Constraint:
, for .
-
4:
– Integer
Input
-
On entry: , the number of dimensions used to represent the data.
Constraint:
.
-
5:
– Real (Kind=nag_wp) array
Output
-
On exit: the th row contains coordinates for the th point, .
-
6:
– Integer
Input
-
On entry: the first dimension of the array
x as declared in the (sub)program from which
g03faf is called.
Constraint:
.
-
7:
– Real (Kind=nag_wp) array
Output
-
On exit: if
,
eval contains the
scaled eigenvalues of the matrix
.
If
,
eval contains the largest
scaled eigenvalues of the matrix
.
In both cases the eigenvalues are divided by the sum of the eigenvalues (that is, the trace of ).
-
8:
– Real (Kind=nag_wp) array
Workspace
-
-
9:
– Integer array
Workspace
-
-
10:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: or .
-
On entry, all the elements of .
On entry, and .
Constraint: .
-
There are less than
ndim eigenvalues greater than zero. Try a smaller number of dimensions or use non-metric scaling.
-
The computation of the eigenvalues or eigenvectors has failed. Seek expert help.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
g03faf uses
f08jff or
f08jjf to compute the eigenvalues and
f08jkf to compute the eigenvectors. These routines should be consulted for a discussion of the accuracy of the computations involved.
8
Parallelism and Performance
g03faf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g03faf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
Alternative, non-metric, methods of scaling are provided by
g03fcf.
The relationship between principal coordinates and principal components, see
g03fcf, is discussed in
Krzanowski (1990) and
Gower (1966).
10
Example
The data, given by
Krzanowski (1990), are dissimilarities between water vole populations in Europe. The first two principal coordinates are computed.
10.1
Program Text
10.2
Program Data
10.3
Program Results