Function to calculate the similarity matrix based on the cluster membership indicator of each iteration.
Function to calculate the similarity matrix based on the cluster membership indicator of each iteration.
calSim(mat)
Arguments
mat: A matrix of cluster membership indicators.
Returns
returns a similarity matrix.
Examples
n =90## number of subjectsiters =200## number of iterations## matrix of cluster membership indicators## perfect clustering with three clustersmat = matrix(rep(1:3,each=n/3),nrow=n,ncol=iters)sim = calSim(t(mat))## plot similarity matrixx <- rep(1:n,times=n)y <- rep(1:n,each=n)z <- as.vector(sim)levelplot(z~x*y,col.regions=rev(gray.colors(n^2)), xlab ="Subject ID",ylab ="Subject ID")