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.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to