Hi, > -----Original Message----- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Joseph Magagnoli > Sent: Thursday, April 02, 2009 5:36 PM > To: r-help@r-project.org > Subject: [R] [R} seasonal differencing > > Hi all, > I was wondering how to construct a seasonal differenced time series > variable. > I used the following code to construct a 12 span seasonal difference > > seasonal<-diff(V2, lag=12, differences=1) > > is this correct? > > thank you in advance > joe >
I think this is fine. Just playing around (see below), I obtained what I would expect. :-) > V2 <- rep(x=1:12, times=5) > seasonal <- diff(V2, lag=12, differences=1) > V2 [1] 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 1 [26] 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 1 2 [51] 3 4 5 6 7 8 9 10 11 12 > seasonal [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [39] 0 0 0 0 0 0 0 0 0 0 > Hope this helps, Roland ---------- This mail has been sent through the MPI for Demographic Research. Should you receive a mail that is apparently from a MPI user without this text displayed, then the address has most likely been faked. If you are uncertain about the validity of this message, please check the mail header or ask your system administrator for assistance. ______________________________________________ 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.