calculate.VAR {VAR.spec}R Documentation

Attempts to define a bivariate VAR (Vector autoregression) model.

Description

Attempts to find a VAR model which is compatible with the polynomials specified in its attribute inv.roots, makes necessary adjustments, calculates its spectra, coefficients and order, makes the necessary checks and plots the spectra. Finding a VAR model involves finding complex polynomials det(z), cross(z), chi.1(z) and chi.2(z), satisfying EQ(*):

|det(z)|^2+|cross(z)|^2 = |chi.1(z)|^2 |chi.2(z)|^2

on z|=1. If calculate.VAR is successful in finding such polynomials, there exists a bivariate VAR(p) model with marginal spectra

f.i (w) = (1/2\pi)* |chi.i(z)|^2 /|det(z)|^2,

and cross-spectrum

f.1.2 (w) = (1/2\pi)* z^{(-p)}*cross(z) /|det(z)|^2,

where z=exp(-iw). The squared Coherency is then given by

|cross(z)|^2 /(|det(z)|^2+|cross(z)|^2).

Usage

calculate.VAR(a.var, calc.method = "from.det.cross", M.fact = 1.1, 
              plot.spectra = TRUE,suppr.spec.check.warn=FALSE)

Arguments

a.var

An object of class var, previously initialized by Init.var.

calc.method

One of 'from.det.cross' or 'from.eta.ksi.zeta'. See details for further explanations.

M.fact

Numeric. A factor >1, by which the min (|ksi.c(z) /[eta.1(z)eta.2(z)zeta(z)]|^2 ) is multiplied, in order to ensure that |chi.1(z)*chi.2(z)|^2 - |det(z)|^2 is positive on |z|=1. Only relevant when calc.method = 'from.eta.ksi.zeta'. Affects the range of values of the Coherency spectrum.

plot.spectra

Logical. If TRUE, the marginal spectra, Coherency and Phase spectra will be plotted.

suppr.spec.check.warn

Logical. If TRUE, warnings on whether spectra obtained directly from cross, det, chi.1 and chi.2 (in spec.1, spec.2, Coher, Phase) differ by more than eps.for.spectra from the spectra (in spec) obtained from the coefficients of the VAR model (see Note, below) are suppressed.

Details

In order to define a VAR model, one seeks to define det(z), cross(z) and chi.1(z), chi.2(z), such that EQ(*) holds. There are two ways implemented for doing so, which are specified by argument calc.method:

Value

An object of class var, basically a list including elements:

grid

The number of equidistant gridpoints in [0,\pi], used for plotting and numerical approximations.

p.max.init

An initial limitation on the order of the VAR model.

inv.roots

A data.frame containing the roots of certain polynomials, used to specify the VAR model.

niter

An integer specifying the maximal number of iterations for the Innovations algorithm.

eps.max.for.UIA

Numeric close to 0. Specifies the threshold for the relative increase in precision achieved at a step of the Innovations algorithm, for accepting that the algorithm has converged.

eps.for.roots

Numeric close to 0. A threshold for considering two roots as identical, if a) the inverses of their radii and b) their angles (in their polar representation) differ by less than this threshold.

eps.for.spectra

Numeric close to 0. A threshold for checking the validity of the calculation of the VAR model. It's spectra are calculated on the basis of the polynomials used to specify the VAR model in inv.roots.def should coincide with the spectra calculated on the basis of the VAR model's coefficients. If they differ by more than a.eps.for.spectra warning messages will be written out to the console.

validity.msg

A message containing more precise information on a) the convergence of the Innovations Algorithm and b) on the maximal difference between the spectra of the VAR model as calculated on the basis of the polynomials used to specify it and the spectra obtained on the basis of the VAR model's coefficients. The message should be printed after each call to calculate.var.

order

(Integer) The final order of the VAR model.

ar.list

A list with entries (calculated solving the Yule-Walker equations):

  • order (Integer) The final order of the VAR model.

  • ar A three dimensional array (orderx2x2), containing the coefficients of the VAR model.

  • var.pred A 2x2 matrix containing the covariance matrix of the innovations.

cov.1, cov.2, cov.cross, cov.cross.neg

Three one dimensional arrays of length order+1 containing the auto- and the cross- covariances (for lags and leads respectively) of the two series for lags=0,...,order. They are being calculated as Dirichlet-approximations to the Fourier transforms of the spectra, which have been calculated from det, cross, chi.1 and chi.2.

freq

A one dimensional array of length grid. It contains the grid-points at which spectra are being calculated.

spec

A three dimensional array (gridx2x2). Contains for each grid-point the spectral matrix, as calculated at the basis of the VAR model's coefficients, given in attribute ar.list. That is, spec[j,1,1] is the spectrum of series 1 at grid-point j, spec[j,1,2] is the cross-spectrum between the series 1 and 2 at grid-point j, etc.

spec.1, spec.2

Two one dimensional arrays of length grid containing the log of the values of the spectra of series 1 and 2, respectively, as calculated from chi, det, i.e. \code{spec.1}[j]=log[(1/2\pi) |chi.i(z)|^2 /|det(z)|^2], where z=exp(-ij\pi/(\code{grid}-1)).

Coher

A one dimensional array of length grid containing the values of the log of the squared Coherency spectrum between series 1 and 2, as calculated from cross, det, i.e. \code{Coher}[j] = log(|cross(z)|^2 /(|det(z)|^2+|cross(z)|^2]), z=exp(-ij\pi/(\code{grid}-1)).

Phase

A one dimensional array of length grid containing the values of the Phase spectrum between series 1 and 2, as calculated from cross, i.e., \code{Phase} (w) = arg[ z^{(-p)}*cross(z)] , where z=exp(-ij\pi/(\code{grid}-1)).

Phase.div.freq, group.delay

Two one dimensional arrays of length grid containing the values of Phase(w)/w, which gives the lead/lag in units of time, and the derivative of Phase(w) with respect to w, respectively.

det, cross, chi.1, chi.2, ksi.1, ksi.2, eta.1, eta.2, zeta

Contain detailed information on the respective polynomials (the last five only if calc.method = 'from.eta.ksi.zeta' was used), as modified during the calculation, each one with attributes:

  • const the constant of the polynomial;

  • inv.roots the modulus and angle for the inverses of the roots of the polynomial (for conjugate pairs only the one with angle in [0,\pi]);

  • inv.roots.number, the number of the roots of the polynomial (pairs of complex roots are counted only once);

  • order, the degree of the polynomial;

  • coefs, an array of length 2( \code{inv.roots.number} +1) containing the coefficients of the polynomial;

  • fourier.coefs, an array of length 2\code{pmax.init}+1 containing the Fourier transform of the |polynomial(z)|^2 on |z|=1;

  • values$spec, an array of length grid, containing the values of the squared modulus of the polynomial, i.e. |polynomial(z)|^2 on |z|=1;

  • Inv.values$spec, an array of length grid, containing the log of the inverses of the values of the squared modulus of the polynomial, i.e. -log [ |polynomial(z)|^2 ] on |z|=1.

Note

calculate.VAR performs a check on the validity of the output and stores relevant information in attribute validity.msg. There are certain reasons for which the output may not be valid: First, the calculation involves numerical approximations; the relevant algorithms may have not achieved convergence to the desired precision. Second, there may be features in the spectra, which cannot be well represented by a VAR model, resulting in polynomials cross, det, chi.1 and chi.2 not satisfying EQ(*). Thus, it is imperative to check a) the validity of EQ(*). It is also important to check b) that the spectra obtained directly from cross, det, chi.1 and chi.2 (in spec.1, spec.2, Coher, Phase) coincide with the spectra (in spec) obtained from the coefficients of the VAR model (in ar.list). The checks performed by calculate.VAR concern exactly the checks under a) and b): the maximum absolute difference between the relevant quantities (in log scale, where appropriate) is passed in validity.msg. Moreover, warnings are written out to the console if the Innovations algorithm did not converge or if any of the quantities in 'b' exceeds eps.for.spectra, provided that suppr.spec.check.warn=FALSE. The same check is conducted visually if plot.spectra=TRUE: each spectrum is calculated and plotted according to both methods. The two should coincide.

The option method='from.det.cross' seems generally numerically more stable than the option

method='from.eta.ksi.zeta'.

Suggestions on how to obtain desired spectral characteristics:

Let z_0:= r_0^{-1}exp(iw_0), with r_0 close to 1. For a polynomial p(z) denote by [p(z_0)] the multiplicity of z_0 as root of p(z).

To obtain

References

Ioannidis, E. E. (2007). Spectra of bivariate VAR(p) models. Journal of Statistical Planning and Inference 137(2), 554-566.

Ioannidis, E. E. and Chronis, G. A. (2005). Extreme spectra of VAR models and orders of near-cointegration. J. Time Ser. Anal. 26, 399-421.

See Also

VAR.spec-package,Init.var, simulate.VAR,

plot_VAR.spectra, plot_VAR.Phase.details,

calc.VAR.spec.from.coefs

Examples

my.var <- Init.var(grid=501, order.max.init=10, inv.roots.def=NULL)
my.var$inv.roots[2,]<- c(0.98,0.017261,2,3,1,1,2, rep(0,8))
my.var$inv.roots[3,]<- c(0.92,0.897598,2,1,1,1,2, rep(0,8))
my.var$inv.roots[4,]<- c(0.98,1.795196,1,1,0,1,1, rep(0,8))
my.var <- calculate.VAR (a.var = my.var, calc.method="from.det.cross", 
          plot.spectra=TRUE,suppr.spec.check.warn=TRUE)
print(my.var$validity.msg)


[Package VAR.spec version 1.0 Index]