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_multidimscal_metric (g03fa)

Purpose

nag_mv_multidimscal_metric (g03fa) performs a principal coordinate analysis also known as classical metric scaling.

Syntax

[x, eval, ifail] = g03fa(roots, n, d, ndim)
[x, eval, ifail] = nag_mv_multidimscal_metric(roots, n, d, ndim)

Description

For a set of nn objects a distance matrix DD can be calculated such that dijdij is a measure of how ‘far apart’ are objects ii and jj (see nag_mv_distance_mat (g03ea) for example). Principal coordinate analysis or metric scaling starts with a distance matrix and finds points XX in Euclidean space such that those points have the same distance matrix. The aim is to find a small number of dimensions, k(n1)k(n-1), that provide an adequate representation of the distances.
The principal coordinates of the points are computed from the eigenvectors of the matrix EE where eij = 1 / 2 (dij2di . 2d . j2 + d . . 2) e ij = -1 / 2 ( d ij 2 - d i. 2 - d .j 2 + d .. 2 )  with di . 2di.2 denoting the average of dij2dij2 over the suffix jj, etc.. The eigenvectors are then scaled by multiplying by the square root of the value of the corresponding eigenvalue.
Provided that the ordered eigenvalues, λiλi, of the matrix EE are all positive, i = 1k λi / i = 1n1 λi i=1 k λi / i=1 n-1 λi  shows how well the data is represented in kk dimensions. The eigenvalues will be non-negative if EE is positive semidefinite. This will be true provided dijdij satisfies the inequality: dij dik + djk dij dik + djk  for all i,j,ki,j,k. 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. nag_mv_multidimscal_metric (g03fa) provides the option for all eigenvalues to be computed so that the smallest eigenvalues can be checked.

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

Parameters

Compulsory Input Parameters

1:     roots – string (length ≥ 1)
Indicates if all the eigenvalues are to be computed or just the ndim largest.
roots = 'A'roots='A'
All the eigenvalues are computed.
roots = 'L'roots='L'
Only the largest ndim eigenvalues are computed.
Constraint: roots = 'A'roots='A' or 'L''L'.
2:     n – int64int32nag_int scalar
nn, the number of objects in the distance matrix.
Constraint: n > ndimn>ndim.
3:     d(n × (n1) / 2n×(n-1)/2) – double array
The lower triangle of the distance matrix DD stored packed by rows. That is d((i1) × (i2) / 2 + j)d((i-1)×(i-2)/2+j) must contain dijdij for i = 2,3,,n;j = 1,2,,i1i=2,3,,n;j=1,2,,i-1.
Constraint: d(i)0.0di0.0, for i = 1,2,,n(n1) / 2i=1,2,,n(n-1)/2.
4:     ndim – int64int32nag_int scalar
kk, the number of dimensions used to represent the data.
Constraint: ndim1ndim1.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

ldx wk iwk

Output Parameters

1:     x(ldx,ndim) – double array
ldxnldxn.
The iith row contains kk coordinates for the iith point, i = 1,2,,ni=1,2,,n.
2:     eval(n) – double array
If roots = 'A'roots='A', eval contains the nn scaled eigenvalues of the matrix EE.
If roots = 'L'roots='L', eval contains the largest kk scaled eigenvalues of the matrix EE.
In both cases the eigenvalues are divided by the sum of the eigenvalues (that is, the trace of EE).
3:     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,ndim < 1ndim<1,
orn < ndimn<ndim,
orroots'A'roots'A' or 'L''L',
orldx < nldx<n.
  ifail = 2ifail=2
On entry,d(i) < 0.0di<0.0 for some ii, i = 1,2,,n(n1) / 2i=1,2,,n(n-1)/2,
orall elements of d = 0.0d=0.0.
  ifail = 3ifail=3
There are less than ndim eigenvalues greater than zero. Try a smaller number of dimensions (ndim) or use non-metric scaling (nag_mv_multidimscal_ordinal (g03fc)).
  ifail = 4ifail=4
The computation of the eigenvalues or eigenvectors has failed. Seek expert help.

Accuracy

nag_mv_multidimscal_metric (g03fa) uses nag_lapack_dsterf (f08jf) or nag_lapack_dstebz (f08jj) to compute the eigenvalues and nag_lapack_dstein (f08jk) to compute the eigenvectors. These functions should be consulted for a discussion of the accuracy of the computations involved.

Further Comments

Alternative, non-metric, methods of scaling are provided by nag_mv_multidimscal_ordinal (g03fc).
The relationship between principal coordinates and principal components, see nag_mv_multidimscal_ordinal (g03fc), is discussed in Krzanowski (1990) and Gower (1966).

Example

function nag_mv_multidimscal_metric_example
roots = 'l';
n = int64(14);
d = [0.099;
     0.033;
     0.022;
     0.183;
     0.114;
     0.042;
     0.148;
     0.224;
     0.059;
     0.068;
     0.198;
     0.039;
     0.053;
     0.085;
     0.051;
     0.462;
     0.266;
     0.322;
     0.435;
     0.268;
     0.025;
     0.628;
     0.442;
     0.444;
     0.406;
     0.24;
     0.129;
     0.014;
     0.113;
     0.07;
     0.046;
     0.047;
     0.034;
     0.002;
     0.106;
     0.129;
     0.173;
     0.119;
     0.162;
     0.331;
     0.177;
     0.039;
     0.089;
     0.237;
     0.071;
     0.434;
     0.419;
     0.339;
     0.505;
     0.469;
     0.39;
     0.315;
     0.349;
     0.151;
     0.43;
     0.762;
     0.633;
     0.781;
     0.7;
     0.758;
     0.625;
     0.469;
     0.618;
     0.44;
     0.538;
     0.607;
     0.53;
     0.389;
     0.482;
     0.579;
     0.597;
     0.498;
     0.374;
     0.562;
     0.247;
     0.383;
     0.387;
     0.084;
     0.586;
     0.435;
     0.55;
     0.53;
     0.552;
     0.509;
     0.369;
     0.471;
     0.234;
     0.346;
     0.456;
     0.09;
     0.038];
ndim = int64(2);
[x, eval, ifail] = nag_mv_multidimscal_metric(roots, n, d, ndim)
 

x =

    0.2408    0.2337
    0.1137    0.1168
    0.2394    0.0760
    0.2129    0.0605
    0.2495   -0.0693
    0.1487   -0.0778
   -0.0514   -0.1623
    0.0115   -0.3446
   -0.0039    0.0059
    0.0386   -0.0089
   -0.0421   -0.0566
   -0.5158    0.0291
   -0.3180    0.1501
   -0.3238    0.0475


eval =

    0.7871
    0.2808
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0


ifail =

                    0


function g03fa_example
roots = 'l';
n = int64(14);
d = [0.099;
     0.033;
     0.022;
     0.183;
     0.114;
     0.042;
     0.148;
     0.224;
     0.059;
     0.068;
     0.198;
     0.039;
     0.053;
     0.085;
     0.051;
     0.462;
     0.266;
     0.322;
     0.435;
     0.268;
     0.025;
     0.628;
     0.442;
     0.444;
     0.406;
     0.24;
     0.129;
     0.014;
     0.113;
     0.07;
     0.046;
     0.047;
     0.034;
     0.002;
     0.106;
     0.129;
     0.173;
     0.119;
     0.162;
     0.331;
     0.177;
     0.039;
     0.089;
     0.237;
     0.071;
     0.434;
     0.419;
     0.339;
     0.505;
     0.469;
     0.39;
     0.315;
     0.349;
     0.151;
     0.43;
     0.762;
     0.633;
     0.781;
     0.7;
     0.758;
     0.625;
     0.469;
     0.618;
     0.44;
     0.538;
     0.607;
     0.53;
     0.389;
     0.482;
     0.579;
     0.597;
     0.498;
     0.374;
     0.562;
     0.247;
     0.383;
     0.387;
     0.084;
     0.586;
     0.435;
     0.55;
     0.53;
     0.552;
     0.509;
     0.369;
     0.471;
     0.234;
     0.346;
     0.456;
     0.09;
     0.038];
ndim = int64(2);
[x, eval, ifail] = g03fa(roots, n, d, ndim)
 

x =

    0.2408    0.2337
    0.1137    0.1168
    0.2394    0.0760
    0.2129    0.0605
    0.2495   -0.0693
    0.1487   -0.0778
   -0.0514   -0.1623
    0.0115   -0.3446
   -0.0039    0.0059
    0.0386   -0.0089
   -0.0421   -0.0566
   -0.5158    0.0291
   -0.3180    0.1501
   -0.3238    0.0475


eval =

    0.7871
    0.2808
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0


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