NAG Library Routine Document
G03FAF performs a principal coordinate analysis also known as classical metric scaling.
||N, NDIM, LDX, IWK(5*N), IFAIL
||D(N*(N-1)/2), X(LDX,NDIM), EVAL(N), WK(N*(N+17)/2-1)
For a set of
objects a distance matrix
can be calculated such that
is a measure of how ‘far apart’ are objects
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:
. 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.
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
- 1: ROOTS – CHARACTER(1)Input
: indicates if all the eigenvalues are to be computed or just the NDIM
- All the eigenvalues are computed.
- Only the largest NDIM eigenvalues are computed.
- 2: N – INTEGERInput
On entry: , the number of objects in the distance matrix.
- 3: D() – REAL (KIND=nag_wp) arrayInput
On entry: the lower triangle of the distance matrix stored packed by rows. That is must contain for .
, for .
- 4: NDIM – INTEGERInput
On entry: , the number of dimensions used to represent the data.
- 5: X(LDX,NDIM) – REAL (KIND=nag_wp) arrayOutput
On exit: the th row contains coordinates for the th point, .
- 6: LDX – INTEGERInput
: the first dimension of the array X
as declared in the (sub)program from which G03FAF is called.
- 7: EVAL(N) – REAL (KIND=nag_wp) arrayOutput
scaled eigenvalues of the matrix
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: WK() – REAL (KIND=nag_wp) arrayWorkspace
- 9: IWK() – INTEGER arrayWorkspace
- 10: IFAIL – INTEGERInput/Output
must be set to
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
. When the value is used it is essential to test the value of IFAIL 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
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
|or|| or ,|
|On entry,|| for some , ,|
|or||all elements of .|
There are less than NDIM
eigenvalues greater than zero. Try a smaller number of dimensions (NDIM
) or use non-metric scaling (G03FCF
The computation of the eigenvalues or eigenvectors has failed. Seek expert help.
G03FAF uses F08JFF (DSTERF)
or F08JJF (DSTEBZ)
to compute the eigenvalues and F08JKF (DSTEIN)
to compute the eigenvectors. These routines should be consulted for a discussion of the accuracy of the computations involved.
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)
The data, given by Krzanowski (1990)
, are dissimilarities between water vole populations in Europe. The first two principal coordinates are computed.
9.1 Program Text
Program Text (g03fafe.f90)
9.2 Program Data
Program Data (g03fafe.d)
9.3 Program Results
Program Results (g03fafe.r)