Description Usage Arguments Value References Examples
msm
is a Bayesian model inferring mixtures of subspaces that are of possibly different dimensions.
For simplicity, this function returns only a handful of information that are most important in
representing the mixture model, including projection, location, and hard assignment parameters.
1 2 3 4 5 6 7 8 9 10 |
X |
an (n\times p) data matrix. |
K |
the number of mixtures. |
iter |
the number of MCMC runs. |
prop.var |
proposal variance parameter. |
temperature |
temperature value for Gibbs posterior. |
burn.in |
burn-in for MCMC runs. |
thin |
interval for recording MCMC runs |
print.progress |
a logical; |
a list whose elements are also lists of following elements:
length-K
list of projection matrices.
length-K
list of orthonormal basis.
length-K
list of center locations of each mixture.
length-n
vector of cluster label.
thomas_learning_2015mosub
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ## generate a toy example
set.seed(10)
tester = gen.LP(n=100, K=2, iso.var=0.1)
data = tester$data
label = tester$class
## do PCA for data reduction
proj = base::eigen(stats::cov(data))$vectors[,1:2]
dat2 = data%*%proj
## run MSM algorithm with K=2, 3, and 4
maxiter = 1000
output2 = msm(data, K=2, iter=maxiter)
output3 = msm(data, K=3, iter=maxiter)
output4 = msm(data, K=4, iter=maxiter)
## extract final clustering information
nrec = length(output2)
finc2 = output2[[nrec]]$cluster
finc3 = output3[[nrec]]$cluster
finc4 = output4[[nrec]]$cluster
## visualize
opar <- par(mfrow=c(3,4))
plot(dat2[,1],dat2[,2],pch=19,cex=0.3,col=finc2+1,main="K=2:PCA")
plot(data[,1],data[,2],pch=19,cex=0.3,col=finc2+1,main="K=2:Axis(1,2)")
plot(data[,1],data[,3],pch=19,cex=0.3,col=finc2+1,main="K=2:Axis(1,3)")
plot(data[,2],data[,3],pch=19,cex=0.3,col=finc2+1,main="K=2:Axis(2,3)")
plot(dat2[,1],dat2[,2],pch=19,cex=0.3,col=finc3+1,main="K=3:PCA")
plot(data[,1],data[,2],pch=19,cex=0.3,col=finc3+1,main="K=3:Axis(1,2)")
plot(data[,1],data[,3],pch=19,cex=0.3,col=finc3+1,main="K=3:Axis(1,3)")
plot(data[,2],data[,3],pch=19,cex=0.3,col=finc3+1,main="K=3:Axis(2,3)")
plot(dat2[,1],dat2[,2],pch=19,cex=0.3,col=finc4+1,main="K=4:PCA")
plot(data[,1],data[,2],pch=19,cex=0.3,col=finc4+1,main="K=4:Axis(1,2)")
plot(data[,1],data[,3],pch=19,cex=0.3,col=finc4+1,main="K=4:Axis(1,3)")
plot(data[,2],data[,3],pch=19,cex=0.3,col=finc4+1,main="K=4:Axis(2,3)")
par(opar)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.