Learn R Programming

Rdimtools (version 0.3.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 = c("center", "scale", "cscale",
  "decorrelate", "whiten"))

Arguments

X

an \((n\times 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. Default is "center". See also aux.preprocess for more details.

Value

a named list containing

Y

an \((n\times ndim)\) matrix whose rows are embedded observations.

trfinfo

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

projection

a \((p\times 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.
output1 <- do.mds(X,ndim=2)

## 2. different preprocessing leads to different results
output2 <- do.mds(X,ndim=2,preprocess="decorrelate")
output3 <- do.mds(X,ndim=2,preprocess="whiten")

## 3. visualize
par(mfrow=c(1,3))
plot(output1$Y[,1],output1$Y[,2],main="center")
plot(output2$Y[,1],output2$Y[,2],main="decorrelate")
plot(output3$Y[,1],output3$Y[,2],main="whiten")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab