mlag.m (435B)
1 % MLAG.m Multiple Series Lag 2 % Accepts a (TxK) matrix y and a 1xK vector lag and returns the 3 % (T-max(lag))x(K+sum(lag)) matrix that contains the original data 4 % and the lags, all of the same length: 5 % 6 % e.g. [y1 y1(-1) y2 y2(-1) y2(-2)] if lag=[ 1 2 ] 7 8 function z=mlag(y,lag); 9 10 [T K] = size(y); 11 M = max(lag); 12 13 z=[]; % Stack things horizontally here... 14 for i=1:K; 15 [y1 y2] = lagx(y(:,i),M); 16 z = [z y1 y2(:,1:lag(i))]; 17 end;