library(igraph)
library(igraph)
library(igraph)
info  <- read.table('sp100-info.csv',header=TRUE,sep='\t')
install.packages("igraph")
library(igraph)
library(glasso)
info  <- read.table('sp100-info.csv',header=TRUE,sep='\t')
D   <- read.table('LVDN_oo.csv',sep=',')
D   <- as.matrix(D)
N     <- ncol(D)
A.hat2 <- 1*( D != 0 ) - diag(rep(1,N))
network.hat <- graph.adjacency( A.hat2 , mode='directed')
deg   <- degree(network.hat)
CC <- evcent(network.hat)
CV <- CC$vector
CS <- sort.int(CV, index.return = TRUE, decreasing = TRUE)
EVCENTRALITY <- CS$ix
V(network.hat)$size <- round( (deg/max(deg))*10+2 )
V(network.hat)$color[ info$GICS.Sector=='Industrials' ]                 <- 'red'
V(network.hat)$color[ info$GICS.Sector=='Financials' ]                  <- 'yellow'
V(network.hat)$color[ info$GICS.Sector=='Utilities' ]                   <- 'orange'
V(network.hat)$color[ info$GICS.Sector=='Consumer Staples' ]            <- 'cyan'
V(network.hat)$color[ info$GICS.Sector=='Energy' ]                      <- 'blue'
V(network.hat)$color[ info$GICS.Sector=='Health Care' ]                 <- 'pink'
V(network.hat)$color[ info$GICS.Sector=='Information Technology' ]      <- 'green'
V(network.hat)$color[ info$GICS.Sector=='Materials' ]                   <- 'purple'
V(network.hat)$color[ info$GICS.Sector=='Consumer Discretionary' ]      <- 'grey'
V(network.hat)$color[ info$GICS.Sector=='Telecommunications Services' ] <- 'white'
V(network.hat)$label <- as.character( info$Ticker.symbol )
E(network.hat)$color <- rep( '#222222' , length( E(network.hat) ) )
plot( network.hat )
# interactive plot...
tkplot( network.hat)
install.packages("igraph")
library(igraph)
library(glasso)
info  <- read.table('sp100-info.csv',header=TRUE,sep='\t')
D   <- read.table('LVDN_oo.csv',sep=',')
D   <- as.matrix(D)
N     <- ncol(D)
A.hat2 <- 1*( D != 0 ) - diag(rep(1,N))
network.hat <- graph.adjacency( A.hat2 , mode='directed')
deg   <- degree(network.hat)
CC <- evcent(network.hat)
CV <- CC$vector
CS <- sort.int(CV, index.return = TRUE, decreasing = TRUE)
EVCENTRALITY <- CS$ix
V(network.hat)$size <- round( (deg/max(deg))*10+2 )
V(network.hat)$color[ info$GICS.Sector=='Industrials' ]                 <- 'red'
V(network.hat)$color[ info$GICS.Sector=='Financials' ]                  <- 'yellow'
V(network.hat)$color[ info$GICS.Sector=='Utilities' ]                   <- 'orange'
V(network.hat)$color[ info$GICS.Sector=='Consumer Staples' ]            <- 'cyan'
V(network.hat)$color[ info$GICS.Sector=='Energy' ]                      <- 'blue'
V(network.hat)$color[ info$GICS.Sector=='Health Care' ]                 <- 'pink'
V(network.hat)$color[ info$GICS.Sector=='Information Technology' ]      <- 'green'
V(network.hat)$color[ info$GICS.Sector=='Materials' ]                   <- 'purple'
V(network.hat)$color[ info$GICS.Sector=='Consumer Discretionary' ]      <- 'grey'
V(network.hat)$color[ info$GICS.Sector=='Telecommunications Services' ] <- 'white'
V(network.hat)$label <- as.character( info$Ticker.symbol )
E(network.hat)$color <- rep( '#222222' , length( E(network.hat) ) )
plot( network.hat )
# interactive plot...
tkplot( network.hat)
install.packages("glasso")
library(igraph)
library(glasso)
info  <- read.table('sp100-info.csv',header=TRUE,sep='\t')
D   <- read.table('LVDN_oo.csv',sep=',')
D   <- as.matrix(D)
N     <- ncol(D)
A.hat2 <- 1*( D != 0 ) - diag(rep(1,N))
network.hat <- graph.adjacency( A.hat2 , mode='directed')
deg   <- degree(network.hat)
CC <- evcent(network.hat)
CV <- CC$vector
CS <- sort.int(CV, index.return = TRUE, decreasing = TRUE)
EVCENTRALITY <- CS$ix
V(network.hat)$size <- round( (deg/max(deg))*10+2 )
V(network.hat)$color[ info$GICS.Sector=='Industrials' ]                 <- 'red'
V(network.hat)$color[ info$GICS.Sector=='Financials' ]                  <- 'yellow'
V(network.hat)$color[ info$GICS.Sector=='Utilities' ]                   <- 'orange'
V(network.hat)$color[ info$GICS.Sector=='Consumer Staples' ]            <- 'cyan'
V(network.hat)$color[ info$GICS.Sector=='Energy' ]                      <- 'blue'
V(network.hat)$color[ info$GICS.Sector=='Health Care' ]                 <- 'pink'
V(network.hat)$color[ info$GICS.Sector=='Information Technology' ]      <- 'green'
V(network.hat)$color[ info$GICS.Sector=='Materials' ]                   <- 'purple'
V(network.hat)$color[ info$GICS.Sector=='Consumer Discretionary' ]      <- 'grey'
V(network.hat)$color[ info$GICS.Sector=='Telecommunications Services' ] <- 'white'
V(network.hat)$label <- as.character( info$Ticker.symbol )
E(network.hat)$color <- rep( '#222222' , length( E(network.hat) ) )
plot( network.hat )
# interactive plot...
tkplot( network.hat)
