<< missrv Basic functions mlag0 >>

Grocer >> Basic functions > mlag

mlag

lag of a matrix

CALLING SEQUENCE

[xlag]=mlag(x,n,init)

PARAMETERS

Input

* x = a matrix (or vector), nobs x nvar

* n = # of contiguous lags for each vector in x

* init = (optional) scalar value to feed initial missing values (default = 0)

 

Output

* xlag = a matrix of lags (nobs x nvar*nlag)

collected as: x1(t-1), x1(t-2), ... x1(t-nlag), x2(t-1), ... x2(t-nlag),...

DESCRIPTION

Generates a matrix of n lags from a matrix (or vector) containing a set of vectors (for use in var routines)

EXAMPLE

x1=ones(7,1);x2=[1:7]';y = mlag([x1 x2],2,4)
//returns:
//!   4.    4.    4.    4. !
//!   1.    4.    1.    4. !
//!   1.    1.    2.    1. !
//!   1.    1.    3.    2. !
//!   1.    1.    4.    3. !
//!   1.    1.    5.    4. !
//!   1.    1.    6.    5. !
 
elag = mlag(rols('resid'),nobse/6);
// Example taken from function var1: takes the residuals from a regression and stores all lags from 1 to nobse/6 to prepare the calculation of the Box-Pierce statistics.

AUTHOR

Eric Dubois 2002

Report an issue
<< missrv Basic functions mlag0 >>