Command Reference : Function Reference : Function Reference: L
  
 
@lag
n-th order lag function.
Syntax: @lag(x, n)
x: series, alpha, vector, svector, matrix object
n: series, alpha, vector, svector, matrix object
Return: series
Returns n-th order lag of the series, alpha, vector, svector, or columns of a matrix x. If n is not an integer, the integer floor will be used.
For a matrix x, the function will return a matrix of the same size with rows shifted down (or up if n is negative) n places. Unavailable rows will be filled with NAs.
This function is panel aware.
Examples
series y = 0
smpl @first+1 @last
y = @lag(y, 1) + @nrnd
smpl @all
The series y is a random walk process that starts at 0.
matrix(5,4) A
rnd(A)
matrix B = @lag(A,2)
Matrix A will be a matrix containing random uniform draws. Matrix B will have two rows of NAs, followed by the first three rows of A.
Cross-references
See also d.