[R] Multidimensional Scaling (MDS) in R

Jari Oksanen jari.oksanen at oulu.fi
Thu Mar 10 07:34:33 CET 2005


This nmds seems to be the wrapper function in the labdsv package. 
Please check the documentation in that package. If I remember 
correctly, labdsv is geared for cases with large number of points, and 
then you don't want to get labels because they would be too congested 
to be seen anyway. The recommended procedure is to identify interesting 
points using 'plotid' function in labdsv.

Function nmds is a very simple wrapper: it uses isoMDS in the MASS 
package, and adds class and some class methods. You may use isoMDS 
directly instead:

dis <- dsvdis(x) # Assuming you use labdsv
ord <- isoMDS(dis)
plot(ord$points, asp = 1, type="n")
text(ord$points, rownames(ord$points)

The posting guide tells  you to make package specific questions to the 
package author directly. In this case, the package author does not read 
R-News.

cheers, jari oksanen

On 8 Mar 2005, at 19:43, Isaac Waisberg wrote:

> Hi;
>
> I am working with the similarity matrix below and I would like to plot
> a two-dimensional MDS solution such as each point in the plot has a
> label.
>
> This is what I did:
>
> data <- read.table('c:/multivariate/mds/colour.txt',header=FALSE)
> similarity <- as.dist(data)
> distance <- 1-similarity
> result.nmds <- nmds(distance)
> plot(result.nmds)
>
> (nmds and plot.nmds as defined at
> labdsv.nr.usu.edu/splus_R/lab8/lab8.html; nmds simply calls isoMDS)
>
> Colour.txt, containing the similaity matrix, reads as follows:
>
>  1.0 .86 .42 .42 .18 .06 .07 .04 .02 .07 .09 .12 .13 .16
>  .86 1.0 .50 .44 .22 .09 .07 .07 .02 .04 .07 .11 .13 .14
>  .42 .50 1.0 .81 .47 .17 .10 .08 .02 .01 .02 .01 .05 .03
>  .42 .44 .81 1.0 .54 .25 .10 .09 .02 .01 .01 .01 .02 .04
>  .18 .22 .47 .54 1.0 .61 .31 .26 .07 .02 .02 .01 .02 .01
>  .06 .09 .17 .25 .61 1.0 .62 .45 .14 .08 .02 .02 .02 .01
>  .07 .07 .10 .10 .31 .62 1.0 .73 .22 .14 .05 .02 .02 .01
>  .04 .07 .08 .09 .26 .45 .73 1.0 .33 .19 .04 .03 .02 .02
>  .02 .02 .02 .02 .07 .14 .22 .33 1.0 .58 .37 .27 .20 .23
>  .07 .04 .01 .01 .02 .08 .14 .19 .58 1.0 .74 .50 .41 .28
>  .09 .07 .02 .01 .02 .02 .05 .04 .37 .74 1.0 .76 .62 .55
>  .12 .11 .01 .01 .01 .02 .02 .03 .27 .50 .76 1.0 .85 .68
>  .13 .13 .05 .02 .02 .02 .02 .02 .20 .41 .62 .85 1.0 .76
>  .16 .14 .03 .04 .01 .01 .01 .02 .23 .28 .55 .68 .76 1.0
>
> The first row corresponds to colour 1 (C1), the second to colour 2
> (C2), and so on.
>
> First, I'm not sure if this is correct or not. Second, obviously the
> points in the plot are not labeled. I suppose I must add a labels
> column and then print the labels together with the results. But, how
> should I do it?
>
> Many thanks,
>
> Isaac
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
>
--
Jari Oksanen, Oulu, Finland




More information about the R-help mailing list