Learn R Programming

Rdimtools (version 0.1.2)

do.mds: (Classical) Multidimensional Scaling

Description

do.mds performs a classical Multidimensional Scaling (MDS) using Rcpp and RcppArmadillo package to achieve faster performance than cmdscale.

Usage

do.mds(X, ndim = 2, preprocess = "center")

Arguments

X

an (n-by-p) matrix or data frame whose rows are observations and columns represent independent variables.

ndim

an integer-valued target dimension.

preprocess

an option for preprocessing the data. This supports three methods, ``center'',``decorrelate'', or ``whiten''. See also aux.preprocess for more details.

Value

a named list containing

Y

an (n-by-ndim) matrix whose rows are embedded observations.

trfinfo

a list containing information for out-of-sample prediction.

projection

a (p-by-ndim) whose columns are basis for projection.

References

kruskal_multidimensional_1964Rdimtools

Examples

Run this code
# NOT RUN {
# generate data
X <- rbind(matrix(rnorm(100),nr=10),matrix(rnorm(100),nr=10)+10)

## 1. projection onto 2 dimension.
output <- do.mds(X,ndim=2)
plot(output$Y[,1],output$Y[,2])

## 2. different preprocessing leads to different results
output2 <- do.mds(X,ndim=2,preprocess="decorrelate")
output3 <- do.mds(X,ndim=2,preprocess="whiten")
par(mfrow=c(1,3))
plot(output$Y[,1],output$Y[,2],main="center")
plot(output2$Y[,1],output2$Y[,2],main="decorrelate")
plot(output3$Y[,1],output3$Y[,2],main="whiten")

# }

Run the code above in your browser using DataLab