Learn R Programming

lgarch (version 0.2)

glag: Lag vector or matrix

Description

Similar to the lag function from the stats package, but glag enables padding (e.g. NAs or 0s) of the lost entries.

Usage

glag(x, k = 1, pad = FALSE, pad.value = NA)

Arguments

x
a numeric vector
k
integer equal to the lag (the default is 1)
pad
logical. If TRUE, then the lost entries are padded with pad.value. If FALSE (default), then no padding is undertaken
pad.value
numeric. The padding-value

Value

  • A vector with the lagged values

See Also

lag

Examples

Run this code
##lag series with NA for the missing entries:
x <- rnorm(5)
xlag1 <- glag(x, pad=TRUE)

Run the code above in your browser using DataLab