psych (version 1.0-17)

ICLUST.sort: sort items by absolute size of cluster loadins

Description

Given a cluster analysis or factor analysis loadings matrix, sort the items by the (absolute) size of each column of loadings. Used as part of ICLUST and SAPA analyses.

Usage

ICLUST.sort(ic.load, cut = 0, labels = NULL,loading=TRUE)

Arguments

ic.load
A loading matrix from a factor or principal components analysis, or from ICLUST.
cut
Do not include items in clusters with absolute loadings less than cut
labels
labels for each item.
loading
if coming from a factor analysis or ICLUST output, use loading=TRUE, but, if just sorting a matrix use loading=FALSE

Value

  • clusterA matrix of -1, 0, 1s defining each item by the factor/cluster with the row wise largest absolute loading.
  • loadA data.frame of item numbers, item contents, and item x factor loadings.
  • ...

Details

When interpreting cluster or factor analysis outputs, is is useful to group the items in terms of which items have their biggest loading on each factor/cluster and then to sort the items by size of the absolute factor loading.

A stable cluster solution will be one in which the output of these cluster definitions does not vary when clusters are formed from the clusters so defined.

References

http://personality-project.org/r/r.ICLUST.html

See Also

ICLUST.graph,ICLUST.cluster, cluster.fit, VSS, factor2cluster

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (ic.load,cut=0,labels=NULL,loading=FALSE) {
    if (length(labels)==0) {
    var.labels <- rownames(ic.load)} else {var.labels=labels}
    if(loading) {loadings <- ic.load$loadings} else {loadings <- ic.load}
     nclust <- dim(loadings)[2]
     nitems <- dim(loadings)[1]
   
  load <- data.frame(item=seq(1:nitems),content=var.labels,cluster=rep(0,nitems),loadings)
  
  #first find the maximum for each row and assign it to that cluster
   load$cluster <- apply(abs(loadings),1,which.max)
  for (i in 1:nitems) {if (abs(loadings[i,load$cluster[i]]) < cut) {load$cluster[i] <-nclust+1}}
 
  ord <- sort(load$cluster,index.return=TRUE)
  load[1:nitems,] <- load[ord$ix,]
  rownames(load)[1:nitems] <- rownames(load)[ord$ix]
  
  items <- c(table(load$cluster),1)   #how many items are in each cluster?
  #now sort the loadings that have their highest loading on each cluster
   first <- 1
	for (i in 1:nclust) {
	last <- first + items[i]- 1
	ord <- sort(abs(load[first:last,i+3]),decreasing=TRUE,index.return=TRUE)
   load[first:last,] <- load[ord$ix+first-1,]
    rownames(load)[first:last] <- rownames(load)[ord$ix+first-1]
    first <- first + items[i]
    }
    if (first < nitems) load[first:nitems,"cluster"] <- 0   #assign items less than cut to 0
 ICLUST.sort <- load }

Run the code above in your browser using DataLab