makeLagMatrix

makeLagMatrix Create lag matrix from input data.

lagMatrix = makeLagMatrix(Y, p) returns a matrix where columns contain 1 to p lags of Y.

Arguments

  • Y (matrix): Input data matrix (T x k).
  • p (integer): Number of lags.

Returns

  • lagMatrix (matrix): Matrix of lagged values. First k columns are lag 1, next k are lag 2, and so on.

Notes

  • Missing values due to lagging are filled with NaN.