Package 'nonParQuantileCausality'

Title: Nonparametric Causality in Quantiles Test
Description: Implements the nonparametric causality-in-quantiles test (in mean or variance), returning a test object with an S3 plot() method. The current implementation uses one lag of each series (first-order Granger causality setup). Methodology is based on Balcilar, Gupta, and Pierdzioch (2016) <doi:10.1016/j.resourpol.2016.04.004> and Balcilar et al. (2016) <doi:10.1007/s11079-016-9388-x>.
Authors: Mehmet Balcilar [aut, cre]
Maintainer: Mehmet Balcilar <[email protected]>
License: MIT + file LICENSE
Version: 0.1.1
Built: 2026-05-16 06:09:16 UTC
Source: https://github.com/mbalcilar/nonparquantilecausality

Help Index


Monthly Gold and Oil Returns

Description

A small example dataset used to illustrate the nonparametric causality-in-quantiles test.

Usage

gold_oil

Format

A data frame with two numeric columns:

Gold

numeric: gold series

Oil

numeric: oil series

Details

Columns are generic numeric series (already aligned and cleaned) suitable for the examples in np_quantile_causality.

Source

Provided by Mehmet Balcilar.


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, doi:10.1016/j.resourpol.2016.04.004) and Balcilar et al. (2016, doi:10.1007/s11079-016-9388-x).

Usage

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

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.

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.

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

Lag order (important)

The current implementation uses one lag of each series only: xt1x_{t-1} and yt1y_{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).

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. 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. doi:10.1007/s11079-016-9388-x

Note

This function tests whether xt1x_{t-1} Granger-causes yty_t in quantile θ\theta (and, with type = "variance", whether xt12x_{t-1}^2 causes yt2y_t^2). Higher-order lags are not supported in this release.

Examples

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)

Plot method for np_quantile_causality objects

Description

Plot method for np_quantile_causality objects

Usage

## S3 method for class 'np_quantile_causality'
plot(x, cv = 1.96, title = NULL, ...)

Arguments

x

an object of class np_quantile_causality

cv

numeric; a reference critical value line (default 1.96 for ~5%)

title

optional plot title; default is constructed from x$type

...

unused (for S3 compatibility)

Value

A ggplot object (invisibly).

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.

  • 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.


YourPackageName: Nonparametric Causality-in-Quantiles

Description

Tools for nonparametric causality-in-quantiles in mean and variance.

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.

  • 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.