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_ordinal (g03fc)

Purpose

nag_mv_multidimscal_ordinal (g03fc) performs non-metric (ordinal) multidimensional scaling.

Syntax

[x, stress, dfit, ifail] = g03fc(typ, d, x, iter, iopt, 'n', n, 'ndim', ndim)
[x, stress, dfit, ifail] = nag_mv_multidimscal_ordinal(typ, d, x, iter, iopt, 'n', n, 'ndim', ndim)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 22: n has been made optional
.

Description

For a set of nn objects, a distance or dissimilarity matrix DD can be calculated such that dijdij is a measure of how ‘far apart’ the objects ii and jj are. If pp variables xkxk have been recorded for each observation this measure may be based on Euclidean distance, dij = k = 1p(xkixkj)2dij=k=1p (xki-xkj) 2, or some other calculation such as the number of variables for which xkjxkixkjxki. Alternatively, the distances may be the result of a subjective assessment. For a given distance matrix, multidimensional scaling produces a configuration of nn points in a chosen number of dimensions, mm, 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 nag_mv_multidimscal_metric (g03fa), 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,
sqrt( (i = 1nj = 1i1(dij^dij~)2)/(i = 1nj = 1i1dij^2))
i=1nj=1 i-1 (dij^-dij~) 2 i=1nj=1 i-1dij^2
where dij^2dij^2 is the Euclidean squared distance between points ii and jj and dij~dij~ is the fitted distance obtained when dij^dij^ is monotonically regressed on dijdij, that is dij~dij~ is monotonic relative to dijdij and is obtained from dij^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, sstresssstress,
sqrt( (i = 1nj = 1i1(dij^2dij~2)2)/(i = 1nj = 1i1dij^4))
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 nag_mv_multidimscal_metric (g03fa). Given an initial configuration, nag_mv_multidimscal_ordinal (g03fc) uses the optimization function nag_opt_uncon_conjgrd_comp (e04dg) to find the configuration of points that minimizes stress or sstresssstress. The function nag_opt_uncon_conjgrd_comp (e04dg) uses a conjugate gradient algorithm. nag_mv_multidimscal_ordinal (g03fc) 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 functions from Chapter G05.

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

Parameters

Compulsory Input Parameters

1:     typ – string (length ≥ 1)
Indicates whether stress or sstresssstress is to be used as the criterion.
typ = 'T'typ='T'
stress is used.
typ = 'S'typ='S'
sstresssstress is used.
Constraint: typ = 'S'typ='S' or 'T''T'.
2:     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,,ni=2,3,,n and j = 1,2,,i1j=1,2,,i-1. If dijdij is missing then set dij < 0dij<0; for further comments on missing values see Section [Further Comments].
3:     x(ldx,ndim) – double array
ldx, the first dimension of the array, must satisfy the constraint ldxnldxn.
The iith row must contain an initial estimate of the coordinates for the iith point, for i = 1,2,,ni=1,2,,n. One method of computing these is to use nag_mv_multidimscal_metric (g03fa).
4:     iter – int64int32nag_int scalar
The maximum number of iterations in the optimization process.
iter = 0iter=0
A default value of 5050 is used.
iter < 0iter<0
A default value of max (50,5nm)max(50,5nm) (the default for nag_opt_uncon_conjgrd_comp (e04dg)) is used.
5:     iopt – int64int32nag_int scalar
Selects the options, other than the number of iterations, that control the optimization.
iopt = 0iopt=0
Default values are selected as described in Section [Further Comments]. In particular if an accuracy requirement of ε = 0.00001ε=0.00001 is selected, see Section [Accuracy].
iopt > 0iopt>0
The default values are used except that the accuracy is given by 10i10-i where i = iopti=iopt.
iopt < 0iopt<0
The option setting mechanism of nag_opt_uncon_conjgrd_comp (e04dg) can be used to set all options except Iteration Limit; this option is only recommended if you are an experienced user of NAG optimization functions. For further details see nag_opt_uncon_conjgrd_comp (e04dg).

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array d and the first dimension of the array x. (An error is raised if these dimensions are not equal.)
nn, the number of objects in the distance matrix.
Constraint: n > ndimn>ndim.
2:     ndim – int64int32nag_int scalar
Default: The second dimension of the array x.
mm, the number of dimensions used to represent the data.
Constraint: ndim1ndim1.

Input Parameters Omitted from the MATLAB Interface

ldx wk iwk

Output Parameters

1:     x(ldx,ndim) – double array
ldxnldxn.
The iith row contains mm coordinates for the iith point, for i = 1,2,,ni=1,2,,n.
2:     stress – double scalar
The value of stress or sstresssstress at the final iteration.
3:     dfit(2 × n × (n1)2×n×(n-1)) – double array
Auxiliary outputs.
If typ = 'T'typ='T', the first n(n1) / 2n(n-1)/2 elements contain the distances, dij^dij^, for the points returned in x, the second set of n(n1) / 2n(n-1)/2 contains the distances dij^dij^ ordered by the input distances, dijdij, the third set of n(n1) / 2n(n-1)/2 elements contains the monotonic distances, dij~dij~, ordered by the input distances, dijdij and the final set of n(n1) / 2n(n-1)/2 elements contains fitted monotonic distances, dij~dij~, for the points in x. The dij~dij~ corresponding to distances which are input as missing are set to zero.
If typ = 'S'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 DD.
4:     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:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

  ifail = 1ifail=1
On entry,ndim < 1ndim<1,
ornndimnndim,
ortyp'T'typ'T' or 'S''S',
orldx < nldx<n.
  ifail = 2ifail=2
On entry,all elements of d0.0d0.0.
  ifail = 3ifail=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.
W ifail = 4ifail=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 = 5ifail=5
The optimization cannot begin from the initial configuration. Try a different set of points.
  ifail = 6ifail=6
The optimization has failed. This error is only likely if iopt < 0iopt<0. It corresponds to ifail = 4ifail=4, 77 and 99 in nag_opt_uncon_conjgrd_comp (e04dg).

Accuracy

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

Further Comments

The optimization function nag_opt_uncon_conjgrd_comp (e04dg) used by nag_mv_multidimscal_ordinal (g03fc) 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-1 to give no printing. The other option set is to stop the checking of derivatives (Verify = NOVerify=NO) for efficiency. All other options are left at their default values. If however iopt < 0iopt<0 is used, only the maximum number of iterations is set. All other options can be controlled by the option setting mechanism of nag_opt_uncon_conjgrd_comp (e04dg) with the defaults as given by that function.
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 function nag_mv_multidimscal_metric (g03fa) 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 nag_mv_multidimscal_metric (g03fa) to give an initial set of coordinates.

Example

function nag_mv_multidimscal_ordinal_example
typ = 'T';
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.070;
     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];
x = [0.240788133045093, 0.2336771621940003;
     0.1136560325924034, 0.1167860264892129;
     0.2393598093421404, 0.07600313166778161;
     0.2129341229512031, 0.06047901667594589;
     0.249489547604401, -0.0693317659454353;
     0.1487285493810621, -0.07783569123014553;
     -0.05139397395173806, -0.1623059860926901;
     0.01153621118615053, -0.3446314902007094;
     -0.003932616383228558, 0.00590873285110863;
     0.03856929371547055, -0.008874156731281325;
     -0.04211582109685088, -0.05655546538851101;
     -0.5158303485449264, 0.02909775244965832;
     -0.3180272688082665, 0.1500964500879802;
     -0.3237616710329136, 0.04748628317308473];
iter = int64(0);
iopt = int64(0);
[xOut, stress, dfit, ifail] = nag_mv_multidimscal_ordinal(typ, d, x, iter, iopt);
 xOut, stress, ifail
 

xOut =

    0.2060    0.2438
    0.1063    0.1418
    0.2224    0.0817
    0.3032    0.0355
    0.2645   -0.0698
    0.1554   -0.0435
   -0.0070   -0.1612
    0.0749   -0.3275
    0.0488    0.0289
    0.0124   -0.0267
   -0.1649   -0.2500
   -0.5073    0.1267
   -0.3093    0.1590
   -0.3498    0.0700


stress =

    0.1256


ifail =

                    0


function g03fc_example
typ = 'T';
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.070;
     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];
x = [0.240788133045093, 0.2336771621940003;
     0.1136560325924034, 0.1167860264892129;
     0.2393598093421404, 0.07600313166778161;
     0.2129341229512031, 0.06047901667594589;
     0.249489547604401, -0.0693317659454353;
     0.1487285493810621, -0.07783569123014553;
     -0.05139397395173806, -0.1623059860926901;
     0.01153621118615053, -0.3446314902007094;
     -0.003932616383228558, 0.00590873285110863;
     0.03856929371547055, -0.008874156731281325;
     -0.04211582109685088, -0.05655546538851101;
     -0.5158303485449264, 0.02909775244965832;
     -0.3180272688082665, 0.1500964500879802;
     -0.3237616710329136, 0.04748628317308473];
iter = int64(0);
iopt = int64(0);
[xOut, stress, dfit, ifail] = g03fc(typ, d, x, iter, iopt);
 xOut, stress, ifail
 

xOut =

    0.2060    0.2438
    0.1063    0.1418
    0.2224    0.0817
    0.3032    0.0355
    0.2645   -0.0698
    0.1554   -0.0435
   -0.0070   -0.1612
    0.0749   -0.3275
    0.0488    0.0289
    0.0124   -0.0267
   -0.1649   -0.2500
   -0.5073    0.1267
   -0.3093    0.1590
   -0.3498    0.0700


stress =

    0.1256


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