The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

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

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


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:

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

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

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.