find lagged values of variables

3 次查看(过去 30 天)
Fernando
Fernando 2014-6-3
Hi,
I have a matrix of data in which and observation is defined by i (people), j (alternatives), t (time). For each i, j, and t there is a random variable u_{ijt}, and I would like to generate a vector with lagged values of u. So, I have
i=[1 1 1 1 1 1 1 1 2 2 2 2 2]';
j=[1 2 3 1 2 1 2 4 1 2 1 2 4]';
t=[1 1 1 2 2 3 3 3 2 2 3 3 3]';
And I have u=[u_{111} u_{121} u_{131} u_{112} u_{112} u_{122} u_{113} u_{123} u_{143} u_{212} u_{222} u_{213} u_{223} u_{243}]'; where the u_{}'s are, of course, numbers.
Now I want to define the lagged value of u for every i and j, over t. In case the lagged value doesn't exist, as it is the case for j=4 in period 3, then replace by zero.
How can I do this?
Thanks

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by