Learn R Programming

lgarch (version 0.1)

glag: Lag vector

Description

Similar to the lag function from the stats package, but glag enables padding (e.g. NAs or 0s) of the lost entries. NOTE: contrary to lag the glag function can only be applied to vectors

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