NAG Library Routine Document

g03fcf  (multidimscal_ordinal)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

g03fcf performs non-metric (ordinal) multidimensional scaling.

2
Specification

Fortran Interface
Subroutine g03fcf ( typ, n, ndim, d, x, ldx, stress, dfit, iter, iopt, wk, iwk, ifail)
Integer, Intent (In):: n, ndim, ldx, iter, iopt
Integer, Intent (Inout):: ifail
Integer, Intent (Out):: iwk(n*(n-1)/2+n*ndim+5)
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):: stress, dfit(2*n*(n-1)), wk(15*n*ndim)
Character (1), Intent (In):: typ
C Header Interface
#include nagmk26.h
void  g03fcf_ ( const char *typ, const Integer *n, const Integer *ndim, const double d[], double x[], const Integer *ldx, double *stress, double dfit[], const Integer *iter, const Integer *iopt, double wk[], Integer iwk[], Integer *ifail, const Charlen length_typ)

3
Description

For a set of n objects, a distance or dissimilarity matrix D can be calculated such that dij is a measure of how ‘far apart’ the objects i and j are. If p variables xk have been recorded for each observation this measure may be based on Euclidean distance, dij=k=1p xki-xkj 2, or some other calculation such as the number of variables for which xkjxki. Alternatively, the distances may be the result of a subjective assessment. For a given distance matrix, multidimensional scaling produces a configuration of n points in a chosen number of dimensions, m, such that the distance between the points in some way best matches the distance matrix. For some distance measures, such as Euclidean distance, the size of distance is meaningful, for other measures of distance all that can be said is that one distance is greater or smaller than another. For the former metric scaling can be used, see g03faf, for the latter, a non-metric scaling is more appropriate.
For non-metric multidimensional scaling, the criterion used to measure the closeness of the fitted distance matrix to the observed distance matrix is known as stress. stress is given by,
i=1nj=1 i-1 dij^-dij~ 2 i=1nj=1 i-1dij^2  
where dij^2 is the Euclidean squared distance between points i and j and dij~ is the fitted distance obtained when dij^ is monotonically regressed on dij, that is dij~ is monotonic relative to dij and is obtained from dij^ with the smallest number of changes. So stress is a measure of by how much the set of points preserve the order of the distances in the original distance matrix. Non-metric multidimensional scaling seeks to find the set of points that minimize the stress.
An alternate measure is squared stress, sstress,
i=1nj=1 i-1 dij^2-dij~2 2 i=1nj=1 i-1dij^4  
in which the distances in stress are replaced by squared distances.
In order to perform a non-metric scaling, an initial configuration of points is required. This can be obtained from principal coordinate analysis, see g03faf. Given an initial configuration, g03fcf uses the optimization routine e04dgf/e04dga to find the configuration of points that minimizes stress or sstress. The routine e04dgf/e04dga uses a conjugate gradient algorithm. g03fcf will find an optimum that may only be a local optimum, to be more sure of finding a global optimum several different initial configurations should be used; these can be obtained by randomly perturbing the original initial configuration using routines from Chapter G05.

4
References

Chatfield C and Collins A J (1980) Introduction to Multivariate Analysis Chapman and Hall
Krzanowski W J (1990) Principles of Multivariate Analysis Oxford University Press

5
Arguments

1:     typ – Character(1)Input
On entry: indicates whether stress or sstress is to be used as the criterion.
typ='T'
stress is used.
typ='S'
sstress is used.
Constraint: typ='S' or 'T'.
2:     n – IntegerInput
On entry: n, the number of objects in the distance matrix.
Constraint: n>ndim.
3:     ndim – IntegerInput
On entry: m, the number of dimensions used to represent the data.
Constraint: ndim1.
4:     dn×n-1/2 – Real (Kind=nag_wp) arrayInput
On entry: the lower triangle of the distance matrix D stored packed by rows. That is d i-1 × i-2 /2+j  must contain dij, for i=2,3,,n and j=1,2,,i-1. If dij is missing then set dij<0; for further comments on missing values see Section 9.
5:     xldxndim – Real (Kind=nag_wp) arrayInput/Output
On entry: the ith row must contain an initial estimate of the coordinates for the ith point, for i=1,2,,n. One method of computing these is to use g03faf.
On exit: the ith row contains m coordinates for the ith point, for i=1,2,,n.
6:     ldx – IntegerInput
On entry: the first dimension of the array x as declared in the (sub)program from which g03fcf is called.
Constraint: ldxn.
7:     stress – Real (Kind=nag_wp)Output
On exit: the value of stress or sstress at the final iteration.
8:     dfit2×n×n-1 – Real (Kind=nag_wp) arrayOutput
On exit: auxiliary outputs.
If typ='T', the first nn-1/2 elements contain the distances, dij^, for the points returned in x, the second set of nn-1/2 contains the distances dij^ ordered by the input distances, dij, the third set of nn-1/2 elements contains the monotonic distances, dij~, ordered by the input distances, dij and the final set of nn-1/2 elements contains fitted monotonic distances, dij~, for the points in x. The dij~ corresponding to distances which are input as missing are set to zero.
If typ='S', the results are as above except that the squared distances are returned.
Each distance matrix is stored in lower triangular packed form in the same way as the input matrix D.
9:     iter – IntegerInput
On entry: the maximum number of iterations in the optimization process.
iter=0
A default value of 50 is used.
iter<0
A default value of max50,5nm (the default for e04dgf/e04dga) is used.
10:   iopt – IntegerInput
On entry: selects the options, other than the number of iterations, that control the optimization.
iopt=0
Default values are selected as described in Section 9. In particular if an accuracy requirement of ε=0.00001 is selected, see Section 7.
iopt>0
The default values are used except that the accuracy is given by 10-i where i=iopt.
iopt<0
The option setting mechanism of e04dgf/e04dga can be used to set all options except Iteration Limit; this option is only recommended if you are an experienced user of NAG optimization routines. For further details see e04dgf/e04dga.
11:   wk15×n×ndim – Real (Kind=nag_wp) arrayWorkspace
12:   iwkn×n-1/2+n×ndim+5 – Integer arrayWorkspace
13:   ifail – IntegerInput/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,ndim<1,
ornndim,
ortyp'T' or 'S',
orldx<n.
ifail=2
On entry,all elements of d0.0.
ifail=3
The optimization has failed to converge in iter function iterations. Try either increasing the number of iterations using iter or increasing the value of ε, given by iopt, used to determine convergence. Alternatively try a different starting configuration.
ifail=4
The conditions for an acceptable solution have not been met but a lower point could not be found. Try using a larger value of ε, given by iopt.
ifail=5
The optimization cannot begin from the initial configuration. Try a different set of points.
ifail=6
The optimization has failed. This error is only likely if iopt<0. It corresponds to ifail=4, 7 and 9 in e04dgf/e04dga.
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

After a successful optimization the relative accuracy of stress should be approximately ε, as specified by iopt.

8
Parallelism and Performance

g03fcf 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.

9
Further Comments

The optimization routine e04dgf/e04dga used by g03fcf has a number of options to control the process. The options for the maximum number of iterations (Iteration Limit) and accuracy (Optimality Tolerance) can be controlled by iter and iopt respectively. The printing option (Print Level) is set to -1 to give no printing. The other option set is to stop the checking of derivatives (Verify=NO) for efficiency. All other options are left at their default values. If however iopt<0 is used, only the maximum number of iterations is set. All other options can be controlled by the option setting mechanism of e04dgf/e04dga with the defaults as given by that routine.
Missing values in the input distance matrix can be specified by a negative value and providing there are not more than about two thirds of the values missing the algorithm may still work. However the routine g03faf does not allow for missing values so an alternative method of obtaining an initial set of coordinates is required. It may be possible to estimate the missing values with some form of average and then use g03faf to give an initial set of coordinates.

10
Example

The data, given by Krzanowski (1990), are dissimilarities between water vole populations in Europe. Initial estimates are provided by the first two principal coordinates computed.

10.1
Program Text

Program Text (g03fcfe.f90)

10.2
Program Data

Program Data (g03fcfe.d)

10.3
Program Results

Program Results (g03fcfe.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 −0.4 −0.3 −0.2 −0.1 0 0.1 0.2 0.3 −0.6 −0.5 −0.4 −0.3 −0.2 −0.1 0 0.1 0.2 0.3 0.4 Second Principal Coordinate First Principal Coordinate Example Program Plot of Observation Number by the First Two Principal Coordinates gnuplot_plot_1 1 2 3 4 5 6 7 8 9 10 11 12 13 14
© The Numerical Algorithms Group Ltd, Oxford, UK. 2017