lagmatrix | R Documentation |
Create an array with lead/lags of an input variable.
lagmatrix(x, lag)
x |
input variable. |
lag |
vector of leads and lags. Positive numbers are lags, negative are leads. O is the original |
An array with the resulting leads and lags (columns).
This code was copied from the ts.utils
package to avoid the archive
operations of the smooth
package in 16-02-2025. This function might be deprecated
in future releases to use the one from ts.utils
again.
Nikolaos Kourentzes, nikolaos@kourentzes.com
x <- rnorm(10)
lagmatrix(x,c(0,1,-1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.