| Type: | Package | 
| Title: | Nonparametric Causality in Quantiles Test | 
| Version: | 0.1.0 | 
| Author: | Mehmet Balcilar [aut, cre] | 
| Maintainer: | Mehmet Balcilar <mehmet@mbalcilar.net> | 
| 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 (2016a) <doi:10.1016/j.resourpol.2016.04.004> and Balcilar et al. (2016) <doi:10.1007/s11079-016-9388-x>. | 
| License: | MIT + file LICENSE | 
| URL: | https://www.mbalcilar.net, https://github.com/mbalcilar/nonParQuantileCausality | 
| Encoding: | UTF-8 | 
| LazyData: | true | 
| LazyDataCompression: | bzip2 | 
| RoxygenNote: | 7.3.2 | 
| Depends: | R (≥ 3.6) | 
| Imports: | stats, ggplot2, quantreg, KernSmooth | 
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) | 
| VignetteBuilder: | knitr | 
| Config/testthat/edition: | 3 | 
| NeedsCompilation: | no | 
| Packaged: | 2025-09-22 20:25:08 UTC; mbalcilar | 
| Repository: | CRAN | 
| Date/Publication: | 2025-09-30 07:20:08 UTC | 
nonParQuantileCausality: Nonparametric Causality in Quantiles
Description
Tools for nonparametric causality-in-quantiles tests (mean and variance) with an S3 plot method and an example dataset.
Lag order (important)
The current implementation uses one lag of each series (first-order Granger setup).
References
Balcilar, M., Gupta, R., & Pierdzioch, C. (2016). Resources Policy, 49, 74–80.
Balcilar, M., Gupta, R., Kyei, C., & Wohar, M. E. (2016). Open Economies Review, 27(2), 229–250.
Author(s)
Maintainer: Mehmet Balcilar mehmet@mbalcilar.net
See Also
Useful links:
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.
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   | 
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:
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).
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 x_{t-1} Granger-causes y_t
in quantile \theta (and, with type = "variance", whether
x_{t-1}^2 causes y_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   | 
cv | 
 numeric; a reference critical value line (default 1.96 for ~5%)  | 
title | 
 optional plot title; default is constructed from   | 
... | 
 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.