The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Type: Package
Title: Bootstrap Tests for Cointegration and Autocorrelation in VARs
Version: 2.0.7
Depends: R (≥ 3.0.2)
LinkingTo: Rcpp (≥ 0.12.10), RcppArmadillo
Imports: methods, Rcpp, sn
Suggests: vars
Description: Implements wild bootstrap tests for autocorrelation in Vector Autoregressive (VAR) models based on Ahlgren and Catani (2016) <doi:10.1007/s00362-016-0744-0>, a combined Lagrange Multiplier (LM) test for Autoregressive Conditional Heteroskedasticity (ARCH) in VAR models from Catani and Ahlgren (2016) <doi:10.1016/j.ecosta.2016.10.006>, and bootstrap-based methods for determining the cointegration rank from Cavaliere, Rahbek, and Taylor (2012) <doi:10.3982/ECTA9099> and Cavaliere, Rahbek, and Taylor (2014) <doi:10.1080/07474938.2013.825175>.
LazyData: yes
NeedsCompilation: yes
Encoding: UTF-8
License: GPL (≥ 3)
Packaged: 2025-07-23 10:26:39 UTC; Markus
Author: Markus Belfrage [aut, cre], Paul Catani [ctb], Niklas Ahlgren [ctb]
Maintainer: Markus Belfrage <markus.belfrage@gmail.com>
Repository: CRAN
Date/Publication: 2025-07-25 09:40:02 UTC

Test for Error Autocorrelation in VAR Models.

Description

Performs LM tests for error AC in VAR models. The code is based on Paul Catani's original R code used in the paper Wild Bootstrap Tests for Autocorrelation in Vector Autoregressive Models (Ahlgren and Catani, 2016).

Usage

ACtest(fit, h = 4, HCtype = c("LM", "HC0", "HC1", "HC2", "HC3"), univariate = FALSE)
## S3 method for class 'ACtest'
print(x, ...)

Arguments

fit

an object of class "VARfit" that was returned by the VARfit function, or an object of class "verest" from the function vars::VAR in the vars package.

h

the lag length of the alternative VAR(h) model for the errors.

HCtype

a vector containing some or all (default) of "LM", "HC0", "HC1", "HC2" and "HC3". The "LM" type assumes homoscedastic errors, while the "HC" types are different Heteroskedasticity-consistent tests (see 'Details').

univariate

either FALSE, TRUE, or "only". If TRUE, the test will also be performed in its univariate form, if "only", only the univariate version will be used.

x

Object with class attribute ‘ACtest’.

...

further arguments passed to or from other methods.

Details

To run the wild bootstrap version of the test, please use the output from this function with the function wildBoot.

Mathematical details

The tests for error AC are based on the least squares (LS) residuals from the K-dimensional vector autoregressive (VAR) model with p lags (abstracting from deterministic terms):

\mathbf{y}_{t}=\mathbf{\Pi }_{1}\mathbf{y}_{t-1}+\cdots +\mathbf{\Pi }_{p} \mathbf{y}_{t-p}+\mathbf{u}_{t},\quad \text{E}(\mathbf{u}_{t})=\mathbf{0} ,\quad \text{E}(\mathbf{u}_{t}\mathbf{u}_{t}^{\prime })=\mathbf{\Omega},\ \ \ \ t=1,\ldots ,N.

The LS residuals are

\widehat{\mathbf{u}}_{t}=\mathbf{y}_{t}-\widehat{\mathbf{\Pi }}_{1}\mathbf{y} _{t-1}-\cdots -\widehat{\mathbf{\Pi }}_{p}\mathbf{y}_{t-p},

where \widehat{\mathbf{\Pi }}_{1},\ldots ,\widehat{\mathbf{\Pi }}_{p} are the LS estimates of the K\times K parameter matrices \mathbf{\Pi } _{1},\ldots ,\mathbf{\Pi }_{p}.

The LM statistic is computed from the auxilary model

\widehat{\mathbf{u}}_{t}=\mathbf{\Pi }_{1}\mathbf{y} _{t-1}+\cdots +\mathbf{\Pi }_{p}\mathbf{y}_{t-p} + \mathbf{D}_{1}\widehat{\mathbf{u}}_{t-1}+\cdots +% \mathbf{D}_{h}\widehat{\mathbf{u}}_{t-h}+\mathbf{e}_{t}

=(\mathbf{Z}_{t-1}^{\prime }\otimes \mathbf{I}_{K})\boldsymbol{\phi }+(\widehat{% \mathbf{U}}_{t-1}^{\prime }\otimes \mathbf{I}_{K})\boldsymbol{\psi }+\mathbf{e}% _{t}, \

where \mathbf{Z}_{t-1}=(\mathbf{y}_{t-1}^{\prime },\ldots ,\mathbf{y}_{t-p}^{\prime })^{\prime }, \boldsymbol{\phi } =\text{vec}(\mathbf{Pi}_{1},\ldots ,\mathbf{Pi}_{p})^{\prime }, \widehat{\mathbf{U}}% _{t-1}=(\widehat{\mathbf{u}}_{t-1}^{\prime },\ldots ,\widehat{% \mathbf{u}}_{t-h}^{\prime })^{\prime } and \boldsymbol{\psi } =\text{vec}(\mathbf{D}_{1},\ldots ,\mathbf{D}_{h})^{\prime }. The symbol \otimes denotes the Kronecker product and the symbol vec denotes the column vectorisation operator. The first h values of the residuals \widehat{\mathbf{u}}_{t} are set to zero in the auxiliary model, so that the series length is equal to the series length in the original VAR model.

The LM statistic for error AC of order h is given by

Q_{\text{LM}}(h) = N \widehat{\boldsymbol{\psi}}^{\prime} \bigl(\widehat{\boldsymbol{\Sigma}}^{\psi\psi}\bigr)^{-1} \widehat{\boldsymbol{\psi}}

where \widehat{\boldsymbol{\psi }} is the LS estimate of \boldsymbol{\psi } and \widehat{\boldsymbol{\Sigma }}^{\psi \psi } is the block of

\left( N^{-1}\sum_{t=1}^{N}\left[ \begin{array}{c} \mathbf{Z}_{t-1}\otimes \mathbf{I}_{K} \\ \widehat{\mathbf{U}}_{t-1}\otimes \mathbf{I}_{K}% \end{array}% \right] \widehat{\boldsymbol{\Sigma }}_{\mathbf{u}}^{-1}\left[ \begin{array}{cc} \mathbf{Z}_{t-1}^{\prime }\otimes \mathbf{I}_{K} & \widehat{\mathbf{U}}% _{t-1}^{\prime }\otimes \mathbf{I}_{K}% \end{array}% \right] \right) ^{-1}

corresponding to \boldsymbol{\psi }. Here \widehat{\boldsymbol{\Sigma }}_{\mathbf{u}% }=N^{-1}\sum_{t=1}^{N}\widehat{\mathbf{u}}_{t}\widehat{\mathbf{u}}% _{t}^{\prime } is the estimator of the error covariance matrix from the VAR model.

The multivariate heteroskedasticity-consistent covariance matrix estimator (HCCME) for the auxilary model is given by (Hafner and Herwartz 2009)

\mathbf{V}_{N}^{-1}\mathbf{W}_{N}\mathbf{V}_{N}^{-1} = (\boldsymbol{\Gamma}_{N}\otimes \mathbf{I}_{K})^{-1} \mathbf{W}_{N} (\boldsymbol{\Gamma}_{N}\otimes \mathbf{I}_{K})^{-1}

where

\mathbf{V}_{N} =\boldsymbol{\Gamma }_{N}\otimes \mathbf{I}_{K},

\boldsymbol{\Gamma }_{N} =\frac{1}{N}\sum_{t=1}^{N}\left( \begin{array}{c} \widehat{\mathbf{U}}_{t-1} \\ \mathbf{Z}_{t-1}% \end{array}% \right) \left( \begin{array}{cc} \widehat{\mathbf{U}}_{t-1}^{\prime } & \mathbf{Z}_{t-1}^{\prime }% \end{array}% \right) ,

\mathbf{W}_{N} =\frac{1}{N}\sum_{t=1}^{N}\left( \begin{array}{c} \widehat{\mathbf{U}}_{t-1} \\ \mathbf{Z}_{t-1}% \end{array}% \right) \left( \begin{array}{cc} \widehat{\mathbf{U}}_{t-1}^{\prime } & \mathbf{Z}_{t-1}^{\prime }% \end{array}% \right) \otimes (\widehat{\mathbf{u}}_{t}\widehat{\mathbf{u}}_{t}^{\prime }).

The HCCME-based LM statistics for error AC are obtained from the expression for Q_{\text{LM}}(h) by replacing \widehat{\boldsymbol{\Sigma }}^{\psi \psi } by the block of % \mathbf{V}_{N}^{-1}\mathbf{W}_{N}\mathbf{V}_{N}^{-1}=(\Gamma _{N}\otimes \mathbf{I}_{K})^{-1}\mathbf{W}_{N}(\Gamma _{N}\otimes \mathbf{I}_{K})^{-1} corresponding to \boldsymbol{\psi } and with % \widehat{\mathbf{u}}_{t} defined by HC_{0}, HC_{1}, HC_{2} and HC_{3} , respectively.

HC_{0} uses \widehat{\mathbf{u}}_{t}\widehat{\mathbf{u}}_{t}^{\prime }. HC_{1} multiplies the elements of \widehat{\mathbf{u}}_{t}\widehat{\mathbf{u}}_{t}^{\prime } by N/(N-Kp). HC_{2} replaces \widehat{% \mathbf{u}}_{t} by \widehat{\mathbf{u}}_{t}/(1-h_{t})^{1/2}, where h_{t}=\mathbf{Z}_{t}(\mathbf{Z}^{\prime }\mathbf{Z})^{-1}\mathbf{Z}_{t}^{\prime } is the tth diagonal element of \mathbf{Z}(\mathbf{Z}^{\prime }\mathbf{Z})^{-1}\mathbf{Z}^{\prime }, and \mathbf{% Z}=(\mathbf{Z}_{0},\ldots ,\mathbf{Z}_{N-1}). HC_{3} replaces \widehat{\mathbf{u}}_{t} by \widehat{\mathbf{u}}_{t}/(1-h_{t}).

See MacKinnon and White (1985) for details.

The recursive-design wild bootstrap (WB) tests for error AC are computed using Algorithm 1 in Ahlgren and Catani (2016). The Fixed-design WB tests for error AC are computed using Algorithm 2 in Ahlgren and Catani (2016).

Value

a list of class "ACtest".

fit

the fit argument object.

inputType

the type of object of fit.

HCtype

a vector of the HCtype's used.

h

the lag length of the alternative VAR(h) model for the errors.

pValues

a 1 x 5 matrix of the P. values of the tests.

Q

a 1 x 5 matrix of the Q statistics of the tests.

unipValues

a K x 5 matrix of the P. values of the univariate tests.

uniQ

a K x 5 matrix of the Q statistics of the univariate tests.

univariate

the 'univariate' argument.

description

who ran the test and when.

time

computation time taken to run the test.

call

how the function ACtest() was called.

References

Ahlgren, N. & Catani, P. (2016). Wild bootstrap tests for autocorrelation in vector autoregressive models. Stat Papers, <doi:10.1007/s00362-016-0744-0>.

Hafner, C. M. and Herwartz, H., (2009). Testing for Linear Vector Autoregressive Dynamics under Multivariate Generalized Autoregressive Heteroskedasticity. Stat Neerl, 63, 294–323

MacKinnon, J. G. and White, H. (1985). Some Heteroskedasticity Consistent Covariance Matrix Estimators with Improved Finite Sample Properties. J Econom, 29, 305–325

See Also

VARfit to estimate a VAR(p), and wildBoot to run the Wild Bootstrap versions of the tests.

Examples

fit <- VARfit(y = VodafoneCDS, p = 3, const = TRUE, trend = FALSE)
test <- ACtest(fit = fit, h = 1, HCtype = c("LM", "HC0", "HC1", "HC2", "HC3"))
test

Multiple Time Series Data Set

Description

The data matrix VodafoneCDS is used for the examples. It consists of 804 daily observations, from 1 January 2009 to 31 January 2012, of Vodafone's Credit Default Swap prices (the 'CDS' column) and the credit spread on its bond over the risk-free rate (the 'SWSP' column). For more information, see Ahlgren and Catani (2016), who used the same data set.

References

Ahlgren, N. & Catani, P. (2016). Wild bootstrap tests for autocorrelation in vector autoregressive models. Stat Papers, <doi:10.1007/s00362-016-0744-0>.


VAR(p) (Vector Autoregression) Model Fitting.

Description

Estimates a VAR(p) model from data. The function's purpose is to be used before the ACtest or archBootTest functions, and doesn't have the same full functionality as for example the function vars::VAR in the vars package.

Usage

VARfit(y, p = 1, const = TRUE, trend = FALSE, exogen = NULL, univariate = FALSE)

Arguments

y

an N x K matrix containing the time series to be modeled.

p

the lag length of the VAR(p) process.

const

if TRUE (default) the model will include a constant.

trend

if TRUE the model will include a trend.

exogen

a matrix or vector of exogenous variable(s). Must have the same number of rows as 'y' does.

univariate

if TRUE univariate (i.e. an AR(p) model for each timeseries) estimates will also be printed.

Value

a list of class "VARfit" with the following slots:

y

the data matrix.

p

the lag length p.

N

the the number of observations/rows in the time series 'y'.

K

the the number of variables in the time series 'y'.

const

TRUE if the model included a constant.

trend

TRUE if the model included a trend.

exogen

the exogen variable(s).

Z

the [N - p] x [Kp + numberOf(const, trend, dummy)] design matrix, where the lags of the y matrix are appended.

call

how the function VARfit() was called.

coef

a matrix of the estimated parameters.

resid

the [N - p] x K matrix of residuals.

uniCoef

a matrix of the estimated parameter for the univariate case (an AR(p) for each column in 'y').

uniResid

the [N - p] x K matrix of residuals from the univariate (AR(p)) cases.

univariate

the 'univariate' argument.

NnonLagVar

the number of non-endogenous variables (i.e. the number of 'exogen' variables + const + trend).

description

who fitted the model and when.

time

computation time taken for the estimation.

See Also

ACtest to test for error autocorrelations, and archBootTest to test for ARCH errors.

Examples

fit <- VARfit(y = VodafoneCDS, p = 3, const = TRUE, trend = FALSE)
fit

Methods for Objects of Class VARfit

Description

residuals.VARfit() returns the residuals, and coef.VARfit() returns the coefficients of a fitted VAR model of class VARfit. print.VARfit() prints the estimated model parameters.

Usage

## S3 method for class 'VARfit'
coef(object, ...)
## S3 method for class 'VARfit'
print(x, ...)
## S3 method for class 'VARfit'
residuals(object, ...)

Arguments

x, object

A fitted VAR model of class VARfit, as returned by VARfit.

...

Additional arguments passed to the methods.

Value

coef.VARfit: A numeric matrix containing the estimated coefficients of the VAR model, including intercepts and lagged autoregressive terms.

print.VARfit: No return value. Called for its side effects (printing model information to the console).

residuals.VARfit: A numeric matrix of residuals from the fitted VAR model. Each column corresponds to one of the time series in the system.

See Also

VARfit


Simulates vector autoregressive (VAR) series

Description

This function simulates VAR(p) series. For quick use, the function can use the estimated model returned by VARfit or vars::VAR as the DGP (Data Generating Process), if passed to the fittedModel argument.

Usage

VARsim(N = 200, K = 2, p = 1, const = TRUE, trend = FALSE, exogen = NULL, 
       coef = NULL, dist = "normal", Ystart = NULL, errors = NULL, fittedModel = NULL)

Arguments

N

The length of the series.

K

The number of series/equations.

p

The lag length of the VAR(p).

const

if TRUE, a constant will be used.

trend

if TRUE, a trend will be used.

exogen

a matrix of exogenous variables. Should either have N or (N - p number of rows. If the latter, the last row will be matched with the last row of the simulated series y.

coef

a matrix of coefficients. E.g. a 2 dimensional VAR(2) with a constant, a trend and one exogenous variable must be entered in the following order (the same as returned by VARfit):

\begin{array}{cc} \bold{\mbox{\ \ \ \ \ \ y1}} & \bold{\mbox{\ \ \ \ \ \ y2}} \\ \end{array}%

\left[ \begin{array}{cc} \mbox{const} & \mbox{const} \\ \mbox{trend} & \mbox{trend} \\ \mbox{exo1} & \mbox{exo1} \\ \mbox{y1[-1]} & \mbox{y1[-1]} \\ \mbox{y2[-1]} & \mbox{y2[-1]} \\ \mbox{y1[-2]} & \mbox{y1[-2]} \\ \mbox{y2[-2]} & \mbox{y2[-2]} \\ \end{array}% \right]

dist

the distribution of the error terms (currently only "normal" for i.i.d. standard normal.)

Ystart

a p x K matrix of the start values. These will be present in the simulated series. If NULL, the start values will be set to zero.

errors

(optional) a matrix of error terms. If supplied, VARsim() will use those instead of sampling the errors. Must have K columns and either N or (N - p) number of rows. If the latter, the last row will be matched with the last row of the simulated series y.

fittedModel

(optional) either an object of class "vars", as returned by vars::VAR, or an object of class "VARfit", as returned by VARfit. If used, the estimated model of the fittedModel will be used as a DGP (Data Generating Process). Unless the arguments N, exogen and/or Ystart were supplied, they too will be taken from the fittedModel object.

Value

an N x K matrix of the simulated VAR(p).

Examples

# Simulates from a fitted DGP:
fit <- VARfit(y = VodafoneCDS, p = 1, const = TRUE)
y <- VARsim(fittedModel = fit)
VARfit(y = y, p = 1, const = TRUE)

# Simulates from user given parameters. 
#  Includes an exogenous variable:
VARcoef <- matrix(c(1,     2,
                    1,   0.5,
                    0.1,  0.3,
                    0.2,  0.5), 
                  ncol = 2, byrow = TRUE)
exo <- matrix(rnorm(500))
y <- VARsim(N = 500, K = 2, p = 1, const = TRUE, 
            trend = FALSE, exogen = exo,
            coef = VARcoef, dist = "normal")
VARfit(y = y, p = 1, const = TRUE, exogen = exo)


Combined LM test for ARCH errors in VAR models.

Description

Performs the bootstrap combined Lagrange multiplier (LM) test for autoregressive conditional heteroskedastic (ARCH) errors in vector autoregressive (VAR) models of Catani and Ahlgren (2016).

The tests of Eklund and Teräsvirta (2007), as well as the Multivariate LM test for ARCH as described for example in Lütkepohl (2006, sect. 16.5), are also included if the arguments ET respectively MARCH are set to TRUE. The bootstrap procedure for those are the same as in Catani and Ahlgren (2016).

Usage

archBootTest(fit, h = 2, B = 499, CA = TRUE, ET = TRUE, MARCH = TRUE,
             dist = "norm", skT.param = c(0, 1, 0, 5), verbose = TRUE)
## S3 method for class 'archBootTest'
print(x, ...)

Arguments

fit

an object of class "VARfit" that was returned by the VARfit function, or an object of class "verest" from the function vars::VAR in the vars package.

h

the lag length of the alternative VAR(h) model for the errors.

B

the number of bootstrap simulations.

CA

if TRUE, the Catani and Ahlgren (2017) test will run.

ET

if TRUE, the Eklund and Teräsvirta (2007) test will run.

MARCH

if TRUE, the Multivariate LM test for ARCH will run. See e.g. Lütkepohl (2006, sect. 16.5).

dist

the error distribution. Either "norm" for the standard normal distribution, or "skT" for the skew-t distribution. The parameters of the skew-t distribution can be set with the skT.param argument. Can also be a function that returns random draws as an (N-p) x K matrix or a vector of length (N-p) * K.

skT.param

a vector of four parameters for the skew-t distribution in case "skT" was used for the dist argument. The function rmst is used to draw the errors and the parameters are passed as skT.param = c(xi, Omega, alpha, nu)

verbose

logical; if TRUE, prints progress messages and an estimated completion time during the bootstrap simulation.

x

Object with class attribute ‘archBootTest’.

...

further arguments passed to or from other methods.

Details

All tests for ARCH are based on Cholesky-standardised least squares (LS) residuals from the K-dimensional vector autoregressive (VAR) model with p lags (abstracting from deterministic terms):

\mathbf{y}_{t}=\mathbf{\Pi }_{1}\mathbf{y}_{t-1}+\cdots +\mathbf{\Pi }_{p} \mathbf{y}_{t-p}+\mathbf{u}_{t},\quad \text{E}(\mathbf{u}_{t})=\mathbf{0} ,\quad \text{E}(\mathbf{u}_{t}\mathbf{u}_{t}^{\prime })=\mathbf{\Omega},\ \ \ \ t=1,\ldots ,N.

The LS residuals are

\widehat{\mathbf{u}}_{t}=\mathbf{y}_{t}-\widehat{\mathbf{\Pi }}_{1}\mathbf{y} _{t-1}-\cdots -\widehat{\mathbf{\Pi }}_{p}\mathbf{y}_{t-p},

where \widehat{\mathbf{\Pi }}_{1},\ldots ,\widehat{\mathbf{\Pi }}_{p} are the LS estimates of the K\times K parameter matrices \mathbf{\Pi } _{1},\ldots ,\mathbf{\Pi }_{p}. The multivariate LS residuals are \widehat{\mathbf{U}}=(\widehat{\mathbf{u}}_{1},\ldots ,\widehat{\mathbf{u}} _{K}), which is an N\times K matrix. The Cholesky-standardised LS residuals are

\widetilde{\mathbf{w}}_{t}=(\mathbf{S}_{\widehat{\mathbf{U}}}^{-1})^{\prime } \widehat{\mathbf{u}}_{t},

where \mathbf{S}_{\widehat{\mathbf{U}}} is the Cholesky factor of N^{-1} \widehat{\mathbf{U}}^{\prime }\widehat{\mathbf{U}}, i.e. \mathbf{S}_{ \widehat{\mathbf{U}}} is the (unique) upper triangular matrix such that

\widehat{\mathbf{\Omega }}=\mathbf{S}_{\widehat{\mathbf{U}}}^{\prime } \mathbf{S}_{\widehat{\mathbf{U}}},\quad \widehat{\mathbf{\Omega }} ^{-1}=(N^{-1}\widehat{\mathbf{U}}^{\prime }\widehat{\mathbf{U}})^{-1}= \mathbf{S}_{\widehat{\mathbf{U}}}^{-1}(\mathbf{S}_{\widehat{\mathbf{U}} }^{-1})^{\prime }.

The LM test for ARCH of order h (Engle 1982) in equation i, i=1,\ldots ,K, is a test of H_{0}:b_{1}=\cdots =b_{h} against H_{1}:b_{j}\neq 0 for at least one j\in \{1,\ldots ,h\} in the auxiliary regression

\widetilde{w}_{it}^{2}=b_{0}+b_{1}\widetilde{w}_{i,t-1}^{2}+\cdots +b_{h} \widetilde{w}_{i,t-h}^{2}+e_{it}.

The LM statistic has the form

LM_{i}=(N-p)R_{i}^{2},

where R_{i}^{2} is R^{2} from the auxiliary regression for equation i.

The combined LM statistic (Dufour et al. 2010, Catani and Ahlgren 2016) is given by

\widetilde{LM}=1-\min_{1\leq i\leq K}(p(LM_{i})),

where p(LM_{i}) is the p-value of the LM_{i} statistic, derived from the asymptotic \chi ^{2}(h) distibution. The test is only available as a bootstrap test. The bootstrap p-value is simulated using Bootstrap Algorithm 1 of Catani and Ahlgren (2016) if the errors are normal,

w_{i1},\ldots ,w_{iT}\sim \text{N}(0,1),

and Bootstrap Algorithm 2 if the errors are skew-t (by setting the function argument dist = "skT"),

w_{i1},\ldots ,w_{iT}\sim \text{skT}(0,1;\lambda ,v),

where \lambda is the skewness parameter and v is the degrees-of-freedom parameter of the skew-t distribution. These parameters can be set with the skT.param argument.

The multivariate LM test for ARCH of order h is a generalisation of the univariate test, and is based on the auxiliary regression

\text{vech}(\widetilde{\mathbf{u}}_{t}\widetilde{\mathbf{u}}_{t}^{\prime })=\mathbf{b} _{0}+\mathbf{B}_{1} \text{vech}(\widetilde{\mathbf{u}}_{t-1}\widetilde{\mathbf{u}}_{t-1}^{\prime }) +\cdots+\mathbf{B}_{h} \text{vech}(\widetilde{\mathbf{u}}_{t-h}\widetilde{\mathbf{u}}_{t-h}^{\prime }) +\mathbf{e}_{t},

where \text{vech} is the half-vectorisation operator. The null hypothesis is H_{0}:\mathbf{B }_{1}=\cdots =\mathbf{B}_{h}=\mathbf{0} against H_{1}:\mathbf{B}_{j}\neq \mathbf{0\!} for at least one j\in \{1,\ldots ,h\}. The multivariate LM statistic has the form

MLM=\frac{1}{2}(N-p)K(K+1)-(N-p)\text{tr}(\widehat{\mathbf{\Omega}}_{\text{vech}}\widehat{\mathbf{\Omega}}^{-1}),

where \widehat{\mathbf{\Omega }}_{\text{vech}} is the estimator of the error covariance matrix from the auxiliary regression and \widehat{\mathbf{ \Omega }} =N^{-1}\sum_{t=1}^{N}\widetilde{\mathbf{u}}_{t}\widetilde{ \mathbf{u}}_{t}^{\prime } is the estimator of the error covariance matrix from the VAR model (see Lütkepohl 2006, sect. 16.5). The MLM statistic is asymptotically distributed as \chi ^{2}(K^{2}(K+1)^{2}h/4). The test is available as an asymptotic test using the asymptotic \chi ^{2}(K^{2}(K+1)^{2}h/4) distribution to derive the p-value, and as a bootstrap test. The bootstrap p-value is simulated using Bootstrap Algorithms 1 and 2 of Catani and Ahlgren (2016). The asymptotic validity of the bootstrap multivariate LM test has not been established.

The Eklund and Teräsvirta (2007) LM test of constant error covariance matrix assumes the alternative hypothesis is a constant conditional correlation autoregressive conditional heteroskedasticity (CCC-ARCH) process of order h: \mathbf{H}_{t}=\mathbf{D}_{t}\mathbf{PD}_{t}, where \mathbf{ D}_{t}=\text{diag}(h_{1t}^{1/2},\ldots ,h_{Kt}^{1/2}) is a diagonal matrix of conditional standard deviations of the errors \{\mathbf{u}_{t}\} and \mathbf{P}=(\rho _{ij}), i,j=1,\ldots ,K, is a positive definite matrix of conditional correlations. The conditional variance \mathbf{h}_{t}=(h_{1t},\ldots ,h_{Kt})^{\prime } is assumed to follow a CCC-ARCH(h) process:

\mathbf{h}_{t}=\mathbf{a}_{0}+\sum_{j=1}^{h}\mathbf{A}_{j}\boldsymbol{u} _{t-j}^{(2)},

where \mathbf{a}_{0}=(a_{01},\ldots ,a_{0K})^{\prime } is a K-dimensional vector of positive constants, \mathbf{A}_{1},\ldots ,\mathbf{A} _{h} are K\times K diagonal matrices and \boldsymbol{u} _{t}^{(2)}=(u_{1t}^{2},\ldots ,u_{Kt}^{2})^{\prime }.

The null hypothesis is H_{0}:\text{diag}(\mathbf{A}_{1})=\cdots =\text{diag}(\mathbf{A}_{h})=\mathbf{0} against H_{1}: \text{diag}(\mathbf{A}_{j})\neq \mathbf{0\!} for at least one j\in \{1,\ldots ,h\}. The LM statistic has the form

LM_{CCC}=(N-p)\mathbf{s}(\widehat{\boldsymbol{\theta }})^{\prime }\mathbf{I}( \widehat{\boldsymbol{\theta }})^{-1}\mathbf{s}(\widehat{\boldsymbol{\theta }} ),

where \mathbf{s}(\widehat{\boldsymbol{\theta }}) and \mathbf{I}(\widehat{ \boldsymbol{\theta }}) are the score vector and information matrix, respectively, estimated under the null hypothesis (see Eklund and Teräsvirta 2007 for details). The asymptotic distribution of the LM_{CCC} statistic is \chi ^{2}(Kh). The test is available as an asymptotic test using the asymptotic \chi ^{2}(Kh) distribution to derive the p-value, and as a bootstrap test. The bootstrap p-value is simulated using Bootstrap Algorithms 1 and 2 of Catani and Ahlgren (2016). The asymptotic validity of the bootstrap LM_{CCC} test has not been established.

Value

a list of class "ACtest".

fit

the fit argument object.

inputType

the type of object of fit.

h

the lag length h of the alternative VAR(h) model for the errors.

B

the number of bootstrap simulations.

K

the number of series/equations in the fitted VAR model.

CA

the CA input argument.

ET

the ET input argument.

MARCH

the MARCH input argument.

dist

the dist argument object.

standardizedResi

the Cholesky-standardized residuals.

CA_LM

the combined LM statistic of Catani and Ahlgren (2016), computed as 1 - min(P(CA_LMi)).

CA_bootPV

the bootstrap P. value of the combined LM test of Catani and Ahlgren (2016).

CA_LMi

the LM statistics of Catani and Ahlgren (2016) for each time series.

CA_LMijStar

an (N-p) x K matrix of the bootstrap LM statistics for each time series (columns) and bootstrap sample (rows), for the Catani and Ahlgren (2016) test.

CA_uniBootPV

a vector of length K with the univariate bootstrap P. values for each time series, for the Catani and Ahlgren (2016) test.

ET_LM

the LM statistic of the Eklund and Teräsvirta (2007) test.

ET_PV

the P.value of the Eklund and Teräsvirta (2007) LM test statistic.

ET_bootPV

the bootstrap P.value of the Eklund and Teräsvirta (2007) test.

ET_LMStar

the bootstrap LM test statistics for the Eklund and Teräsvirta (2007) test.

MARCH_LM

the LM statistic of the Multivariate LM test for ARCH. See e.g. Lütkepohl (2006, sect. 16.5).

MARCH_PV

the P.value of the MARCH LM test statistic.

MARCH_bootPV

the bootstrap P.value of the MARCH test.

MARCH_LMStar

the bootstrap LM test statistics for the MARCH test.

description

who ran the test and when.

time

computation time taken to run the test.

call

how the function ACtest() was called.

References

Catani, P. and Ahlgren, N. (2016). Combined Lagrange multiplier test for ARCH in vector autoregressive models, Economics and Statistics, <doi:10.1016/j.ecosta.2016.10.006>.

Dufour, J.-M., Khalaf, L., and Beaulieu, M.-C. (2010). Multivariate residual-based finite-sample tests for serial dependence and arch effects with applications to asset pricing models, Journal of Applied Econometrics, 25 (2010) 263–285.

Eklund, B. and Teräsvirta, T. (2007). Testing constancy of the error covariance matrix in vector models, Journal of Econometrics, 140, 753-780.

Engle, R.F. (1982). Autoregressive conditional heteroscedasticity with estimates of the variance of United Kingdom inflation, Econometrica, 50, 987-1007.

Lütkepohl, H. (2006), New Introduction to Multiple Time Series Analysis, Springer, New York.

See Also

VARfit to estimate a VAR(p).

Examples

fit <- VARfit(y = VodafoneCDS, p = 3, const = TRUE, trend = FALSE)
test <- archBootTest(fit = fit, h = 5, B = 199, CA = TRUE, ET = TRUE, MARCH = TRUE, dist = "norm")
test

Bootstrap Determination of Cointegration Rank in VAR Models

Description

This function uses the bootstrap and wild bootstrap to test the cointegration rank of a VAR model. The test is an implementation of Cavaliere, Rahbek & Taylor (2012, 2014), and is used in Ahlgren & Catani (2018).

Usage

cointBootTest(y, r = "sequence", p, model = 1, signif = 0.05, dummies = NULL, B = 999,
boot_type = c("B", "WB"), WB_dist = c("rademacher", "normal", "mammen"), verbose = TRUE)
## S3 method for class 'cointBootTest'
print(x, ...)

Arguments

y

a T x K matrix containing the time series.

r

either "sequence" or a vector of integers (0 <= r <= K - 1, where K is the number of columns in y). If a vector of integers, r is the cointegration rank being tested. If r = "sequence", the bootstrap sequential algorithm will be used (see 'details').

p

the lag order of the model.

model

either 1 (no deterministic terms), 2 (restricted constant), or 3 (restricted linear trend). See 'details' below.

signif

if r = "sequence" is used, signif sets the significance level of the tests in the sequential algorithm.

dummies

(optional) dummy variables. Must have the same number of rows as y. The models will then be estimated with the dummy variables, but the dummy variables are not used in the bootstrap DGP. In the boot_type = "B" version, the residuals used to draw the bootstrap errors do not include rows corresponding to observations where any of the dummies are equal to 1.

B

the number of bootstrap replications.

boot_type

either "B", "WB", or both. "B" uses the iid bootstrap algorithm, while "WB" uses the wild bootstrap algorithm.

WB_dist

The distribution used for the wild bootstrap. Either "rademacher", "normal", or "mammen".

verbose

logical; if TRUE, prints progress messages and an estimated completion time during the bootstrap simulation.

x

Object with class attribute ‘cointBootTest’.

...

further arguments passed to or from other methods.

Details

Consider the K-dimensional heteroskedastic cointegrated VAR model of Cavaliere, Rahbek and Taylor (2014):

\Delta\mathbf{y}_{t}=\boldsymbol{\alpha}\boldsymbol{\beta}^{\prime}\mathbf{y}_{t-1}+\sum_{i=1}^{p-1}\mathbf{\Gamma}_{i}\Delta\mathbf{y}_{t-i}+\boldsymbol{\alpha}\boldsymbol{\rho}^{\prime}D_{t}+\bm{\phi}d_{t}+\bm{\varepsilon}_{t},\ \ \ \ t=1,\ldots ,T,

where \boldsymbol{\alpha} and \boldsymbol{\beta} are \left( K \times r \right) matrices of rank r<K, the number r being the cointegration rank. D_{t} and d_{t} differ according to the model argument in the following manner:

model 1: D_{t}=0 and d_{t}=0 (no deterministic terms) model 2: D_{t}=1 and d_{t}=0 (restricted constant) model 3: D_{t}=1 and d_{t}=1 (restricted linear trend)

The likelihood ratio (LR) statistic for testing cointegration rank r against K is

Q_{r,T}=-T\sum_{i=r+1}^{K}\text{log}( 1 - \widehat{\lambda}_{i},),

where the eigenvalues \mathbf{\widehat{\lambda}}_{1}>\ldots >\mathbf{\widehat{\lambda}}_{K} are the K largest solutions to a certain eigenvalue problem (see Johansen 1996).

Bootstrap and wild bootstrap algorithm of Cavaliere, et al. (2012, 2014):

1. Estimate the model under H(r) using Gaussian PMLE yielding the estimates \boldsymbol{\widehat{\beta}}^{(r)}, \boldsymbol{\widehat{\alpha}}^{(r)}, \boldsymbol{\widehat{\rho}}^{(r)}, \mathbf{\widehat{\Gamma}}_{1}^{(r)},\ldots,\mathbf{\widehat{\Gamma}}_{p-1}^{(r)} and \widehat{\bm{\phi}}^{(r)}, together with the corresponding residuals, \widehat{\bm{\varepsilon}}_{r,t}. 2. Check that the equation | \widehat{\mathbf{A}}^{(r)}(z) |=0, with \widehat{\mathbf{A}}^{(r)}(z):=(1-z)\mathbf{I}_{K}-\boldsymbol{\widehat{\alpha}}^{(r)}\boldsymbol{\widehat{\beta}}^{(r)\prime}z-\sum_{i=1}^{p-1}\mathbf{\widehat{\Gamma}}_{i}^{(r)}(1-z)z^{i}, has K-r roots equal to 1 and all other roots outside the unit circle. If so, procede to step 3. 3. Construct the bootstrap sample recursively from

\Delta\mathbf{y}_{r,t}^{\ast}=\boldsymbol{\widehat{\alpha}}^{(r)}\boldsymbol{\widehat{\beta}}^{(r)\prime}\mathbf{y}_{r,t-1}^{\ast}+\sum_{i=1}^{p-1}\mathbf{\widehat{\Gamma}}_{i}^{(r)}\Delta\mathbf{y}_{r,t-i}^{\ast}+\boldsymbol{\widehat{\alpha}}^{(r)}\boldsymbol{\widehat{\rho}}^{(r)\prime}D_{t}+\widehat{\bm{\phi}}^{(r)}d_{t}+\bm{\varepsilon}_{r,t}^{\ast},\ \ \ \ t=1,\ldots ,T,

initialized at \mathbf{y}_{r,j}^{\ast}=\mathbf{y}_{j}, j=1-p,\ldots,0, and with the T bootstrap errors \bm{\varepsilon}_{r,t}^{\ast} generated using the residuals \widehat{\bm{\varepsilon}}_{r,t}. The bootstrap errors are generated depending on the boot_type argument in the following manner: boot_type = "B": The i.i.d. bootstrap, such that \bm{\varepsilon}_{r,t}^{\ast}:=\mathbf{\widehat{\bm{\varepsilon}}}_{r,\mathcal{U}_{t}}, where \mathcal{U}_{t}, t=1,\ldots ,T is an i.i.d. sequence of discrete uniform distributions on \{1,2,\ldots, T\}. boot_type = "WB": The wild bootstrap, where for each t=1,\ldots ,T, \bm{\varepsilon}_{r,t}^{\ast}:=\widehat{\bm{\varepsilon}}_{r,t}w_{t}, where w_{t}, t=1,\ldots ,T, is an i.i.d. sequence distributed according to the WB_dist argument. 4. Using the bootstrap sample, \{\mathbf{y}_{r,t}^{\ast}\}, and denoting by \mathbf{\widehat{\lambda}}_{1}^{\ast}>\ldots >\mathbf{\widehat{\lambda}}_{K}^{\ast} the ordered solutions to the bootstrap analogue of the eigenvalue problem, compute the bootstrap LR statistic Q_{r,T}^{\ast}:=-T\sum_{i=r+1}^{K}\text{log}( 1 - \widehat{\lambda}_{i}^{\ast}). Define the corresponding p-value as p_{r,T}^{\ast}:=1-G_{r,T}^{\ast}(Q_{r,T}), G_{r,T}^{\ast}(.) denoting the conditional (on the original data) cdf of Q_{r,T}^{\ast}. 5. The bootstrap test of H(r) against H(K) at level \mathbf{\eta} rejects H(r) if p_{r,T}^{\ast}\leq\mathbf{\eta}.

If r = "sequence", the algorithm is repeated for each null hypothesis H(r), r=0,\ldots ,K-1, and the first null hypothesis with a p_{r,T}^{\ast}>\mathbf{\eta} is selected as the cointegration rank. If p_{r,T}^{\ast}\leq\mathbf{\eta}, r=0,\ldots ,K-1, the rank selected is \widehat{r}=K.

Value

a list of class "cointBootTest".

eigen_val

the eigenvalues.

eigen_vec

the eigenvectors.

alpha

a matrix with the estimated alpha parameters for the model with r = K (for other values of r, the alpha parameters are the first r columns of this matrix).

beta

a matrix with the estimated beta parameters for the model with r = K (for other values of r, the beta parameters are the first r columns of this matrix).

gamma

a list of matrices with the estimated gamma parameters. Each parameter matrix corresponds to the model estimated under the null hypothesis in r (0:(K-1) if r = "sequence"), in the same order.

rho

a matrix with the estimated rho parameters for the model with r = K (for other values of r, the rho parameters are the first r columns of this matrix).

phi

a list of matrices with the estimated phi parameters. Each parameter matrix corresponds to the model estimated under the null hypothesis in r (0:(K-1) if r = "sequence"), in the same order.

dummy_coefs

a list of matrices with the estimated dummy parameters. Each parameter matrix corresponds to the model estimated under the null hypothesis in r (0:(K-1) if r = "sequence"), in the same order.

residuals

a list of residual matrices, one for each model estimated under the null hypothesis in r (0:(K-1) if r = "sequence"), in that order.

Q

a vector with the Q test statistics. If r = "sequence", then the first element is for the null hypothesis r = 0, and the last is for r = K - 1. Otherwise, the order corresponds to the r argument.

B.Q

a matrix of the iid bootstrap Q statistics. Each column represent the null hypothesis in the order of r (0:(K-1) if r = "sequence").

WB.Q

a matrix of the wild bootstrap Q statistics. Each column represent the null hypothesis in the order of r (0:(K-1) if r = "sequence").

B.r

the selected cointegration rank from the iid bootstrap test, if r = "sequence") were used.

WB.r

the selected cointegration rank from the wild bootstrap test, if r = "sequence") were used.

B.pv

a vector with the bootstrap P.values, in the order of r (0:(K-1) if r = "sequence").

WB.pv

a vector with the wild bootstrap P.values, in the order of r (0:(K-1) if r = "sequence").

B.errors

the number of times the bootstrap simulations had to be resimulated due to errors.

WB.errors

the number of times the wild bootstrap simulations had to be resimulated due to errors.

companion_eigen

a list of matrices with the eigenvalues of the companion matrix. The inverse of the eigenvalues are the roots in step 2 of the boostrap algorithm (see the .pdf version of this help file).

References

Ahlgren, N. & Catani, P. (2018). Practical Problems with Tests of Cointegration Rank with Strong Persistence and Heavy-Tailed Errors. In Corazza, M., Durábn, M., Grané, A., Perna, C., Sibillo, M. (eds) Mathematical and Statistical Methods for Actuarial Sciences and Finance, Cham, Springer.

Cavaliere, G., Rahbek, A., & Taylor, A. M. R. (2012). Bootstrap determination of the co-integration rank in vector autoregressive models, Econometrica, 80, 1721-1740.

Cavaliere, G., Rahbek, A., & Taylor, A. M. R. (2014). Bootstrap determination of the co-integration rank in heteroskedastic VAR models, Econometric Reviews, 33, 606-650.

Johansen, S. (1996). Likelihood-based inference in cointegrated vector autoregressive models, Oxford, Oxford University Press.

Examples


test <- cointBootTest(y = VodafoneCDS, r = "sequence", p = 2, model = 3, signif = 0.05, 
  dummies = NULL, B = 999, boot_type = c("B", "WB"), WB_dist = "rademacher")
test


Wild Bootstrap Tests for Error Autocorrelation

Description

This function runs Ahlgren and Catani's (2016) wild bootstrap (WB) test for error autocorrelation in VAR models. The function uses the test results from the function ACtest for the argument 'test', so that ACtest must be used before running wildBoot.

Usage

wildBoot(test, WBtype = c("recursive", "fixed"), B = 199, 
         WBdist = c("rademacher", "normal", "mammen"), 
         HCtype = c("LM", "HC0", "HC1", "HC2", "HC3"), 
         univariate = FALSE, verbose = TRUE)
## S3 method for class 'wildBoot'
print(x, ...)

Arguments

test

An object of class ACtest.

WBtype

set this to "recursive" for the recursive version of the test, "fixed". for the fixed version, or c("recursive", "fixed") to run both versions.

B

the number of bootstrap simulations (default is 199).

WBdist

the distribution used for the wild bootstrap error terms. Either "rademacher", "normal" or "mammen".

HCtype

a vector of the HCtype's used for the WB test. The types must have been used in the test object.

univariate

either FALSE, TRUE, or "only". If TRUE, the test will also be performed univariatly, if "only", only the univariate version will be used. For TRUE and "only", the univariate version must have been used in the test object.

verbose

logical; if TRUE, prints progress messages and an estimated completion time during the bootstrap simulation.

x

Object with class attribute ‘wildBoot’.

...

further arguments passed to or from other methods.

Value

a list of class "wildBoot".

test

the test argument object.

WBtype

the WBtype input.

B

the number of bootstrap simulations.

WBdist

the distribution used for the wild bootstrap error terms..

HCtype

the HCtype's used for the WB test.

description

who ran the function and when.

time

computation time taken to run the WB test.

call

how the function wildboot() was called.

numberOfErrors

number of times the bootstrap simulations gave an error (can happen if one of the matrices becomes computational singular). If this happens, the particular bootstrap sample will be resimulated.

numberOfNA

number of times the test from the bootstrap simulations returned NA. If this happens, the particular bootstrap sample will be resimulated.

WBr.Q

a B x 5 matrix of the recursive wild bootstrap (if used) Q statistics. Each row is the Q statistics from a bootstrap sample.

WBr.pv

the P. values from the recursive design wild bootstrap (if used).

WBf.Q

a B x 5 matrix of the fixed wild bootstrap (if used) Q statistics. Each row is the Q statistics from a bootstrap sample.

WBf.pv

the P. values from the fixed design wild bootstrap (if used).

uniList

a list of the corresponding above items (WBr.Q, WBf.Q, WBr.pv, WBf.pv) for each respective univariate test. The elemtents of the list is named "uni1WBr.Q", "uni2WBr.pv", etc.

References

Ahlgren, N. & Catani, P. (2016). Wild bootstrap tests for autocorrelation in vector autoregressive models. Stat Papers, <doi:10.1007/s00362-016-0744-0>.

See Also

ACtest for the test that is required to be run before the wildBoot function.

Examples


fit <- VARfit(y = VodafoneCDS, p = 3, const = TRUE, trend = FALSE)
test <- ACtest(fit = fit, h = 1, HCtype = c("LM", "HC0", "HC1", "HC2", "HC3"))
test
wb <- wildBoot(test = test, WBtype = "recursive", B = 199, 
               WBdist = "rademacher",  HCtype = c("LM", "HC3"))
wb               

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.