Give the maximal lag in an object
maxLag.Rd
Give the maximal lag in an object, such as autocorrelations.
Details
maxLag
is a generic function to get the maximal lag for which
information is available in lagged objects.
Methods
signature(object = "Lagged")
This method applies to all classes inheriting from
"Lagged"
.signature(object = "array")
signature(object = "matrix")
signature(object = "vector")
signature(object = "ANY")
signature(object = "slMatrix")
Examples
## 1d
v <- Lagged(2^(0:6))
v
#> An object of class "Lagged1d"
#> Slot *data*:
#> Lag_0 Lag_1 Lag_2 Lag_3 Lag_4 Lag_5 Lag_6
#> 1 2 4 8 16 32 64
maxLag(v)
#> [1] 6
v[c(2,4,6)]
#> [1] 4 16 64
v[8] # NA
#> [1] NA
## reduce the number of lags in place
maxLag(v) <- 4
v
#> An object of class "Lagged1d"
#> Slot *data*:
#> Lag_0 Lag_1 Lag_2 Lag_3 Lag_4
#> 1 2 4 8 16
## extend the object (with NA's)
maxLag(v) <- 6
v
#> An object of class "Lagged1d"
#> Slot *data*:
#> Lag_0 Lag_1 Lag_2 Lag_3 Lag_4 Lag_5 Lag_6
#> 1 2 4 8 16 NA NA
## extend using "["
v[5:8] <- 2^(5:8)
v
#> An object of class "Lagged1d"
#> Slot *data*:
#> Lag_0 Lag_1 Lag_2 Lag_3 Lag_4 Lag_5 Lag_6 Lag_7 Lag_8
#> 1 2 4 8 16 32 64 128 256
## 2d
m <- Lagged(matrix(1:12, nrow = 4))
m
#> An object of class "Lagged2d"
#> Slot *data*:
#> Lag_0 Lag_1 Lag_2
#> 1 5 9
#> 2 6 10
#> 3 7 11
#> 4 8 12
maxLag(m)
#> [1] 2
maxLag(m) <- 1
m
#> An object of class "Lagged2d"
#> Slot *data*:
#> Lag_0 Lag_1
#> 1 5
#> 2 6
#> 3 7
#> 4 8
## maxLag(m) <- 4 # extending this way doesn't work currently