# Dimension Reduction - Multidimensional Scaling (MDS)

Computes multidimensional scaling and displays the output as a two-dimensional scatterplot

Computes multidimensional scaling and displays the output as a two-dimensional scatterplot. Metric MDS minimizes the difference between distances in input and output spaces. Non-metric MDS aims to preserve the ranking of distances between input and output spaces. You can find out more about MDS on our blog here.

## How to Create

1. Add the object by selecting from the men Anything > Advanced Analysis > Dimension Reduction > Multidimensional Scaling (MDS)Create > Dimension Reduction > Multidimensional Scaling (MDS)
2. Under Inputs > Algorithm select MDS - Metric or MDS - Non-metric
3. Under Inputs > Input type select an input type

## Example

If the input type is Variables, the probability that each point has the same class as its nearest neighbor is calculated. A further variable may be specified to classify the output cases into groups using the Group variable field.

Example output:
Using Metric

Using Metric Non-metric algorithm:

If the input is a distance matrix, output points are labelled.
Example output:
Using Metric algorithm:

Using Metric Non-metric algorithm:

Input Example: A distance matrix either pasted in or created in the software. You can learn how to create a distance matrix in Q here: Correlation_-_Distance_Matrix#How_to_Create_a_Distance_Matrix

Dimension Reduction - Plot - Goodness of Fit can be used to assess the accuracy of the fit.

## Options

Algorithm A choice between metric and non-metric multidimensional scaling. Other dimension reduction techniques of PCA and t-SNE are also available.

The input data can be provided via one of three options:

Variables The variables or a questionvariable set containing variables that you would like to analyze. Cases with missing data are ignored.
Distance matrix Select an existing distance matrix. This should be a symmetric matrix of distances, such as the output of Correlation - Distances.
Paste or type distance matrix Opens up a blank spreadsheet into which tabular data can be manually entered or pasted.

Group variable A variable to categorize the output. If numeric, the data are shaded from light (lowest values) to dark (highest). If categorical, data points are colored according to their category. This option is only available if Variables are provided.

Create binary variables from unordered categories If selected, unordered categorical Variables with N categories are converted are converted into N-1 binary indicator variables. Otherwise such variables are each converted to a single numeric variable with integers representing categories (as happens for ordered categories). This option is only available if Variables are provided.

Normalize variables For Variables input, whether to normalize the data.

For t-SNE and MDS each variable is standardized to the range [0, 1].
For PCA the correlation matrix is used rather than the covariance matrix.

Perplexity A parameter used by the t-SNE algorithm and related to the number of nearest neighbors considered when placing each data point. The typical useful range is from 5 to 50.

Low values imply that immediately local structure is most important.
High values increase the impact of more distant neighbors and global structure.

When using this feature you can obtain additional information that is stored by the R code which produces the output.

1. To do so, select Create > R Output.
2. In the R CODE, paste: item = YourReferenceName
3. Replace YourReferenceName with the reference name of your item. Find this in the Report tree or by selecting the item and then going to Properties > General > Name from the object inspector on the right.
4. Below the first line of code, you can paste in snippets from below or type in str(item) to see a list of available information.

For a more in depth discussion on extracting information from objects in R, checkout our blog post here.

## Acknowledgements

Uses the R packages MASS and isoMDS.