top of page
  • Twitter
  • LinkedIn
  • Facebook

Revolutionizing Portfolio Management with Network Theory (R Code)

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

Aktualisiert: 23. Juni 2025

Gueorgui S. Konstantinov, and Frank J. Fabozzi. 2025. Journal of Financial Data Science 7 (2): 166-183.



#The S&P500 BA Model with preferential attatchment

A<-as.matrix(ba.model)

colnames(A)<-t(SPX.Index.Members)

ba.model<-graph_from_adjacency_matrix(A)


#ba.model<-barabasi.game(502,power=1, out.dist=c(0.25,0.65,0.25,0.25), directed=FALSE,zero.appeal=1)

E(ba.model)$arrow.size<-0

V(ba.model)$size<-5

V(ba.model)[degree(ba.model)>mean(degree(ba.model))]$color="red"

plot(ba.model, vertex.label.cex=.3,vertex.size=degree(ba.model)/10,layout=layout_with_kk)



netz_spx<-sample_pa(502)

A<-as.matrix(netz_spx)

colnames(A)<-(SPX.Index.Members)

netz_sp500<-graph_from_adjacency_matrix(A)

V(netz_sp500)[degree(netz_sp500)>mean(degree(netz_sp500))]$color="red"

plot(netz_sp500,vertex.size=degree(netz_sp500)/5,vertex.label.cex=.3, layout=layout_with_kk)


#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