causality_predVAR {funtimes} | R Documentation |
Out-of-sample Tests of Granger Causality using (Restricted) Vector Autoregression
Description
Test for Granger causality using out-of-sample prediction errors from a vector autoregression (VAR), where the original VAR can be restricted (see Details). The tests include the MSE-t approach (McCracken 2007) and MSE-correlation test as in Chapter 9.3 of Granger and Newbold (1986). The bootstrap is used to empirically derive distributions of the statistics.
Usage
causality_predVAR(
y,
p = NULL,
cause = NULL,
B = 500L,
test = 0.3,
cl = 1L,
...
)
Arguments
y |
data frame or |
p |
an integer specifying the order |
cause |
name of the cause variable. If not specified, the first variable in
|
B |
number of bootstrap replications. Default is 500. |
test |
a numeric value specifying the size of the testing set. If |
cl |
parameter to specify computer cluster for bootstrapping passed to
the package
|
... |
other arguments passed to the function for VAR estimation.
The arguments include |
Details
The arguments specified in ...
are passed to the VAR
function.
Additionally, lag.restrict
can be specified to remove short-term lags from
consideration (lag.restrict
is not an option in the original package vars
).
Note that if p
is specified, lag.restrict
must be smaller
than p
otherwise the default lag.restrict = 0
will be used.
If lag.max
is specified instead of p
, VAR orders
lag.restrict
+ 1, ..., lag.max
will be considered using the training data
and the order p
will be automatically selected according to the information criterion
(by default, AIC).
In the current implementation, the bootstrapped p
-value is calculated using equation 4.10 of
Davison and Hinkley (1997): p.value
= (1 + n
) / (B
+ 1),
where n
is the number of bootstrapped statistics smaller or equal to the observed statistic.
In the fast bootstrap, n
is the number of bootstrapped statistics greater or equal to 0.
This function uses symmetric VAR with the same orders p
for modeling both Y
to X
.
To select these orders more independently, consider using the function causality_pred
.
Value
Two lists (one for the fast bootstrap, another for the bootstrap under the null hypothesis) each containing the following elements:
result |
a table with the observed values of the test statistics and |
cause |
the cause variable. |
p |
the AR order used. |
Author(s)
Vyacheslav Lyubchich
References
Davison AC, Hinkley DV (1997).
Bootstrap Methods and Their Application.
Cambridge University Press, Cambridge.
Granger CWJ, Newbold P (1986).
Forecasting economic time series, 2 edition.
Academic Press.
McCracken MW (2007).
“Asymptotics for out of sample tests of Granger causality.”
Journal of Econometrics, 140(2), 719–752.
doi:10.1016/j.jeconom.2006.07.020.
See Also
Examples
## Not run:
# Example 1: Canada time series (ts object)
Canada <- vars::Canada
causality_predVAR(Canada[,1:2], cause = "e", lag.max = 5)
causality_predVAR(Canada[,1:2], cause = "e", lag.restrict = 3, lag.max = 15)
# Example 2 (run in parallel, initiate the cluster manually):
# Box & Jenkins time series
# of sales and a leading indicator, see ?BJsales
# Initiate a local cluster
cores <- parallel::detectCores()
cl <- parallel::makeCluster(cores)
parallel::clusterSetRNGStream(cl, 123) # to make parallel computations reproducible
D <- cbind(BJsales.lead, BJsales)
causality_predVAR(D, cause = "BJsales.lead", lag.max = 5, B = 1000, cl = cl)
causality_predVAR(D, cause = "BJsales.lead", lag.restrict = 3, p = 5, B = 1000, cl = cl)
parallel::stopCluster(cl)
## End(Not run)