[R] Ordered Multidimensional Arrays

Patrick Burns pburns at pburns.seanet.com
Tue Dec 23 21:08:16 CET 2008


The old fashioned solution is to have the N x N x T
array and use character strings of the dates as the
dimnames on the third dimension.

Is there something you think you need to do that is
hard with such a setup?


Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

Derek Schaeffer wrote:
> Hi,
> I am inquiring as to what are the best practices with respect to storing and
> manipulating ordered multi-dimensional arrays.  For example, suppose I have
> a sequence of time-varying covariance matrices of asset returns.  The data
> is ordered, but the ordering is not necessarily regular (e.g. daily data
> omitting weekends and holidays, etc.).  The data array is say, N x N x T.
> For example, the first two elements may look as follows:
>
>   
>> *result$covariance[,,1:2]
>>     
> , , 1*
> *             [,1]         [,2]         [,3]         [,4]
> [1,] 1.511137e-06 1.918668e-06 1.201553e-06 3.205271e-06
> [2,] 1.918668e-06 7.488916e-06 6.593317e-06 1.203421e-05
> [3,] 1.201553e-06 6.593317e-06 1.305861e-05 2.132272e-05
> [4,] 3.205271e-06 1.203421e-05 2.132272e-05 4.571225e-05*
> *, , 2*
> *             [,1]         [,2]         [,3]         [,4]
> [1,] 1.500858e-06 1.905574e-06 1.193412e-06 3.183290e-06
> [2,] 1.905574e-06 7.444871e-06 6.555459e-06 1.195876e-05
> [3,] 1.193412e-06 6.555459e-06 1.297075e-05 2.117777e-05
> [4,] 3.183290e-06 1.195876e-05 2.117777e-05 4.551706e-05*
>
> I would like to be able to partition this sequence of matrices by date and
> by individual element.  Partitioning by individual elements is trivial;
> however, partitioning by time stamp is not (especially if the partitioned
> data set must be carried through a number of downstream calculations).  I
> could carry the data in a list complete with a date vector and the data
> array, and partition the list as I go, but this seems somewhat clunky.  Any
> ideas?  A "zoo"-like package capable of handling multidimensional arrays
> would be optimal, but I don't believe this exists.
>
> Thanks,
> Derek
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>



More information about the R-help mailing list