[R] Plotting MDS (multidimensional scaling)
Daniel Malter
daniel at umd.edu
Sat Apr 2 22:07:35 CEST 2011
Hi,
I just encountered what I thought was strange behavior in MDS. However, it
turned out that the mistake was mine. The lesson learned from my mistake is
that one should plot on a square pane when plotting results of an MDS. Not
doing so can be very misleading. Follow the example of an equilateral
triangle below to see what I mean. I hope this helps others to avoid this
kind of headache.
Let's say I have an equilateral triangle. Then, the three Euclidean
distances between points A, B, and C are all equal. That is,
dist(AB)=dist(AC)=dist(BC). Let the points A, B, and C have
(x,y)-coordinates (0,0), (2,0), and (1,sqrt(3)). Then, MDS should reproduce
an equilateral triangle, which it does if there are only three points.
require(MASS)
x=c(0,2,1,0,0,sqrt(3))
dim(x)=c(3,2)
d1=dist(x)
fit1<-isoMDS(d1)
plot(fit1$points, xlab="Coordinate 1", ylab="Coordinate 2",
main="Metric MDS",type="n")
text(fit1$points, labels = c('A','B','C'), cex=1)
So far so good, until I add more points. Now assume, I add a fourth point D
at {0,2*sqrt(3)}. This produces the rectangular triangle ABD with
hypothenuse BD that encompasses the smaller triangle ABC such that C lies in
the middle between B and D. Then, MDS should reproduce the rectangular
triangle ABD and the equilateral triangle ABC within it. However, even
though distance matrix d2 below still indicates that ABC is an equilateral
triangle, the plot of the MDS does not confirm this.
x=c(0,2,1,0,0,0,sqrt(3),2*sqrt(3))
dim(x)=c(4,2)
d2=dist(x)
fit2<-isoMDS(d2)
plot(fit2$points, xlab="Coordinate 1", ylab="Coordinate 2",
main="Metric MDS",type="n")
text(fit2$points, labels = c('A','B','C','D'), cex=1)
The reason for this is that the dimension of the plot is automatically
scaled to fit the points. This distorts the visual impression of the
distances, angular relationships, and relative locations. If you plot on a
square pane, however, peace and order are restored in the galaxy.
plot(fit2$points, xlab="Coordinate 1", ylab="Coordinate 2",
main="Metric MDS",type="n",xlim=c(-3,3),ylim=c(-3,3))
text(fit2$points, labels = c('A','B','C','D'), cex=1)
Best,
Daniel
--
View this message in context: http://r.789695.n4.nabble.com/Plotting-MDS-multidimensional-scaling-tp3422670p3422670.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list