shift {regr} | R Documentation |
Shifts a vector by introducing NA's at the beginning and dropping elements at the end or vice versa. Analogous for rows of matrices and data.frames
shift(x, k = 1)
x |
vector or matrix to be shifted |
k |
number of elements or rows to be dropped in the end (if
|
shifted vector or matrix
This function helps to regress a target variable on lagged (=shifted) versions of itself (autocorrelation) and/or explanatory variables (time series regression)
Werner A. Stahel
lag
for ts
objects
shift(1:5,k=2) shift(c("a","b","c"),-1) ## need an example for time series regression!!!