Learn R Programming

nonParQuantileCausality (version 0.1.0)

np_quantile_causality: Nonparametric Causality-in-Quantiles Test

Description

Computes the Balcilar-Jeong-Nishiyama style nonparametric quantile Granger-causality test for first-order lags. Methodology is based on Balcilar, Gupta, and Pierdzioch (2016, tools:::Rd_expr_doi("10.1016/j.resourpol.2016.04.004")) and Balcilar et al. (2016, tools:::Rd_expr_doi("10.1007/s11079-016-9388-x")).

Usage

np_quantile_causality(x, y, type = c("mean", "variance"), q = NULL, hm = NULL)

Value

An object of class np_quantile_causality with elements:

  • statistic: numeric vector of test statistics by quantile

  • quantiles: numeric vector of quantiles tested

  • bandwidth: scalar base bandwidth used before quantile adjustment

  • type: "mean" or "variance"

  • n: effective sample size

  • call: the matched call

Arguments

x

numeric vector; candidate cause (independent) variable. The test internally uses the first lag of x (one-lag Granger causality setup).

y

numeric vector; effect (dependent) variable. The test internally uses the first lag of y (one-lag Granger causality setup).

type

character; "mean" or "variance" (causality in mean or variance).

q

numeric vector of quantiles in (0,1). Default is seq(0.01, 0.99, 0.01).

hm

optional numeric bandwidth; if NULL, uses Yu & Jones (1998) style plug-in via KernSmooth::dpill on the mean-regression proxy.

Lag order (important)

The current implementation uses one lag of each series only: \(x_{t-1}\) and \(y_{t-1}\) (first-order Granger setup). Extending to higher lags requires changing the internal embedding (currently stats::embed(*, 2)) and the kernel construction to handle multivariate lag vectors (e.g., a product kernel over all lag coordinates or a multivariate Gaussian kernel).

Details

Uses local polynomial quantile regression at each quantile with kernel weights, constructs the Song et al. (2012) style quadratic form, and rescales to the asymptotic standard-normal statistic.

References

  • Balcilar, M., Gupta, R., & Pierdzioch, C. (2016). Does uncertainty move the gold price? New evidence from a nonparametric causality-in-quantiles test. Resources Policy, 49, 74–80. tools:::Rd_expr_doi("10.1016/j.resourpol.2016.04.004")

  • Balcilar, M., Gupta, R., Kyei, C., & Wohar, M. E. (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–250. tools:::Rd_expr_doi("10.1007/s11079-016-9388-x")

Examples

Run this code
# \donttest{
set.seed(1234)
x <- arima.sim(n = 600, list(ar = 0.4))
y <- 0.5*lag(x, -1) + rnorm(600)  # x Granger-causes y
y[is.na(y)] <- mean(y, na.rm = TRUE)
obj <- np_quantile_causality(x, y, type = "mean", q = seq(0.1, 0.9, 0.1))
plot(obj)  # test statistic vs quantiles with 5% CV line

# Example with bundled dataset (Gold causes Gold or Oil depending on call)
data(gold_oil)
# use first 500 days
gold_oil <- gold_oil[1:501,]
q_grid <- seq(0.25, 0.75, by = 0.25)

# 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

# Causality in conditional variance
res_var <- np_quantile_causality(
  x = gold_oil$Oil,
  y = gold_oil$Gold,
  type = "variance",
  q = q_grid
)
res_var

# Plot (with 5% critical value line); returns a ggplot object invisibly
plot(res_mean)
plot(res_var)
# }

Run the code above in your browser using DataLab