I try to create code to load times series into the rows of a matrix [serie1, 2, 3, etc.] and then manipulate those time series into a loop (see code below). My problem is threefold (3 loops below):

1-how to create a loop to fill the array's rows one by one. 2-fill a 3d array of with stuff I calculate off those time series (correlation coefficients) 3-calculate the average correlation of the lower triangular matrix for each time period

what i am doing wrong?

thanks a lot for your help!

- Code: Select all
`i=0`

while i<length(fx_tech):

for f in fx_tech:

time_series[:,i]= (LoadSeries(f[2],'7','fx','0',(ts.now('Y')-20).asfreq('B'),ts.now('B')-1,'0','0','B'))

i=1+i

#i want to populate a matrix with all series, fx_tech is a list of series i have

#to feed through the "loadseries" command. I know the first set of loops is wrong.

#then loop over each series pair and populate the matrix "corr"

corr = zeros((len(time_series)-1,len(fx_tech),len(fx_tech))) #allocate matrix

i=0

j=0

while i < len(fx_tech):

while j < len(fx_tech):

corr[:,i,j] = gencorrelation(time_series[:,i],time_series[:,j],lambda1)

j=1+j

i=1+i

#finally calculate the average of the elements below the diagonal for each time period.

mean_fx = []

i=0

while i < len(time_series)-1:

diag[:,:] = corr[i,:,:]-eye(len(fx_tech))

mean_fx.append = sum(diag)/((len(fx_tech)**2)/2-len(fx_tech))

i=1+i