# [R] prcomp( and cmdscale( not equivalent?

David Carlson dcarlson at tamu.edu
Mon Apr 29 16:02:35 CEST 2013

```I may not understand completely, but it seems you have a 45x45 distance
matrix of stimuli and you want to use to determine which stimuli are
similar. Wouldn't hierarchical clustering be a more straightforward
approach?

?hclust

-------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Bob Wiley
Sent: Friday, April 26, 2013 4:33 PM
To: r-help at r-project.org
Subject: [R] prcomp( and cmdscale( not equivalent?

Hello,

I have a dilemma that I'm hoping the R gurus will be able to help resolve.
For background:
My data is in the form of a (dis)similarity matrix created from taking the
inverse of normalized reaction times. That is, each cell of the matrix
represents how long it took to distinguish two stimuli from one another-- a
square matrix of 45X45 where the diagonal values are all zero (since this
represents two identical stimuli).

I have been using cmdscale with this matrix as the input--  So:

X = cmdscale(mydata,k=44,add=FALSE,eig=TRUE)\$points returns a 45x34 matrix
because only 34 of the eigenvalues > 0

I then run prcomp on the (transposition of) this matrix:
prcomp(t(X),scale.=TRUE)

The goal is to take the original matrix of inverse reaction times and
transform that data such that we have PCs that show how stimuli are grouping
together-- high absolute value loadings/coordinates on a given dimension
should reflect how similar the stimuli are to one another.

My concern is that I'm not fully understanding the mathematics behind
cmdscale( and prcomp(, and that I may just be losing a lot of information or
introducting noise? Or is my approach theoretically sound... I've read a TON
on this now but I can't see exactly what R is doing with these two
functions.
thank you!

-bob
JHU

Robert (Bob) Wiley

[[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org 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.

```