Learn R Programming

nnfor (version 0.9.2)

lagmatrix: Create matrix with lead/lags of an input vector.

Description

Create matrix with lead/lags of an input vector.

Usage

lagmatrix(x, lag)

Arguments

x

Input variable.

lag

Vector of leads and lags. Positive numbers are lags, negative are leads. O is the original x.

Value

lmat - Resulting matrix.

Examples

Run this code
# NOT RUN {
  x <- rnorm(10)
  lagmatrix(x,c(0,1,-1))
# }

Run the code above in your browser using DataLab