acgf2poly: Change of Variable in the AutoCovariance Generating Function

Description Usage Arguments Details Value Note See Also Examples

View source: R/acgf2poly.R

Description

Change of variable in the autocovariance generating function (ACGF). This transformation allows the pseudo-spectrum to be represented as a polynomial liable to be decomposed in partial fractions.

Usage

1
2
3
4
5
acgf2poly(x)
poly2acgf(x, type=c("roots2poly", "acov2ma"), tol = 1e-16, maxiter = 100, 
  init.tol=1e-05, init.maxiter=100)
## S3 method for class 'tsdecMAroots'
print(x, units = c("radians", "degrees", "pi"), digits = 4, echo = TRUE, ...)

Arguments

x

numeric vector of autocovariances; for poly2acgf, an object of class tsdecMAroots returned by type="roots2poly"

type

character string selecting the method to undo the transformation.

tol

convergence tolerance to be used by acov2ma.

maxiter

maximum number of iterations allowed in acov2ma.

init.tol

convergence tolerance to be used by acov2ma.init.

init.maxiter

maximum number of iterations allowed in acov2ma.init.

units

character, the units in which the argument of the roots are printed. units="pi" prints the argument in radians as multiples of pi.

digits

numeric, the number of significant digits to be used by print.

echo

logical, if TRUE the output is printed, otherwise a invisible copy of the matrix summarizing the results obtained by poly2acgf is returned.

...

further arguments to be passed to print.

Details

The ACGF is defined as a power series where the coefficients are the autocovariances g[i]:

g(z) = g[0] + g[1](z+z^(-1)) + g[2](z^2+z^(-2)) + g[3](z^3+z^(-3)) + ...

where z is a complex variable.

Replacing z by e^(-i*w) with 0 <= w <= 2*pi yields the spectral density multiplied by 2*pi. This gives a power series in the variable 2*cos(w*j) (note that for z=e^(-i*w), which has unit modulus, the inverse 1/z is the complex-conjugate of z):

z^j + z^(-j) = cos(w*j) + i*sin(w*j) + cos(w*j) - i*sin(w*j) = 2*cos(w*j).

acgf2poly transforms the following expression in the variable 2*cos(w*j):

A(2*cos(j*w)) = a[0] + a[1] * 2*cos(w) + a[2] 2*cos(2*w) + ... + a[n] 2*cos(n*w)

into a polynomial in the variable x=2*cos(w):

B(x) = b[0] + b[1]*x + b[2]*x^2 + ... + b[n] x^n.

poly2acgf recovers the vector of autocovariances by undoing the above transformation and computes the coefficients and the variance of the innovations of the moving average model related to those autocovariances. Two methods can be employed. 1) type="acov2ma": this method recovers the autocovariances by undoing the change of variable; then, the the autocovariances are converted to the coefficients of a moving average by means of acov2ma. In the presence of non-invertible roots, this method may experience difficulties to converge. 2) type="roots2poly": this method does not explicitly undo the change of variable acgf2poly (i.e., the vector of autocovariances is not recovered). Instead, the roots of the moving average polynomial theta(L) are obtained from the polynomial theta(L)*theta(L^(-1)), where the coefficients are in terms of the polynomial B(x) defined above; then, the coefficients of the moving average model are computed by means of roots2poly.

Value

acgf2poly returns the transformed vector of coefficients.

poly2acgf returns an object of class tsdecMAroots containing the coefficients and the variance of the innovations in the moving average model related to the autocovariances underlying the transformed coefficients. print.tsdecMAroots prints a summary of the results computed by poly2acgf.

Note

Method type="roots2poly" in poly2acgf is based on algorithm pu2ma in the software SSMMATLAB by G<c3><b3>mez, V. URL http://www.sepg.pap.minhap.gob.es/sitios/sepg/en-GB/Presupuestos/Documentacion/Paginas/SSMMATLAB.aspx.

See Also

acov2ma, roots2poly.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# the matrix 'm' performs the mapping from the original 
# to the transformed coefficients
n <- 30
m <- diag(1, n, n)
n2 <- n - 2
j <- -1
tmp <- seq.int(2, n-1)
for (i in seq.int(3, n-2, 2))
{
  id <- cbind(seq_len(n2),seq.int(i,n))
  m[id] <- j * tmp
  n2 <- n2 - 2
  j <- -1 * j
  tmp <- cumsum(tmp[seq_len(n2)])
}
if (2*floor(n/2) == n) {  # if (n %% 2 == 0)
  m[cbind(seq_len(n2),seq.int(n-1,n))] <- j * tmp 
} else 
  m[1,n] <- j * tmp
m[1:10,1:10]

# equivalence of the original and transformed coefficients,
# example with an ARMA(2,1) model
#
# method 1: compute the spectral density upon the 
# the theoretical autocovariances ('gamma') of the ARMA model
gamma <- ARMAacov(ar=c(0.8,-0.6), ma=0.4, lag.max=n-1)
w <- seq(0, pi, len=length(gamma))
spec1 <- rep(gamma[1], length(w))
for (i in seq_along(w))
{
  z <- 2*cos(w[i] * seq_len(length(gamma)-1))
  spec1[i] <- spec1[i] + sum(gamma[seq.int(2, n)] * z)
}
spec1 <- spec1/(2*pi)
#plot(w, spec1)

# method 2: compute the spectral density upon the 
# transformed coefficients
newcoefs <- m 
spec2 <- rep(newcoefs[1], length(w))
for (i in seq_along(w))
{
  x <- (2*cos(w[i]))^seq_len(n-1)
  spec2[i] <- spec2[i] + sum(newcoefs[seq.int(2, n)] * x)
}
spec2 <- spec2/(2*pi)

# both representations are equivalent
all.equal(spec1, spec2, check.names=FALSE)
#[1] TRUE

# the original coefficients (the autocovariances) 
# can be recovered premultiplying by the inverse of the 
# transformation matrix 'm'
all.equal(c(solve(m) %*% newcoefs), gamma, check.names=FALSE)
#[1] TRUE

tsdecomp documentation built on May 1, 2019, 9:15 p.m.