Name

lag — creation of a lagged matrix

CALLING SEQUENCE

[z]=lag(x,n,v)

PARAMETERS

Input

• x = input matrix or vector, (nobs x k)

• n = (kx1) vector of lags

• v = (optional) initial values (default=0)

Output

• z = matrix (or vector) of lags (nobs x k)

DESCRIPTION

Creates a matrix or vector of lagged values if n <= 0, z = [] is returned. While you may find this perverse, it is sometimes useful. for ts use lagts (see chapter 3)

EXAMPLE


1) y = lag([1:8]',2)

2) x1=ones(7,1);x2=[1:7]';y = lag([x1 x2],1,4)

 

Example 1 gives the column matrix: 

!   0. !

!   0. !

!   1. !

!   2. !

!   3. !

!   4. !

!   5. !

!   6. !

 

Example 2 gives the (7,2) matrix: 

!   4.    4. !

!   1.    1. !

!   1.    2. !

!   1.    3. !

!   1.    4. !

!   1.    5. !

!   1.    6. !



               

AUTHOR

Eric Dubois 2002