top of page
  • Twitter
  • LinkedIn
  • Facebook

A Correlation Network

  • gkonstantinov1111
  • 19. Juni 2025
  • 1 Min. Lesezeit

Aktualisiert: 23. Juni 2025

Gueorgui S. Konstantinov and Frank J. Fabozzi - Network Models in Finance: Expanding the Tools for Portfolio and Risk Management, John Wiley & Sons, 2025



How to build a Correlation Network? Below you can see the simple code in the R programming language that helps to build a simple correlation network. Important issue is to integrate a threshold level for the correlations.


#Unirected Partial-Cor Network with Fischer Transformation Volatility as Compromise and Bonferroni Adj for DJIA

#JFDS Code Exhibit 1 for Konstantinov and Fabozzi (2025) - Network Models in Finance


#run only when initially Import Index Returns

colnames(INDU_experimental)<- sapply(strsplit(colnames(INDU_experimental), split='X.', fixed=TRUE), function(x) (x[2]))


set.seed(3211)

returns_indu<-INDU_experimental

mtx_pcor_indu<-data.frame()

mtx_pcor_indu<-matrix(nrow=ncol(INDU_experimental),ncol=ncol(INDU_experimental))

mtx_pcor_indu<-as.matrix(mtx_pcor_indu)

mat_pcor_indu=0.5*log((1+pcor(returns_indu)$estimate)/(1-pcor(returns_indu)$estimate))

mat_pcor_indu=abs(mat_pcor_indu)

p.t.adj=0.05

mat_pcor_indu<-ifelse(mat_pcor_indu[,]<p.t.adj,1,0)

diag(mat_pcor_indu)<-0

colnames(mat_pcor_indu)<-colnames(INDU_experimental)

print(mat_pcor_indu)

netz_pcor_indu<-as.matrix(mat_pcor_indu)

netz_pcor_indu<-graph_from_adjacency_matrix(netz_pcor_indu, weighted=TRUE)

hist(degree_distribution(netz_pcor_indu))

E(netz_pcor_indu)$arrow.size<-1


par(mfrow=c(1,2))

barplot(sort(degree(netz_pcor_indu), decreasing=TRUE), lwd=0.5, cex.names=0.7,cex.axis=0.7,las=2)


barplot(sort(eigen_centrality(netz_pcor_indu)$vector, decreasing=TRUE), lwd=0.5, cex.names=0.7,cex.axis=0.7,las=2)

ecs_pcor<-as.matrix(eigen_centrality(netz_pcor_indu)$vector)

par(mfrow=c(1,1))

csg<-cluster_spinglass(netz_pcor_indu)

E(netz_pcor_indu)$arrow.size<-0

plot(csg, netz_pcor_indu, vertex.size=degree(netz_pcor_indu), vertex.color=csg$membership, edge.color=E(netz_pcor_indu)$csg, edge.width=E(netz_pcor_indu)$weight/1000)


plot(netz_pcor_indu, vertex.size=eigen_centrality(netz_pcor_indu)$vector*20, vertex.color=csg$membership, edge.color=E(netz_pcor_indu)$csg, edge.width=E(netz_pcor_indu)$weight, layout=layout_with_gem)

plot(csg, netz_pcor_indu, vertex.label.cex=0.5,vertex.size=degree(netz_pcor_indu), vertex.color=csg$membership, edge.color=E(netz_pcor_indu)$csg, edge.width=E(netz_pcor_indu)$weight, layout=layout_with_gem)

 
 
 

Kommentare


bottom of page