Re: Construcing correlation matrix from time-ordered list

*To*: mathgroup at smc.vnet.net*Subject*: [mg54780] Re: [mg54707] Construcing correlation matrix from time-ordered list*From*: János <janos.lobb at yale.edu>*Date*: Tue, 1 Mar 2005 01:58:41 -0500 (EST)*References*: <200502270629.BAA25482@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

I took the liberty to modify your data to include different years: In[25]:= data = {{{1897, 1, 4}, 40.37}, {{1897, 1, 5}, 40.87}, {{1897, 1, 6}, 40.95}, {{1898, 1, 7}, 40.87}, {{1898, 1, 8}, 40.97}, {{1898, 1, 11}, 40.75}, {{1899, 1, 12}, 41.4}, {{1899, 1, 13}, 41.45}, {{1899, 1, 14}, 41.79}, {{1899, 1, 15}, 42.27}, {{1896, 1, 18}, 42.76}, {{1896, 1, 19}, 43.25}, {{1895, 1, 20}, 42.78}, {{1895, 1, 21}, 42.52}, {{1894, 1, 22}, 42.42}} Then here are the steps: In[40]:= mm = Sort[Thread[ {Transpose[data][[1]][[ All,1]], Transpose[ data][[2]]}]] In[42]:= nn = Split[mm, #1[[1]] - #2[[1]] == 0 & ] In[59]:= ({First[First[#1]], #1[[All,2]]} & ) /@ nn Out[59]= {{1894, {42.42}}, {1895, {42.52, 42.78}}, {1896, {42.76, 43.25}}, {1897, {40.37, 40.87, 40.95}}, {1898, {40.75, 40.87, 40.97}}, {1899, {41.4, 41.45, 41.79, 42.27}}} János On Feb 27, 2005, at 1:29 AM, Adam Getchell wrote: > Hello all, > I have time series data (a lot of it) in a format like: > {{{1897,1,4},40.37`},{{1897,1,5},40.87`},{{1897,1,6},40.95`}, > {{1897,1,7}, > 40.87`},{{1897,1,8},40.97`},{{1897,1,11},40.75`},{{1897,1,12}, > 41.4`},{{1897,1,13},41.45`},{{1897,1,14},41.79`},{{1897,1,15}, > 42.27`},{{1897,1,18},42.76`},{{1897,1,19},43.25`},{{1897,1,20}, > 42.78`},{{1897,1,21},42.52`},{{1897,1,22},42.42`}} > ie the year, then the value, for 100+ years. > I'd like to construct a correlation matrix so that year values become > columns, e.g. > 1897 1898 > ========== > Value1 Value 1 > Value 2 Value 2 > ... > From my long list of {{{date1},value1},{{date2},value2}} > But I'm not yet sure how to proceed. I'm looking at Cases or Select to > apply a function for each year range that will pick out that column. > Any pointers appreciated. > --Adam Getchell