# Out-of-sample embedding into principal coordinate space

I'm trying to project a point into an existing PCOA (Principal Coordinates Analysis) space (in R). I am under the impression this must be possible, but I can't figure out how to go about it.

Here's how far I've gotten (a toy example):

x <- c(1:10)
y <- c(10:1)
z <- c(rnorm(10,mean=0,sd=2),rnorm(10,mean=10,sd=2))
m <- cbind(x,y,z)

d <- dist(m)
r <- pcoa(d)
biplot(r,m)


The biplot generates the representation I want. Now, given a new point P=(x,y,z) I would like to project it into the above space. The reason I need this and can't simply add this point to the original matrix is that this new point is going to be an outlier and would change the projection of the original space. What I want is to know where this point ends up relative to the untainted representation.

Also note that I don't actually use a Euclidean distance in reality, so doing a PCA is not an option.

• First: If this is not a purely R question but a statistical question, then please show the data and interim results at every step. Second: your example explicitly makes use of euclidean distance and adding a new point with coordinates (x,y,z) also seems implying the euclidean space. Thence your last sentence is mystic so far. Did you mean to say that you won't have (x,y,z) data at all but will have distances at the very beginning? – ttnphns Aug 29 '13 at 15:21
• First: I will add the interim data asap. Second: The distance matrix 'd' is in reality computed using the Jensen–Shannon divergence. The new point has the same coordinate space as the ones originally used, but i fail to see what the transformation might be between those coordinates and the principal coordinates. – Paul Igor Costea Aug 29 '13 at 15:32
• Which R library are you using? (It appears that at least two have a pcoa function: LabDSV and BiodiversityR.) – whuber Aug 29 '13 at 17:31
• Classical MDS takes as it input the pairwise Euclidean distances among n objects and returns the coordinates of n corresponding points in an m-dimensional space whose origin is at the centroid of the configuration, with the reference axes rotated to the principal axes of the configuration. Given the input distances of an (n+1)st object to the n others, the general principal to be followed in augmenting the solution without rerunning the analysis is to place the corresponding point in the m-space so that its distances to the other points approximate the input distances in some sense. – Ray Koopman Aug 30 '13 at 5:20
• Thank you guys for the comments. @whuber I'm using 'ape' and also 'BiodiversityR'. So yes, i have access to the pcoa, but nothing in those packages seems to do the projection of an additional point. And Roy, thanks! I guess i'll just have to implement this myself. Though, i was still hoping that i could somehow use something computed during the MDS step. It would seem to me that the output of the optimization problem should yield a function porting the input space to the projection space. I might be completely wrong about that though – Paul Igor Costea Aug 30 '13 at 9:13

Found a paper that gets the math down: http://www.stat.indiana.edu/files/TR/TR-06-04.pdf

From there it's quite straight forward. I would like to see this implemented in one of the R packages that handles these kinds of things.

• Then what stops you from implementing it? :-) – Marc Claesen Nov 5 '13 at 15:26

For an R solution you might try Bios2mds, which does out-of-sample interpolation (they call it the 'reference' versus 'active' sample)

http://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-13-133

For an R-compatible solution you can try the MDS implementation in SHOGUN toolbox (for which there is an R interface), which is capable of "landmark approximation"

https://github.com/ratschlab/ASP/blob/master/src/shogun/converter/MultidimensionalScaling.h

For a non-R solution you can try the Deterministic Annealing MDS implementation out of Geoffrey Fox's lab, which you can find on github at DSC-SPIDAL/damds

• I've implemented the same extendible metric MDS method used in the R package bios2mds in Python: github.com/grayfall/pymmds. – Eli Korvigo Mar 27 '18 at 20:54