The output of the kmeans clustering function produces a vector of cluster membership. The score.items and cluster.cor functions require a matrix of keys. cluster2keys does this.
May also be used to take the output of an ICLUST analysis and find a keys matrix. (By doing a call to the factor2cluster function.
cluster2keys(c)
| c | A vector of cluster assignments or an object of class ``kmeans" that contains a vector of clusters. |
|---|
Note that because kmeans will not reverse score items, the clusters defined by kmeans will not necessarily match those of ICLUST with the same number of clusters extracted.
A matrix of keys suitable for score.items or cluster.cor
cluster.cor,score.items, factor2cluster, make.keys
test.data <- Harman74.cor$cov kc <- kmeans(test.data,4) keys <- cluster2keys(kc) keys #these match those found by ICLUST#> [,1] [,2] [,3] [,4] #> [1,] 0 0 1 0 #> [2,] 0 0 1 0 #> [3,] 0 0 1 0 #> [4,] 0 0 1 0 #> [5,] 0 1 0 0 #> [6,] 0 1 0 0 #> [7,] 0 1 0 0 #> [8,] 0 1 0 0 #> [9,] 0 1 0 0 #> [10,] 0 0 0 1 #> [11,] 0 0 0 1 #> [12,] 0 0 0 1 #> [13,] 0 0 0 1 #> [14,] 1 0 0 0 #> [15,] 1 0 0 0 #> [16,] 1 0 0 0 #> [17,] 1 0 0 0 #> [18,] 1 0 0 0 #> [19,] 1 0 0 0 #> [20,] 0 0 1 0 #> [21,] 0 0 0 1 #> [22,] 0 0 1 0 #> [23,] 0 0 1 0 #> [24,] 0 0 0 1#> Call: cluster.cor(keys = keys, r.mat = test.data) #> #> (Standardized) Alpha: #> [1] 0.74 0.90 0.80 0.83 #> #> (Standardized) G6*: #> [1] 0.76 0.90 0.83 0.86 #> #> Average item correlation: #> [1] 0.32 0.64 0.36 0.45 #> #> Number of items: #> [1] 6 5 7 6 #> #> Signal to Noise ratio based upon average r and n #> [1] 2.8 8.8 4.0 4.8 #> #> Scale intercorrelations corrected for attenuation #> raw correlations below the diagonal, alpha on the diagonal #> corrected correlations above the diagonal: #> [,1] [,2] [,3] [,4] #> [1,] 0.74 0.52 0.69 0.67 #> [2,] 0.43 0.90 0.72 0.56 #> [3,] 0.53 0.61 0.80 0.63 #> [4,] 0.53 0.48 0.51 0.83