Learn R Programming

Rdimtools (version 1.0.4)

do.bmds: Bayesian Multidimensional Scaling

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. A note on the method is that this algorithm does not return an explicit form of projection matrix so it's classified in our package as a nonlinear method. Also, automatic dimension selection is not supported for simplicity as well as consistency with other methods in the package.

Usage

do.bmds(
  X,
  ndim = 2,
  par.a = 5,
  par.alpha = 0.5,
  par.step = 1,
  mc.iter = 50,
  preprocess = c("null", "center", "scale", "cscale", "whiten", "decorrelate"),
  print.progress = FALSE
)

Arguments

X

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

ndim

an integer-valued target dimension.

par.a

hyperparameter for conjugate prior on variance term, i.e., \(\sigma^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., \(\lambda_j \sim IG(\alpha, \beta_j)\). Note that \(\beta_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.

preprocess

an additional option for preprocessing the data. Default is "null". See also aux.preprocess for more details.

print.progress

a logical; TRUE to show iterations, FALSE otherwise.

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.

References

oh_bayesian_2001Rdimtools

Examples

Run this code
# NOT RUN {
## load iris data
data(iris)
set.seed(100)
subid = sample(1:150,50)
X     = as.matrix(iris[subid,1:4])
label = as.factor(iris[subid,5])

## try different preprocessing
out1 <- do.bmds(X, ndim=2, preprocess="center")
out2 <- do.bmds(X, ndim=2, preprocess="cscale")
out3 <- do.bmds(X, ndim=2, preprocess="decorrelate")

## embeddings for each procedure
Y1 <- out1$Y; Y2 <- out2$Y; Y3 <- out3$Y

## visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,3))
plot(Y1, main="BMDS::iter=5",  col=label, pch=19)
plot(Y2, main="BMDS::iter=10", col=label, pch=19)
plot(Y3, main="BMDS::iter=50", col=label, pch=19)
par(opar)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab