find lagged values of variables

3 views (last 30 days)
Fernando
Fernando on 3 Jun 2014
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

Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!