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 |
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 |
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 |
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
:
-
calc.method
= 'from.det.cross'. (See Ioannidis (2007), Proposition 2). One must first specify the roots fordet(z)
andcross(z)
. They fix these two polynomials, which will not be modified during the calculation. One may also specify some roots forchi.1(z)
andchi.2(z)
. If these two latter are compatible with EQ(*) they will be kept. If not, they may be modified during the calculation. Further roots may be added bycompute.VAR
during the calculation tochi.2
to ensure that EQ(*) holds. All changes are recorded in attributeinv.roots
. If the user wishes some of the roots ofchi.2
to be rather added tochi.1
, he may do so by editing attributeinv.roots
after running the function once, by increasing the multiplicity of the root forchi.1
and decreasing it by the same amount forchi.2
, and then, re-running the function. With the optioncalc.method
= 'from.det.cross' one has more direct control over peaks for the marginal spectra (viachi.i
anddet
) and the Coherency being close to 0 or 1 (viadet
andcross
), as well as the Phase spectrum, i.e., the lag-/lead- structure between the two series (viacross
). -
calc.method
= 'from.eta.ksi.zeta'. (See Ioannidis (2007), Proposition 1). One must specify the roots ofeta.1, eta.2, ksi.1, ksi.2
andzeta
. These fixchi.i(z) = M* eta.i(z) zeta(z) ksi.j(z)/ksi.c(z))
and
det(z)=M *zeta(z) ksi.1(z) ksi.2(z)/ksi.c(z),
where
M
equalsM.fact
*min (|ksi.c(z) /[eta.1(z) eta.2(z) zeta(z)]|^2 )
andksi.c
is the maximal common divisor ofksi.1(z)
andksi.2(z)
. Then,cross(z)
is automatically determined so as that EQ(*) is satisfied. The result is that marginal spectra are given byf.i (w) = |eta.i(z)|^2 /|ksi.i(z)|^2
and the squared Coherency is given by
1-|ksi.c(z)|^2 /|M* eta.1(z) eta.2(z) zeta(z)|^2.
With the option
calc.method
= 'from.eta.ksi.zeta' one has more direct control over peaks (viaksi
) and zeroes (viaeta
) of the marginal spectra and, partially, over the Coherency (viaksi.c, eta
andzeta
), but not of the Phase spectrum. However, for certain aspects of the Coherency, a more direct control over the relation ofcross
anddet
would be required, which is not available with this option. For example, with this option, it is not possible to set the multiplicity of a root to be higher forcross
than fordet
.
Value
An object of class var, basically a list including elements:
grid |
The number of equidistant gridpoints in |
p.max.init |
An initial limitation on the order of the VAR model. |
inv.roots |
A |
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 |
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 |
order |
(Integer) The final order of the VAR model. |
ar.list |
A list with entries (calculated solving the Yule-Walker equations):
|
cov.1 , cov.2 , cov.cross , cov.cross.neg |
Three one dimensional arrays of length |
freq |
A one dimensional array of length |
spec |
A three dimensional array ( |
spec.1 , spec.2 |
Two one dimensional arrays of length |
Coher |
A one dimensional array of length |
Phase |
A one dimensional array of length |
Phase.div.freq , group.delay |
Two one dimensional arrays of length |
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
|
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
a peak in
f.1(w_0)
with
method
='from.det.cross': choose[det(z_0)] > [chi.1(z_0)]
.with
method
='from.eta.ksi.zeta': choose[ksi.1(z_0)] > [eta.1(z_0)]
.
a trough in
f.1(w_0)
with
method
='from.eta.ksi.zeta': choose[ksi.1(z_0)] < [eta.1(z_0)]
.
a
Coh(w_0)
close to 1with
method
='from.det.cross': choose[det(z_0)] > [cross(z_0)]
.with
method
='from.eta.ksi.zeta': choosemin([ksi.1(z_0)],[ksi.2(z_0)]) > [eta.1(z_0)]+[eta.2(z_0)]+[zeta(z_0)]
.
a
Coh(w_0)
close to 0with
method
='from.det.cross': choose[det(z_0)] < [cross(z_0)]
.with
method
='from.eta.ksi.zeta': choosemin([ksi.1(z_0)],[ksi.2(z_0)]) < [eta.1(z_0)]+[eta.2(z_0)]+[zeta(z_0)]
.
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
,
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)