1
2# Rmetrics is free software; you can redistribute it and/or
3# modify it under the terms of the GNU Library General Public
4# License as published by the Free Software Foundation; either
5# version 2 of the License, or (at your option) any later version.
6#
7# Rmetrics is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU Library General Public License for more details.
11#
12# You should have received a copy of the GNU Library General
13# Public License along with this library; if not, write to the
14# Free Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15# MA  02111-1307  USA
16
17
18################################################################################
19
20
21test.lag <-
22function()
23{
24    # RUnit Test:
25
26    tS = round(dummySeries(flormat = "counts"), 3)[, 1]
27    tS
28    lag(tS)
29    lag(tS, k = -2:2)
30    lag(tS, k = -2:2, trim = TRUE)
31
32    tS = round(dummySeries(), 3)[, 1]
33    tS
34    lag(tS)
35    lag(tS, k = -2:2)
36    lag(tS, k = -2:2, trim = TRUE)
37
38
39    # check colnames when using multiple lag indexes.
40    data <- matrix(runif(12), ncol = 2)
41    charvec <- rev(paste("2009-0", 1:6, "-01", sep = ""))
42    S <- timeSeries(data, charvec)
43    colnames(S) <- paste("S", 1:2, sep = ".")
44    ts <- lag(S, -1:1)
45    checkIdentical(colnames(ts), c("S.1[-1]", "S.1[0]", "S.1[1]", "S.2[-1]",
46                                   "S.2[0]", "S.2[1]"))
47
48}
49
50
51
52################################################################################
53
54