# DESCRIPTION

Multidimensional scaling (MDS) is a tool for visualizing the level of
similarity of N units of a dataset and it is a form of non-linear
dimensionality reduction.

MDS displays the information contained in a distance matrix. The MDS
places units in a K-dimensional space (with K typically less than N)
so that the between-unit distances are preserved as well as possible,
evaluating for each units new coordinates in each of the K
dimensions. The number of dimensions of a MDS space must be specified
a priori. The customary choice is K = 2 and the graphical output is a
scatterplot.

The package performs the Classical MDS algorithm, via the main
function `MDS()`, and the corresponding scatterplot is produced by the
auxiliary function `MDS_plot()`.

In the common case when K = 2, it may be desirable to rotate the
solution to make the plot more readily interpretable. This is
accomplished by the function `rotate2d()`.

## References:

- Kruskal, J.B. and M. Wish 1978. Multidimensional Scaling. Sage.

- Mardia, K. V., Kent, J. T., and Bibby, J. M. (1979), Multivariate
  Analysis, London, UK: Academic Press.

# AVAILABLE FUNCTIONS

## MDS

usage: ret = MDS(XDist, K)

Main function, performs the main computations and stores results
into the returned bundle

inputs:

- XDist: N*N symmetric distance matrix between the n units; if the
matrix has row or column labels, they will be used by the `MDS_plot()` function fo labelling the points.
- K: scalar, optional. Number of dimensions (default = 2)

output: Bundle containing:

- coord:  N*K matrix: coordinates in the MDS space
- d_ms: N*N matrix: Euclidean distances in the MDS space

## MDS_plot

usage: MDS_plot(bun, dest, fix)

Used to plot the points 

inputs:

- bun:    A bundle created by the MDS function
- dest:   string, optional. Destination filename (default = display)
- fix:    boolean, optional. Used to have equally-scaled coordinates (default = 1)

## rotate2d

usage: rotate2d(&bun, omega, flip)

Rotate a 2-dimensional coordinate system. 

inputs:

- bun:    A bundle created by the MDS function (in pointer form)
- omega:  angle in radians for rotating the plot (default = 0)
- flip:   matrix 2x1, optional: dummies for swapping the signs on
        the (x,y) axes (default = {0,0}: no flipping) 

# CHANGELOG:

1.2 -> 1.3: Perform some basic checks on the input matrix to the
`MDS()` function. Switch to markdown for help file. (Internal) get rid
of OS-dependent mechanism for temporary filenames.

1.1 -> 1.2: Internal changes only: use the native `distance()` function
and robustify temporary filenames.

1.0 -> 1.1: fix the "decimal comma" problem; new function `rotate2d()`;
a few internal fixes
