Skip to contents

slMatrix is a matrix-like object for storing values of periodic autocovariance functions, i.e. of functions of two arguments which are periodic in the first argument, r[t,k]=r[t+d,k]. The first argument has the meaning of "time" or "season" (when taken modulo the period), the second is "lag". This class provides various access and assignment methods for such objects. slMatrix was created as the storage for values of periodic autocovariance functions and is used for other related quantities.

Objects from the Class

Objects can be created by calls of the form new("slMatrix", m), where m is a matrix with m[i,k] giving the values for season i and lag (k-1), \(k=1,2,\dots\). The number of rows in m is taken to be the number of seasons. The function slMatrix provides several ways to specify the data for the slMatrix object.

Slots

m:

Object of class "matrix".

Methods

[<-

signature(x = "slMatrix", i = "ANY", j = "ANY", value = "ANY"): ...

[

signature(x = "slMatrix", i = "ANY", j = "ANY", drop = "ANY"):

The indexing method is quite flexible and allows to extract parts of slMatrix objects in a variety of ways. It returns an ordinary matrix or, if drop = TRUE, vector.

The syntax for indexing is similar to that for ordinary matrices with some features specific to the periodic nature of the first index. The named parameters are i, j, and type. Both i and j can be vectors. The interpretation of i and j depends on type.

x[i,j] (or x[i,j,type="sl"]) refers to the value for season i and lag j. This is referred to as standard season-lag pair, meaning that the elements of i must be in the range 1,...,d, where d is the number of seasons and the lags must be non-negative. Negative indices have the usual effect of removing the corresponding elements. A zero element for lag is admissible.

x[i,j,type="tl"] is similar to "sl" but i is allowed to take any (integer) values. These are reduced modulo the number of seasons to the 1,...,d, range.

x[i,j,type="tl+-"] This allows also the lags to be negative.

x[i,j,type="co"] ("co" stands for "coefficient") This assumes that the values for negative lags and lags larger than maxlag are 0. If assignment is attempted for such lags, a message is issued and the assignment is ignored.

x[i,j,type="tt"] both arguments have the meaning of time. If i and j are scalars the pair i,j is converted to standard s,l pair and the value assigned to the relevant element. If i and/or j are vectors, they are crossed and the procedure is done for each pair.

If several values need to be assigned to the same s,l pair a warning is isssued if these values are not all equal.

Obviously, whereever negative arguments are allowed, elements to omit cannot be specified with negative indices.

see [-methods.

maxLag

signature(x = "slMatrix"): maximum lag available for storage.

Author

Georgi N. Boshnakov

Note

The current implementation of the indexing is inefficient, I simply added features and patches as the need arose. Maybe some day I will replace it with C code.

See also

Examples

m1 <- rbind(c(1, 0.81, 0), c(1, 0.4972376, 0.4972376))
x <- slMatrix(m1)
x[1, 0]
#> [1] 1
x[1:2, 0:1]
#>       lag
#> season 0         1
#>      1 1 0.8100000
#>      2 1 0.4972376
x[1:3, 1:3, type = "tt"]
#>           [,1]      [,2] [,3]
#> [1,] 1.0000000 0.4972376 0.00
#> [2,] 0.4972376 1.0000000 0.81
#> [3,] 0.0000000 0.8100000 1.00