CONvergence of iterated CORrelations (CONCOR) R function

KNOKE BUREAUCRACIES network data used here were obtained through UCINET software.

For an excellent method tutorial on blockmodeling with UCINET see the file Blockmodels.doc written by David Knoke and hosted on his SOC 8412 homepage.

# Stack matricies and matrix transposes
KNOKI <- read.table("KNOKI.txt",header=FALSE,sep="")
KNOKM <- read.table("KNOKM.txt",header=FALSE,sep="")
KNOKIT <- t(KNOKI)
KNOKMT <- t(KNOKM)
KNOK <- rbind(KNOKI,KNOKIT,KNOKM,KNOKMT)

# CONCOR function
# CONvergence of iterated CORrelations
# Creates a square matrix of correlations of the column pairs of a matrix
CONCOR <- function(mat){
    colN <- ncol(mat)
    X <- matrix(rep(0,times=colN*colN),nrow=colN,ncol=colN)
    for(i in 1:colN){
        for(j in i:colN){
            X[i,j] <- cor(mat[,i],mat[,j],method=c("pearson"))
        }
    }
    X <- X+(t(X)-diag(diag((X))))
return(X)
}

KNOKSIM <- CONCOR(KNOK)
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s