On Fri, 15 Feb 2002, Bill Simpson wrote:
> In applying multidimensional scaling, it seems to me that sometimes the
> underlying dimensionality of the matrix is 1. However I found a case
> where cmdscale failed when I tried k=1. Here it is:
>
> m<-matrix(
> c(.5,.81,.23,.47,.61,
> .19,.5,.06,.17,.28,
> .77,.94,.5,.74,.85,
> .53,.83,.26,.5,.64,
> .39,.72,.15,.36,.5),
> nrow=5)
>
> # BTW I think cmdscale uses only the lower triangle--how to enter only
> # that bit and save some data entry?
>
> fit<-cmdscale(dist(m),k=2) #k is number of dimensions
> rownames(m,do.NULL=FALSE)
>
rownames(m)<-c("A","B","C","D","E")
>
> x <- fit[,1]
> y <- -fit[,2]
> plot(x, y, type="n", xlab="", ylab="")
> text(x, y, rownames(m))
>
> #So far so good. Note that y dimension in plot is very small compared to x
> #should be able to ditch the y dimension
>
> fit<-cmdscale(dist(m),k=1)
> fit
> #nothing!
I get the first column of the k=2 solution, as I should. Using 1.4.1,
BTW.
Since you specified a data matrix, the distance matrix dist(m) is
Euclidean (and it is the lower triangle of that which is used, not of m),
and cmdscale just gives you the data on the principal components. So for
k dimensions cmdscale gives you exactly
predict(princomp(m))[, 1:k, drop = FALSE]
> I found for other matrices that I could use k=1 and the result was
> sensible. I'm not really sure how cmdscale works. Can someone please
tell
> me what is going on and if I'm unreasonable to expect k=1 to work?
It is reasonable to use cmdscale for k=1. It is not reasonable to use it
for Euclidean distances computed from a data matrix, as this is an opaque
and inefficient way to do PCA.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._