[R] Difference between prcomp and cmdscale

From: michael watson (IAH-C) <michael.watson_at_bbsrc.ac.uk>
Date: Thu, 14 Jun 2007 09:33:42 +0100

I'm looking for someone to explain the difference between these procedures. The function prcomp() does principal components anaylsis, and the function cmdscale() does classical multi-dimensional scaling (also called principal coordinates analysis).

My confusion stems from the fact that they give very similar results:

my.d <- matrix(rnorm(50), ncol=5)
rownames(my.d) <- paste("c", 1:10, sep="")
# prcomp

prc <- prcomp(my.d)
# cmdscale

mds <- cmdscale(dist(my.d))
cor(prc$x[,1], mds[,1]) # produces 1 or -1 cor(prc$x[,2], mds[,2]) # produces 1 or -1

Presumably, under the defaults for these commands in R, they carry out the same (or very similar) procedures?


The information contained in this message may be confidentia...{{dropped}}

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 and provide commented, minimal, self-contained, reproducible code. Received on Thu 14 Jun 2007 - 08:42:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 14 Jun 2007 - 12:31:57 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.