XLAG = lagmatrix(X,Lags) creates
a lagged (shifted) version of a time series matrix. The lagmatrix function
is useful for creating a regression matrix of explanatory variables
for fitting the conditional mean of a return series.

Input Arguments

X

Time series of explanatory data. X can
be a column vector or a matrix. As a column vector, X represents
a univariate time series whose first element contains the oldest observation
and whose last element contains the most recent observation. As a
matrix, X represents a multivariate time series
whose rows correspond to time indices. The first row contains the
oldest observations and the last row contains the most recent observations. lagmatrix assumes
that observations across any given row occur at the same time. Each
column is an individual time series.

Lags

Vector of integer lags. lagmatrix applies
the first lag to every series in X, then applies
the second lag to every series in X, and so forth.
To include a time series as is, include a 0 lag.
Positive lags correspond to delays, and shift a series back in time.
Negative lags correspond to leads, and shift a series forward in time.

Output Arguments

XLAG

Lagged transform of the time series X.
To create XLAG, lagmatrix shifts
each time series in X by the first lag, then shifts
each time series in X by the second lag, and so
forth. Since XLAG represents an explanatory regression
matrix, each column is an individual time series. XLAG has
the same number of rows as there are observations in X.
Its column dimension is equal to the product of the number of columns
in X and the length of Lags. lagmatrix uses
a NaN (Not-a-Number) to indicate an undefined observation.