cmds: Classical Multidimensional Scaling

View source: R/cmds.R

cmdsR Documentation

Classical Multidimensional Scaling

Description

Classical multidimensional scaling aims at finding low-dimensional structure by preserving pairwise distances of data.

Usage

cmds(data, ndim = 2)

Arguments

data

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

ndim

an integer-valued target dimension.

Value

a named list containing

embed

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

stress

discrepancy between embedded and origianl data as a measure of error.

References

\insertRef

torgerson_multidimensional_1952maotai

Examples

## use simple example of iris dataset
data(iris) 
idata = as.matrix(iris[,1:4])
icol  = as.factor(iris[,5])   # class information

## run Classical MDS
iris.cmds = cmds(idata, ndim=2)

## visualize
opar <- par(no.readonly=TRUE)
plot(iris.cmds$embed, col=icol, 
     main=paste0("STRESS=",round(iris.cmds$stress,4)))
par(opar)


maotai documentation built on March 31, 2023, 6:48 p.m.