Vector of Matrices of Varying Dimensions



I am trying to program a simple Kalman Filter and Smoother that incorporates the possibility of partially missing observations in the observables vector. However, this would require to store arrays of varying dimensions. The innovations vector and the innovations covariance matrix are of time varying dimensions depending on which observations are available. What would be an efficient way to deal with this?

The third dimension of the arrays (one for the innovations and one for the covariance of the innovations) should be time, while the other two will depend on the specific situation.


I think that interesting keywords to use for searching existing solutions to this kind of problems are “ragged” or “non-rectangular” arrays.

One possibility is to actually have a vector of arrays (of possibly varying dimensions), i.e a structure typed like Vector{Array{T,2}} for example. Then you can either use it directly (a[i][j,k], where i indexes time, and bounds for j,k depend on i) or use tools such as RecursiveArrayTools to wrap your structure in an object which provides the same access as if it were a higher dimensional array (a[i,j,k]).

Another possibility is to directly use a data structure which supports ragged data. Packages like RaggedData or RaggedArrays seem to provide these kinds of features. There might be others.