Getting started with nonParQuantileCausality

We follow the testing framework introduced in Balcilar, Gupta, and Pierdzioch (2016) and Balcilar, Gupta, Kyei, et al. (2016).

library(nonParQuantileCausality)
data(gold_oil)
# use first 500 rows
gold_oil <- gold_oil[1:501,]
q_grid <- seq(0.05, 0.95, by = 0.05)

# Causality in conditional mean (does Oil_t-1 cause Gold_t?)
res_mean <- np_quantile_causality(
  x = gold_oil$Oil,
  y = gold_oil$Gold,
  type = "mean",
  q = q_grid
)
res_mean
## $statistic
##  [1]  0.5970618  1.2387415  1.2852325  3.3940568 21.5021152 29.3965858
##  [7] 28.2085750 25.3139611 33.7866928 29.4624222 20.4465822 14.9285244
## [13] 11.9381960  8.3220207  4.9858627  2.3873202  0.9368983  0.6120236
## [19]  0.5758621
## 
## $quantiles
##  [1] 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75
## [16] 0.80 0.85 0.90 0.95
## 
## $bandwidth
## [1] 5.277595
## 
## $type
## [1] "mean"
## 
## $n
## [1] 500
## 
## $call
## np_quantile_causality(x = gold_oil$Oil, y = gold_oil$Gold, type = "mean", 
##     q = q_grid)
## 
## attr(,"class")
## [1] "np_quantile_causality"
# Causality in conditional variance
res_var <- np_quantile_causality(
  x = gold_oil$Oil,
  y = gold_oil$Gold,
  type = "variance",
  q = q_grid
)
res_var
## $statistic
##  [1]  0.5252767  1.2650061  1.2852325  2.2724813  9.3198446 11.3183913
##  [7] 24.5561055 30.3527577 28.9669302 23.8704604 23.2600689 16.8927560
## [13] 11.2089409  8.3006439  4.7351184  2.2658127  0.8908481  0.6262628
## [19]  0.5768538
## 
## $quantiles
##  [1] 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75
## [16] 0.80 0.85 0.90 0.95
## 
## $bandwidth
## [1] 5.277595
## 
## $type
## [1] "variance"
## 
## $n
## [1] 500
## 
## $call
## np_quantile_causality(x = gold_oil$Oil, y = gold_oil$Gold, type = "variance", 
##     q = q_grid)
## 
## attr(,"class")
## [1] "np_quantile_causality"
# Plot (with 5% critical value line); returns a ggplot object invisibly
plot(res_mean)

plot(res_var)

Balcilar, Mehmet, Rangan Gupta, Clement Kyei, and Mark E. Wohar. 2016. “Does Economic Policy Uncertainty Predict Exchange Rate Returns and Volatility? Evidence from a Nonparametric Causality-in-Quantiles Test.” Open Economies Review 27 (2): 229–50.
Balcilar, Mehmet, Rangan Gupta, and Christian Pierdzioch. 2016. “Does Uncertainty Move the Gold Price? New Evidence from a Nonparametric Causality-in-Quantiles Test.” Resources Policy 49: 74–80.