bmds: Bayesian Multidimensional Scaling

Description Usage Arguments Value References Examples

View source: R/bmds.R

Description

A Bayesian formulation of classical Multidimensional Scaling is presented. Even though this method is based on MCMC sampling, we only return maximum a posterior (MAP) estimate that maximizes the posterior distribution. Due to its nature without any special tuning, increasing mc.iter requires much computation.

Usage

1
2
3
4
5
6
7
8
9
bmds(
  data,
  ndim = 2,
  par.a = 5,
  par.alpha = 0.5,
  par.step = 1,
  mc.iter = 8128,
  verbose = TRUE
)

Arguments

data

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

ndim

an integer-valued target dimension.

par.a

hyperparameter for conjugate prior on variance term, i.e., σ^2 \sim IG(a,b). Note that b is chosen appropriately as in paper.

par.alpha

hyperparameter for conjugate prior on diagonal term, i.e., λ_j \sim IG(α, β_j). Note that β_j is chosen appropriately as in paper.

par.step

stepsize for random-walk, which is standard deviation of Gaussian proposal.

mc.iter

the number of MCMC iterations.

verbose

a logical; TRUE to show iterations, FALSE otherwise.

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

oh_bayesian_2001amaotai

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## use simple example of iris dataset
data(iris) 
idata = as.matrix(iris[,1:4])

## run Bayesian MDS
#  let's run 10 iterations only.
iris.cmds = cmds(idata, ndim=2)
iris.bmds = bmds(idata, ndim=2, mc.iter=5, par.step=(2.38^2)) 

## extract coordinates and class information
cx = iris.cmds$embed # embedded coordinates of CMDS
bx = iris.bmds$embed #                         BMDS
icol = iris[,5]      # class information

## visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(2,1))
mc = paste0("CMDS with STRESS=",round(iris.cmds$stress,4))
mb = paste0("BMDS with STRESS=",round(iris.bmds$stress,4))
plot(cx, col=icol,pch=19,main=mc)
plot(bx, col=icol,pch=19,main=mb)
par(opar)

maotai documentation built on Oct. 25, 2021, 9:06 a.m.