I have a data set like this:
data <- ts(data.frame(a=c(104.8587, 104.5483, 104.0210, 105.7185,104.9054),
b=c(95.4, 95.9, 95.6, 95.5, 95.8)), start=c(2007,1), frequency=12)
> data
a b
Jan 2007 104.86 95.4
Feb 2007 104.55 95.9
Mar 2007 104.02 95.6
Apr 2007 105.72 95.5
May 2007 104.91 95.8
Now I want to ad the laged series of b to the data set. However, I'm struggleling, since whatever value I put in for k
, it shows the same result.
> lag(data[,2], k=3)
Jan Feb Mar Apr May
2007 NA 95.4 95.9 95.6 95.5
> lag(data[,2], k=5)
Jan Feb Mar Apr May
2007 NA 95.4 95.9 95.6 95.5
I've already read the help page, but I couldn't find a hint beside that the laged series must be a time series object, which is fulfilled. So what am I doing wrong?