Skip to contents

Given a PCARMA model, create a function for computing autocovariances or coefficients of the corresponding infinite moving average representation or prepare the linear system whose solution provides the first few autocovariances of the model.

Usage

pcarma_acvf_lazy(phi, theta, sigma2, p, q, period, maxlag = 100)
pcarma_h_lazy(phi, theta, p, q, period, maxlag = 200)
pcarma_acvf_system(phi, theta, sigma2, p, q, period)
pcarma_param_system(acf, h, sigma2, p, q, period)
pcarma_h(h, na = NA)

Arguments

phi

the autoregression parameters, an object of class "slMatrix"

theta

the moving average parameters, an object of class "slMatrix"

sigma2

the innovation variances, an object of class "PeriodicVector" or a vector of size period, Details.

p

the (maximal) autoregression order or the autoregression orders.

q

the (maximal) moving average order or the moving average orders.

period

number of seasons in an epoch

maxlag

maximal lag for which the result is stored internally.

acf

the autocovariance function, an object of class pcAcvf, slMatrix, or similar

h

pcarma_param_system, h(t,k) is expected to return the coefficient \(h_{t,k}\). h is usually created by pcarma_h_lazy. For pcarma_h, a matrix of h(t,i) coefficients.

na

not used currently, controls what to do for large lags.

Details

Compute acvf from parameters

pcarma_acvf_lazy creates a function that will compute (on demand) values of the acf by a recursive formula. Computed values are stored internally for lags up to maxlag.

System for acvf from parameters

pcarma_acvf_system forms a linear system for the calculation of autocovariances from the parameters of a pc-arma model. The argument theta is not used if \(q=0\) and phi is not used if \(p=0\).

System for parameters from acvf

pcarma_param_system takes the periodic autocovariances of a pc-arma model and computes a matrix and a vector representing the linear system whose solution provides the parameters of the model.

Scalar p specifies the same autoregression order for each season, similarly for q. p and q may be vectors of length period specifying the order for each season individually. In the latter case the solution of the system may not be a proper model or, if it is, its autocovariances may not be the ones used here! See the references for details.

The class of acf is not required to be one of those explicitly listed above, but it should understand their indexing conventions, similarly for sigma2.

For pure autoregression, \(q=0\), the arguments h and sigma2 are ignored. TODO: add sigma2 (if supplied) to the returned list?

Compute h from parameters

pcarma_h_lazy: h(t,i) are the coefficients in infinite the moving average representation of the pc.arma model. The calculations use formula (4.4) from my paper (or elsewhere) with internal storage (in an slMatrix) of calculated results (for i<maxlag) and recursive calls to itself. So, it is not necessary to compute h(t,i) in any particular order.

Infinite MA coefficients(h)

pcarma_h Function to create a function for lazy computation of h(t,i) in pc.arma models

Takes a matrix of h(t,i) coefficeints and returns a function that calculates h(t,i) from my paper xxx. The returned value can be used in the same way as that of pcarma_h_lazy.

Value

for pcarma_acvf_lazy

a function taking two arguments t and k such that for scalar t and k the call f(t,k) will return EX(t)X(t-k). If either of the arguments is a vector, then f(t,k) returns a matrix of size (length(t),length(k)) containing the respective autocovariances.

for pcarma_h_lazy

a function, say h. In calls to h, if both arguments are scalars h(t,i) returns $h_t,i$. If at least one of the arguments is a vector a matrix of values of $h$ is returned.

for pcarma_acvf_system

a list with two components representing the linear system:

A

The \((p+1)\mbox{period}\times(p+1)\mbox{period}\) matrix of the system, an object of class "matrix".

b

The right-hand side of the system, a vector of length \((p+1)\mbox{period}\), an object of class "vector".

\(A^{-1}b\) can be used to get a vector of the autocovariances in the following order (d is the period, p is the maximal AR order): $$K(1,0),...,K(d,0), K(1,1),...,K(d,1),...,K(1,p),...,K(d,p).$$

for pcarma_param_system

A list with components representing the linear system and the AR and MA orders:

A

The matrix of the system

b

The right-hand side of the system

p

The AR order

q

The MA order

\(A^{-1}b\) will return a vector of the parameters of the pc-arma model: all parameters for the first season, followed by all parameters for the second seasons and so on. For each season the parameters are in the following order (s is the current season, d is the period, \(p[s]\) and \(q[s]\) are the corresponding AR and MA orders): $$ \sigma^2(s), \phi(s,1),...,\phi(s,p[s]),\theta(s,1),...,\theta(s,q[s]). $$

for pcarma_h

a function, say h. In calls to h, if both arguments are scalars h(t,i) returns $h_t,i$. If at least one of the arguments is a vector a matrix of values of $h$ is returned. Analogous to pcarma_h_lazy.

References

Boshnakov GN (1996). “Recursive computation of the parameters of periodic autoregressive moving-average processes.” J. Time Ser. Anal., 17(4), 333--349. ISSN 0143-9782, doi: 10.1111/j.1467-9892.1996.tb00281.x .

Author

Georgi N. Boshnakov

Note

for pcarma_acvf_lazy: The recursion may become extremely slow for lags greater than maxlag. If large lags are likely to be needed the argument maxlag should be used to increase the internal storage. The default for maxlag currently is 100.

See also

pcarma_h, pcarma_param_system

Examples

## periodic acf of Lambert-Lacroix
data(ex1f)
(pc3 <- slMatrix(period = 2, maxlag = 5, f = ex1f, type = "tt"))
#> An object of class "slMatrix"
#> Slot "m":
#>       lag
#> season 0    1     2     3      4      5
#>      1 1 0.81 0.729 0.729 0.6561 0.6561
#>      2 1 0.90 0.900 0.810 0.8100 0.7290
#> 
## find the parameters
s3 <- pcarma_param_system(pc3, NULL, NULL, 2, 0, 2)
coef3 <- solve(s3$A, s3$b)
pcarma_unvec(list(p = 2, q = 0, period = 2, param = coef3))
#> $p
#> [1] 2 2
#> 
#> $q
#> [1] 0 0
#> 
#> $si2
#> [1] 0.3439000 0.1049724
#> 
#> $phi
#>           [,1]      [,2]
#> [1,] 0.8100000 0.0000000
#> [2,] 0.4972376 0.4972376
#> 

## actually, the model is PAR(1,2):
s3a <- pcarma_param_system(pc3, NULL, NULL, c(1, 2), 0, 2)
coef3a <- solve(s3a$A, s3a$b)
pcarma_unvec(list(p = c(1,2), q = 0, period = 2, param = coef3a))
#> $p
#> [1] 1 2
#> 
#> $q
#> [1] 0 0
#> 
#> $si2
#> [1] 0.3439000 0.1049724
#> 
#> $phi
#>           [,1]      [,2]
#> [1,] 0.8100000 0.0000000
#> [2,] 0.4972376 0.4972376
#> 


## prepare test parameters for a PAR(2) model with period=2.
##   (rounded to 6 digits from the above example.
m1 <- rbind(c(1, 0.81, 0), c(1, 0.4972376, 0.4972376) )
m2 <- rbind(c(1, 0, 0), c(1, 0, 0) )
testphi <- slMatrix(init = m1)
testtheta <- slMatrix(init = m2)
si2 <- PeriodicVector(c(0.3439000, 0.1049724)) #     # or si2 <- c(1,1)

## acf from parameters
myf <- pcarma_acvf_lazy(testphi, testtheta, si2, 2, 0, 2, maxlag = 110)
myf(1,4)        # compute a value
#> [1] 0.6561005
a1 <- myf(1:2,0:9)    # get a matrix of values

## h from parameters
h <- pcarma_h_lazy(testphi, testtheta, 2, 2, 2)
h(3, 2)           # a scalar
#> [1] 0.4027625
h1 <- h(1:2, 1:4) # a matrix

## compute acvf from parameters
( acfsys <- pcarma_acvf_system(testphi, testtheta, si2, 2, 0, 2) )
#> $A
#>            [,1]       [,2]       [,3]       [,4] [,5]       [,6]
#> [1,]  1.0000000  0.0000000 -0.8100000  0.0000000    0  0.0000000
#> [2,]  0.0000000  1.0000000  0.0000000 -0.4972376    0 -0.4972376
#> [3,]  0.0000000 -0.8100000  1.0000000  0.0000000    0  0.0000000
#> [4,] -0.4972376  0.0000000 -0.4972376  1.0000000    0  0.0000000
#> [5,]  0.0000000  0.0000000  0.0000000 -0.8100000    1  0.0000000
#> [6,]  0.0000000 -0.4972376 -0.4972376  0.0000000    0  1.0000000
#> 
#> $b
#> [1] 0.3439000 0.1049724 0.0000000 0.0000000 0.0000000 0.0000000
#> 
acfvec <- solve(acfsys$A, acfsys$b)
acf1 <- slMatrix(acfvec, period = 2)

## TODO: examples wirh q != 0