mmds Metric (classical) Multidimensional Scaling (a.k.a Principal Coordinate Analysis) of a (Euclidean) Distance Matric
Description
Perform an MMDS of a (Euclidean) distance matrix measured between a set of weighted objects.
MMDS Give factor scores that make it possible to
draw a map of the objects such that the distances between objects on the
map best approximate the original distances between objects.
Method: Transform the distance matrix into a (double centered)
covariance matrix which is then analyze via its eigen-decomposition.
The factor score of each dimension are scaled such that their variance
(i.e., the sum ot their weighted squared factor scores) is
equal to the eigen-value of the corresponding dimension.
Note that if the masses vector is absent, equal masses (i.e. 1 divided by number of objects)
are used.
Usage
mmds(DistanceMatrix,masses=NULL)
Arguments
DistanceMatrix
.
A squared (assumed to be Euclidean) distance matrix
masses
A vector of masses (i.e.,
non negative numbers with a sum of 1)
of same dimensionality as number of rows of
DistanceMatrix.
Value
Sends back a list
LeF
factor scores for the objects.
eigenvalues
the eigenvalues for the factor scores (ie.a variance).
tau
the percentage of explained variance of each dimension.
Contributions
give the proporion of explained variance by an object for a dimension.
Author(s)
Herve Abdi
References
The procedure and references are detailled in:
Abdi, H. (2007). Metric multidimensional scaling.
In N.J. Salkind (Ed.):
Encyclopedia of Measurement and Statistics. Thousand Oaks (CA): Sage. pp. 598–605.
# An example of MDS from Abdi (2007)
# Discriminability of Brain States
# Table 1.
# 1. Get the distance matrix
D <- matrix(c(
0.00, 3.47, 1.79, 3.00, 2.67, 2.58, 2.22, 3.08,
3.47, 0.00, 3.39, 2.18, 2.86, 2.69, 2.89, 2.62,
1.79, 3.39, 0.00, 2.18, 2.34, 2.09, 2.31, 2.88,
3.00, 2.18, 2.18, 0.00, 1.73, 1.55, 1.23, 2.07,
2.67, 2.86, 2.34, 1.73, 0.00, 1.44, 1.29, 2.38,
2.58, 2.69, 2.09, 1.55, 1.44, 0.00, 1.19, 2.15,
2.22, 2.89, 2.31, 1.23, 1.29, 1.19, 0.00, 2.07,
3.08, 2.62, 2.88, 2.07, 2.38, 2.15, 2.07, 0.00),
ncol = 8, byrow=TRUE)
rownames(D) <- c('Face','House','Cat','Chair','Shoe','Scissors','Bottle','Scramble')
colnames(D) <- rownames(D)
# 2. Call mmds
BrainRes <- mmds(D)
# Note that compared to Abdi (2007)
# the factor scores of mmds are equal to F / sqrt(nrow(D))
# the eigenvalues of mmds are equal to Lambda *{1/nrow(D)}
# (ie., the normalization differs but the results are proportional)
# 3. Now a pretty plot with the prettyPlot function from prettyGraphs
prettyPlot(BrainRes$FactorScore,
display_names = TRUE,
display_points = TRUE,
contributionCircles = TRUE,
contributions = BrainRes$Contributions)
# 4. et Voila!
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(DistatisR)
Loading required package: prettyGraphs
Loading required package: car
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DistatisR/mmds.Rd_%03d_medium.png", width=480, height=480)
> ### Name: mmds
> ### Title: mmds Metric (classical) Multidimensional Scaling (a.k.a
> ### Principal Coordinate Analysis) of a (Euclidean) Distance Matric
> ### Aliases: mmds
> ### Keywords: DistatisR
>
> ### ** Examples
>
> # An example of MDS from Abdi (2007)
> # Discriminability of Brain States
> # Table 1.
> # 1. Get the distance matrix
> D <- matrix(c(
+ 0.00, 3.47, 1.79, 3.00, 2.67, 2.58, 2.22, 3.08,
+ 3.47, 0.00, 3.39, 2.18, 2.86, 2.69, 2.89, 2.62,
+ 1.79, 3.39, 0.00, 2.18, 2.34, 2.09, 2.31, 2.88,
+ 3.00, 2.18, 2.18, 0.00, 1.73, 1.55, 1.23, 2.07,
+ 2.67, 2.86, 2.34, 1.73, 0.00, 1.44, 1.29, 2.38,
+ 2.58, 2.69, 2.09, 1.55, 1.44, 0.00, 1.19, 2.15,
+ 2.22, 2.89, 2.31, 1.23, 1.29, 1.19, 0.00, 2.07,
+ 3.08, 2.62, 2.88, 2.07, 2.38, 2.15, 2.07, 0.00),
+ ncol = 8, byrow=TRUE)
> rownames(D) <- c('Face','House','Cat','Chair','Shoe','Scissors','Bottle','Scramble')
> colnames(D) <- rownames(D)
> # 2. Call mmds
> BrainRes <- mmds(D)
> # Note that compared to Abdi (2007)
> # the factor scores of mmds are equal to F / sqrt(nrow(D))
> # the eigenvalues of mmds are equal to Lambda *{1/nrow(D)}
> # (ie., the normalization differs but the results are proportional)
> # 3. Now a pretty plot with the prettyPlot function from prettyGraphs
> prettyPlot(BrainRes$FactorScore,
+ display_names = TRUE,
+ display_points = TRUE,
+ contributionCircles = TRUE,
+ contributions = BrainRes$Contributions)
dev.new(): using pdf(file="Rplots135.pdf")
$col
[,1]
Face "#305ABF"
House "#305ABF"
Cat "#305ABF"
Chair "#305ABF"
Shoe "#305ABF"
Scissors "#305ABF"
Bottle "#305ABF"
Scramble "#305ABF"
$pch
[,1]
[1,] 21
[2,] 21
[3,] 21
[4,] 21
[5,] 21
[6,] 21
[7,] 21
[8,] 21
$constraints
$constraints$minx
[1] -0.8928154
$constraints$miny
[1] -0.5828126
$constraints$maxx
[1] 1.028313
$constraints$maxy
[1] 0.9642077
> # 4. et Voila!
>
>
>
>
>
> dev.off()
png
2
>