Multiple lags of time-series in one matrix

135 Views Asked by At

Let's say I have some time-series z.

To get the first lag, I can do:

x1 = z(1:end-1);
y  = z(2:end);

Then both x1 and y will have the same dimensions. How do I do this in a more general way to get also the lags of say 5 periods and 1 periods together in one matrix with same dimensions?

If I do

x1 = z(1:end-1);
x5 = z(1:end-5);
y  = z(2:end);

then x1 will have a different length than x5.

1

There are 1 best solutions below

0
On BEST ANSWER

The circulant matrix $$C_4 = \left[\begin{array}{cccc} 0&1&0&0\\ 0&0&1&0\\ 0&0&0&1\\ 1&0&0&0 \end{array}\right]$$ produces a lag of 1 for a 4 sample long signal. ${C_4}^2$ produces a lag of 2 and so on. Then you may want to crop the data that will "overlap" in the circulation. You can do that with a crop matrix: $\left[\begin{array}{cccc} 1&0&0&0\\ 0&1&0&0\\ 0&0&1&0 \end{array}\right]$ or in general $[\bf I_n, 0]$ where the zero pads number of columns required to make the matrix multiplication ${{\bf MC}_n}^k$ well defined.