Learn R Programming

bclust (version 1.3)

bclust: Bayesian agglomerative clustering for high dimensional data with variable selection.

Description

The function clusters data saved in a matrix using an additive linear model with disappearing random effects. The model has built-in spike-and-slab components which quantifies important variables for clustering and can be extracted using the imp function.

Usage

bclust(x,rep.id=1:nrow(x),effect.family="gaussian",
var.select=TRUE,transformed.par,labels=NULL)

Arguments

x
A numeric matrix, with clustering individuals in rows and variables in columns.
rep.id
A vector consisting of positive integer elements having the same length as the number of rows of x. This vector identifies replicates of a clustering type such that the total number of clustering types is max(rep.id). If nothing
effect.family
Distribution family of the disappearing random components. The choices are "gaussian" or "alaplace" allowing Gaussian or asymmetric Laplace family, respectively.
var.select
A logical value, TRUE for fitting models that define spike-and-slab distribution in variable level and allows Bayesian variable selection.
transformed.par
The transformed model parameters in a vector. The length of the vector depends on the chosen model and the availability of variable selection. The log transformation is supposed to be applied for the variance parameters, the identity for the mean, and t
labels
A vector of strings referring to the labels of clustering types. The length of the vector should match to max(rep.id). The first element corresponds to the label of the type having the smallest integer value in rep.id, the seco

Value

  • dataThe data matrix, reordered according to rep.id.
  • repnoThe number of replicates of the values of rep.id
  • mergeThe merge matrix, in hclust object format.
  • heightA monotone vector referring to the height of the constructed tree.
  • logposteriorThe log posterior for each merge.
  • clust.numberThe number of clusters for each merge.
  • cutThe value of the height corresponding to the maximum of the log posterior in agglomerative path.
  • transformed.parThe transformed values of the model parameters. The log transformation is applied for the variance parameters, the identity for the mean, and the logit for the proportions.
  • labelsThe labels associated to each clustering type.
  • effect.familyThe distribution assigned to the disappearing random effect in the function arguments.
  • var.selectThe variable selection chosen in the function arguments.

Details

The function calls internal C functions depending on the chosen model. The C-stack of the system may overflow if you have a large dataset. You may need to adjust the stack before running R using your operation system command line. If you use Linux, open a console and type >ulimit -s unlimited and then run R in the same console. The Microsoft Windows users don't need to increase the stack size.

We assumed a Bayesian linear model for clustering being $$y_{vctr}=\mu+\eta_{vct}+\delta_v \gamma_{vc}\theta_{vc}+\varepsilon_{vctr}$$ where $y_{vctr}$ is the available data on variable $v$, cluster $c$, clustering type $t$, and replicate $r$; $\eta_{vct}$ is the between-type error, $\theta_{vc}$ is the disappearing random component controlled by the Bernoulli variables $\delta_v$ with success probability $q$ and $\gamma_{vc}$ with success probability $p$; and $\varepsilon_{vctr}$ is the between-replicate error. The types inside a cluster share the same $\theta_{vc}$, but may arise with a different $\eta_{vct}$. For more details see Vahid Partovi Nia and Anthony C. Davison (2012)

References

Vahid Partovi Nia and Anthony C. Davison (2012). High-Dimensional Bayesian Clustering with Variable Selection: The R Package bclust. Journal of Statistical Software, 47(5), 1-22. URL http://www.jstatsoft.org/v47/i05/

See Also

loglikelihood, meancss, imp.

Examples

Run this code
data(gaelle)

# unreplicated clustering
gaelle.bclust<-bclust(x=gaelle,
transformed.par=c(-1.84,-0.99,1.63,0.08,-0.16,-1.68)) 
par(mfrow=c(2,1))
plot(as.dendrogram(gaelle.bclust))
abline(h=gaelle.bclust$cut)
plot(gaelle.bclust$clust.number,gaelle.bclust$logposterior,
xlab="Number of clusters",ylab="Log posterior",type="b")
abline(h=max(gaelle.bclust$logposterior))

#replicated clustering
gaelle.id<-rep(1:14,c(3,rep(4,13))) 
# first 3 rows replication of ColWT 
# 4 replications for the others

gaelle.lab<-c("ColWT","d172","d263","isa2",
"sex4","dpe2","mex1","sex3","pgm","sex1",
"WsWT","tpt","RLDWT","ke103")

gaelle.bclust<-bclust(gaelle,rep.id=gaelle.id,labels=gaelle.lab,
transformed.par=c(-1.84,-0.99,1.63,0.08,-0.16,-1.68))
plot(as.dendrogram(gaelle.bclust))
abline(h=gaelle.bclust$cut)
plot(gaelle.bclust$clust.number,gaelle.bclust$logposterior,
xlab="Number of clusters",ylab="Log posterior",type="b")
abline(h=max(gaelle.bclust$logposterior))

Run the code above in your browser using DataLab