data for financial net model and code for graph laplacian and degree distribution
Inbox

x 

4:29 PM (34 minutes ago)



1. code for creating and dumping a single large Ranalyzable table that works attached along with a snapshot showing that column means seem sensible. This code needs a minor change pointing to the directory where all the .csv flat files with historical stock price data exists.
I will get you full dataset analyzable with R along with graphs of Laplacian and degree spectrum within the hour. With R package igraph these are simple exercises once the large matrix of daily volatility are avaliable.
We create a covariance matrix and threshold by a single standard deviation to remove noise and then use the nonzero values to create an adjacency matrix deleting the diagonal! And then just use eigen() to get the spectrum. igraph has a degree.distributution function for a graph so that’s trivial.
2 Attachments
Preview attachment Screenshot from 20150530 16:23:07.png
Screenshot from 20150530 16:23:07.png
Preview attachment createreturnmatrix.py
createreturnmatrix.py

4:43 PM (20 minutes ago)



Attached is the entire large matric containing closing prices for all the stocks in a large table that one can gunzip and pull into R. A scan showed that minus expected missing data this looks good.
Here is my analysis code again in R:
# code to generate the fundamental VOLATILITY data
V<read.table(‘volatility.csv’, sep=’,’,header=TRUE)
n<dim(as.matrix(V))[2]
prices<as.matrix(V)[,2:n]
returns<diff(log(prices))
eps<10e6
noisy.volatility<log(returns**2+eps)
# we create a graph using volatilities correlated by subtracting diagonal
# then soft thresholding by sd, and then setting all nonzero entries to 1
C<matrix.cov( noisy.volatility)
C<Cdiag(C)
C<Csd(C)
C[C<0]<0
A<C
A[A>0]<1
# now create a graph from these data using A as adjacency matrix
library(igraph)
graph<graph.adjacency( A )
# plot the Laplace spectrum
H<graph.laplacian( graph )
E<eigen(H)$value
plot(E)
# plot the degree distribution
D<degree.distribution(graph)
plot(D)
Now we can check these against the degree distribution of power law (which is not happening here) and Laplace spectrum which is quite different from the ErdosRenyi random graphs and others which is the interesting thing I found in the smaller dataset of 188 nodes.
Attachments area
Advertisements
Leave a Reply