[R] lag function doesn't work - what am i doing wrong?
Scotty Nelson
poorboy44 at hotmail.com
Fri Oct 10 19:27:07 CEST 2008
I am trying to lag a time series. My data is in a matrix, but I coerce it
into a ts object.
But when I lag it and then look at the result, nothing has changed. What am
I doing wrong?????
residsq<-resid^2
residsq<-as.ts(residsq)
lag1residsq<-lag(residsq,-1)
> residsq[1:5]
1 2 3 4 5
87.759 329882.188 5325849.333 31512.334 70865.228
> lag1residsq[1:5]
1 2 3 4 5
87.759 329882.188 5325849.333 31512.334 70865.228
>
PS: I tried to lag the series manually using rbind(0, residsq), but the
result ended up returning me [ 0, residsq(1), 0, residsq(2), 0, ....]
WTF!!!! how do you stack 1 element onto another in R?
--
View this message in context: http://www.nabble.com/lag-function-doesn%27t-work---what-am-i-doing-wrong--tp19922651p19922651.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list