| Type: | Package |
| Title: | Multiple Granger Causality Tests for Time Series and Panel Data |
| Version: | 1.1.1 |
| Description: | Comprehensive suite of Granger causality tests for time series and panel data. For time series: Toda-Yamamoto (1995) <doi:10.1016/0304-4076(94)01616-8>, Fourier-based tests with single frequency (Enders and Jones, 2016) <doi:10.1515/snde-2014-0101> and cumulative frequencies (Nazlioglu et al., 2019) <doi:10.1080/1540496X.2018.1434072>, quantile causality tests (Cai et al., 2023) <doi:10.1016/j.frl.2023.104327>, and Bootstrap Fourier Granger Causality in Quantiles (Cheng et al., 2021) <doi:10.1007/s12076-020-00263-0>. For panel data: Panel Fourier Toda-Yamamoto (Yilanci and Gorus, 2020) <doi:10.1007/s11356-020-10092-9> and Panel Quantile Causality tests (Wang and Nguyen, 2022) <doi:10.1080/1331677X.2021.1952089>, as well as Group-Mean and Pooled Fully Modified OLS estimators for panel cointegrating polynomial regressions (Wagner and Reichold, 2023) <doi:10.1080/07474938.2023.2178141>. All tests include bootstrap inference for robust p-values. |
| License: | GPL-3 |
| URL: | https://github.com/muhammedalkhalaf/caustests |
| BugReports: | https://github.com/muhammedalkhalaf/caustests/issues |
| Encoding: | UTF-8 |
| LazyData: | true |
| Depends: | R (≥ 3.5.0) |
| Imports: | stats, quantreg |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-04-04 14:51:37 UTC; SYSTEM |
| Author: | Muhammad Alkhalaf |
| Maintainer: | Muhammad Alkhalaf <muhammedalkhalaf@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-04-05 06:50:06 UTC |
caustests: Multiple Granger Causality Tests for Time Series and Panel Data
Description
Comprehensive suite of Granger causality tests for time series and panel data including standard Toda-Yamamoto, Fourier-based tests, quantile causality tests, panel Fourier Toda-Yamamoto, panel quantile causality, and Group-Mean/Pooled FM-OLS for panel cointegrating polynomial regressions.
Time Series Functions
-
caustests: Perform Granger causality tests (time series)
Panel Data Functions
-
xtpcaus: Panel Granger causality tests (PFTY and PQC) -
xtpcmg: Panel cointegrating polynomial regressions (FM-OLS)
Available Tests (Time Series)
Toda-Yamamoto (1995) - Robust to integration order
Single Fourier Granger (Enders & Jones, 2016)
Single Fourier Toda-Yamamoto (Nazlioglu et al., 2016)
Cumulative Fourier Granger (Enders & Jones, 2019)
Cumulative Fourier Toda-Yamamoto (Nazlioglu et al., 2019)
Quantile Toda-Yamamoto (Cai et al., 2023)
Bootstrap Fourier Granger in Quantiles (Cheng et al., 2021)
Available Tests (Panel Data)
Panel Fourier Toda-Yamamoto (Yilanci and Gorus, 2020)
Panel Quantile Causality (Wang and Nguyen, 2022)
Group-Mean FM-OLS (Wagner and Reichold, 2023)
Pooled FM-OLS (de Jong and Wagner, 2022)
Data
-
caustests_data: Example time series dataset -
grunfeld_panel: Example panel dataset for xtpcaus -
grunfeld_cmg: Example panel dataset for xtpcmg
Author(s)
Maintainer: Muhammad Alkhalaf muhammedalkhalaf@gmail.com (ORCID) [copyright holder]
References
Toda, H. Y., & Yamamoto, T. (1995). Statistical inference in vector autoregressions with possibly integrated processes. Journal of Econometrics, 66(1-2), 225-250. doi:10.1016/0304-4076(94)01616-8
Enders, W., & Jones, P. (2016). Grain prices, oil prices, and multiple smooth breaks in a VAR. Studies in Nonlinear Dynamics & Econometrics, 20(4), 399-419. doi:10.1515/snde-2014-0101
Nazlioglu, S., Gormus, N. A., & Soytas, U. (2016). Oil prices and real estate investment trusts (REITs): Gradual-shift causality and volatility transmission analysis. Energy Economics, 60, 168-175. doi:10.1016/j.eneco.2016.09.009
Nazlioglu, S., Soytas, U., & Gormus, N. A. (2019). Oil prices and monetary policy in emerging markets: Structural shifts in causal linkages. Emerging Markets Finance and Trade, 55(1), 105-117. doi:10.1080/1540496X.2018.1434072
Cai, Y., Chang, T., Xiang, Y., & Chang, H. L. (2023). Testing Granger causality in quantiles between the stock and the foreign exchange markets of Japan. Finance Research Letters, 58, 104327. doi:10.1016/j.frl.2023.104327
Cheng, S. C., Hsueh, H. P., Ranjbar, O., Wang, M. C., & Chang, T. (2021). Bootstrap Fourier Granger causality test in quantiles and the asymmetric causal relationship between CO2 emissions and economic growth. Letters in Spatial and Resource Sciences, 14, 31-49. doi:10.1007/s12076-020-00263-0
Yilanci, V. and Gorus, M.S. (2020). Does economic globalization have predictive power for ecological footprint in MENA counties? A panel causality test with a Fourier function. Environmental Science and Pollution Research, 27, 40552-40562. doi:10.1007/s11356-020-10092-9
Wang, K.M. and Nguyen, T.B. (2022). A quantile panel-type analysis of income inequality and healthcare expenditure. Economic Research, 35(1), 873-893. doi:10.1080/1331677X.2021.1952089
Wagner, M. and Reichold, K. (2023). Panel cointegrating polynomial regressions: group-mean fully modified OLS estimation and inference. Econometric Reviews, 42(4), 358-392. doi:10.1080/07474938.2023.2178141
de Jong, R.M. and Wagner, M. (2022). Panel cointegrating polynomial regressions. Annals of Applied Statistics, 16(1), 416-442. doi:10.1214/21-AOAS1536
See Also
Useful links:
Report bugs at https://github.com/muhammedalkhalaf/caustests/issues
Multiple Granger Causality Tests
Description
Performs various Granger causality tests including Toda-Yamamoto, Fourier-based tests (single and cumulative frequency), and quantile causality tests with bootstrap inference.
Usage
caustests(
data,
test,
pmax = 8,
ic = 1,
nboot = 1000,
kmax = 3,
dmax = NULL,
quantiles = seq(0.1, 0.9, 0.1),
verbose = TRUE
)
Arguments
data |
A data frame or matrix with time series variables (columns). |
test |
Integer 1-7 specifying the test type:
|
pmax |
Maximum lag order for model selection (default: 8). |
ic |
Information criterion: 1 for AIC, 2 for SBC/BIC (default: 1). |
nboot |
Number of bootstrap replications (default: 1000). |
kmax |
Maximum Fourier frequency (default: 3, used for tests 2-5, 7). |
dmax |
Extra lags for Toda-Yamamoto augmentation. If NULL, automatically set to 0 for tests 2, 4 (differences) and 1 for tests 1, 3, 5, 6, 7 (levels). |
quantiles |
Numeric vector of quantiles for tests 6-7 (default: seq(0.1, 0.9, 0.1)). |
verbose |
Logical; print progress messages (default: TRUE). |
Details
The package implements seven Granger causality tests:
Test 1: Toda-Yamamoto (1995) Standard Granger causality in levels using VAR with extra lags equal to the maximum integration order (dmax). This approach is robust to unknown integration and cointegration properties.
Tests 2-3: Single Fourier Frequency Incorporate a single Fourier frequency to capture smooth structural breaks. Test 2 uses first differences, Test 3 uses levels (Toda-Yamamoto style).
Tests 4-5: Cumulative Fourier Frequency Use cumulative Fourier frequencies (1 to k) for more flexible break patterns. Test 4 uses first differences, Test 5 uses levels.
Test 6: Quantile Toda-Yamamoto Extends Toda-Yamamoto to quantile regression, allowing causality analysis across different quantiles of the conditional distribution.
Test 7: Bootstrap Fourier Granger Causality in Quantiles (BFGC-Q) Combines Fourier flexibility with quantile regression for robust inference under structural breaks and across quantiles.
Value
An object of class "caustests" containing:
results |
Data frame with test results for each direction |
test |
Test number used |
test_name |
Name of the test |
pmax |
Maximum lag considered |
ic |
Information criterion used |
nboot |
Number of bootstrap replications |
kmax |
Maximum Fourier frequency |
dmax |
Augmentation lags |
quantiles |
Quantiles used (for tests 6-7) |
quantile_results |
Detailed quantile results (for tests 6-7) |
References
Toda, H. Y., & Yamamoto, T. (1995). Statistical inference in vector autoregressions with possibly integrated processes. Journal of Econometrics, 66(1-2), 225-250. doi:10.1016/0304-4076(94)01616-8
Enders, W., & Jones, P. (2016). Grain prices, oil prices, and multiple smooth breaks in a VAR. Studies in Nonlinear Dynamics & Econometrics, 20(4), 399-419. doi:10.1515/snde-2014-0101
Nazlioglu, S., Gormus, N. A., & Soytas, U. (2016). Oil prices and real estate investment trusts (REITs): Gradual-shift causality and volatility transmission analysis. Energy Economics, 60, 168-175. doi:10.1016/j.eneco.2016.09.009
Nazlioglu, S., Soytas, U., & Gormus, N. A. (2019). Oil prices and monetary policy in emerging markets: Structural shifts in causal linkages. Emerging Markets Finance and Trade, 55(1), 105-117. doi:10.1080/1540496X.2018.1434072
Cai, Y., Chang, T., Xiang, Y., & Chang, H. L. (2023). Testing Granger causality in quantiles between the stock and the foreign exchange markets of Japan. Finance Research Letters, 58, 104327. doi:10.1016/j.frl.2023.104327
Cheng, S. C., Hsueh, H. P., Ranjbar, O., Wang, M. C., & Chang, T. (2021). Bootstrap Fourier Granger causality test in quantiles and the asymmetric causal relationship between CO2 emissions and economic growth. Letters in Spatial and Resource Sciences, 14, 31-49. doi:10.1007/s12076-020-00263-0
Examples
# Load example data
data(caustests_data)
# Test 1: Toda-Yamamoto test
result1 <- caustests(caustests_data, test = 1, nboot = 199)
print(result1)
summary(result1)
# Test 3: Single Fourier Toda-Yamamoto
result3 <- caustests(caustests_data, test = 3, kmax = 2, nboot = 199)
print(result3)
# Test 6: Quantile causality (fewer quantiles for speed)
result6 <- caustests(caustests_data, test = 6,
quantiles = c(0.25, 0.50, 0.75), nboot = 199)
print(result6)
Example Time Series Dataset for Causality Tests
Description
A simulated dataset containing three time series variables for demonstrating Granger causality tests. The data includes one dependent variable (Y) and two potential causal variables (X1, X2) with known causal relationships.
Usage
caustests_data
Format
A data frame with 200 observations and 3 variables:
- Y
Dependent variable, generated as AR(2) plus causal effects from X1
- X1
First explanatory variable, AR(1) process
- X2
Second explanatory variable, independent AR(1) process
Details
The data generating process is:
X1 and X2 are independent AR(1) processes
Y depends on its own lags plus lagged values of X1 (but not X2)
This creates a true causal relationship from X1 to Y
There is no true causality from X2 to Y or from Y to X1/X2
This allows users to verify that the causality tests correctly identify the causal direction X1 => Y while finding no significant causality in other directions (with appropriate sample sizes and test settings).
Source
Simulated data for package demonstration
Examples
data(caustests_data)
head(caustests_data)
summary(caustests_data)
# Check correlations
cor(caustests_data)
Example Panel Data for xtpcmg
Description
Returns the Grunfeld (1958) balanced panel dataset for examples.
Usage
grunfeld_cmg()
Value
A data frame with columns firm, year,
invest, and mvalue.
Examples
dat <- grunfeld_cmg()
head(dat)
Example Panel Data for xtpcaus
Description
Returns a small balanced panel dataset (subset of Grunfeld 1958) for use in examples and testing.
Usage
grunfeld_panel()
Value
A data frame with columns firm, year,
invest, and mvalue.
Examples
dat <- grunfeld_panel()
head(dat)
Plot Quantile Causality Results
Description
Creates diagnostic plots for quantile causality tests (tests 6-7).
Usage
## S3 method for class 'caustests'
plot(x, which = 1, type = "both", ...)
Arguments
x |
An object of class |
which |
Which direction to plot (default: 1, first direction). |
type |
Plot type: "wald" for Wald statistics, "pval" for p-values, or "both" (default). |
... |
Additional arguments passed to |
Value
Invisibly returns the plotted data.
Examples
data(caustests_data)
result <- caustests(caustests_data, test = 6,
quantiles = c(0.25, 0.50, 0.75), nboot = 199)
plot(result)
Print Method for xtpcaus Objects
Description
Print Method for xtpcaus Objects
Usage
## S3 method for class 'xtpcaus'
print(x, ...)
Arguments
x |
An object of class |
... |
Additional arguments (ignored). |
Value
Invisibly returns x.
Print Method for xtpcmg Objects
Description
Print Method for xtpcmg Objects
Usage
## S3 method for class 'xtpcmg'
print(x, ...)
Arguments
x |
An object of class |
... |
Additional arguments (ignored). |
Value
Invisibly returns x.
Summary Method for xtpcaus Objects
Description
Summary Method for xtpcaus Objects
Usage
## S3 method for class 'xtpcaus'
summary(object, ...)
Arguments
object |
An object of class |
... |
Additional arguments (ignored). |
Value
Invisibly returns object.
Summary Method for xtpcmg Objects
Description
Summary Method for xtpcmg Objects
Usage
## S3 method for class 'xtpcmg'
summary(object, ...)
Arguments
object |
An object of class |
... |
Additional arguments (ignored). |
Value
Invisibly returns object.
Panel Granger Causality Tests
Description
Tests whether x Granger-causes y in a balanced panel using
either the Panel Fourier Toda-Yamamoto (PFTY) test or the Panel Quantile
Causality (PQC) test.
Usage
xtpcaus(
data,
y,
x,
panel_id,
time_id,
test = c("pfty", "pqc"),
pmax = 4L,
dmax = 1L,
nboot = 499L,
kmax = 3L,
ic = c("aic", "bic"),
quantiles = c(0.1, 0.25, 0.5, 0.75, 0.9),
seed = -1L
)
Arguments
data |
A data frame in long format. |
y |
Character. Name of the dependent (caused) variable. |
x |
Character. Name of the independent (causing) variable. |
panel_id |
Character. Name of the panel identifier variable. |
time_id |
Character. Name of the time variable. |
test |
Character. Test type: |
pmax |
Integer. Maximum lag order for selection. Default is |
dmax |
Integer. Maximum integration order for Toda-Yamamoto
augmentation. Default is |
nboot |
Integer. Number of bootstrap replications. Minimum 99.
Default is |
kmax |
Integer. Maximum Fourier frequency (PFTY only). Default is
|
ic |
Character. Information criterion: |
quantiles |
Numeric vector. Quantile grid for PQC test (values strictly
between 0 and 1). Default is
|
seed |
Integer. Random seed for bootstrap. |
Value
An object of class "xtpcaus" containing:
- test
Character.
"pfty"or"pqc".- N
Integer. Number of panel units.
- TT
Integer. Number of time periods.
- nboot
Integer. Number of bootstrap replications.
- y
Character. Name of the y variable.
- x
Character. Name of the x variable.
For PFTY:
- fisher
Numeric. Fisher panel statistic.
- fisher_df
Integer. Degrees of freedom (2*N).
- fisher_pv
Numeric. Fisher p-value.
- wbar
Numeric. Average individual Wald statistic.
- zbar
Numeric. Dumitrescu-Hurlin Z-bar statistic.
- zbar_pv
Numeric. Z-bar p-value.
- ind_wald
Numeric vector. Individual Wald statistics (length N).
- ind_freq
Integer vector. Optimal Fourier frequencies (length N).
- ind_pval_b
Numeric vector. Bootstrap p-values (length N).
- ind_lags
Integer vector. Selected lag orders (length N).
For PQC:
- quantiles
Numeric vector. Quantiles tested.
- wald_xy
Numeric vector. Wald statistics per quantile (x => y).
- pval_xy
Numeric vector. Bootstrap p-values per quantile (x => y).
- wald_yx
Numeric vector. Wald statistics per quantile (y => x).
- pval_yx
Numeric vector. Bootstrap p-values per quantile (y => x).
- supwald_xy
Numeric. Sup-Wald statistic for x => y.
- supwald_yx
Numeric. Sup-Wald statistic for y => x.
- p_opt
Integer. Selected optimal lag.
References
Chuang, C.C., Kuan, C.M. and Lin, H.Y. (2009). Causality in quantiles and dynamic stock return-volume relations. Journal of Banking and Finance, 33(7), 1351–1360. doi:10.1016/j.jbankfin.2009.02.013
Emirmahmutoglu, F. and Kose, N. (2011). Testing for Granger causality in heterogeneous mixed panels. Economic Modelling, 28(3), 870–876. doi:10.1016/j.econmod.2010.10.018
Toda, H.Y. and Yamamoto, T. (1995). Statistical inference in vector autoregressions with possibly integrated processes. Journal of Econometrics, 66(1–2), 225–250. doi:10.1016/0304-4076(94)01616-8
Wang, K.M. and Nguyen, T.B. (2022). A quantile panel-type analysis of income inequality and healthcare expenditure. Economic Research, 35(1), 873–893. doi:10.1080/1331677X.2021.1952089
Yilanci, V. and Gorus, M.S. (2020). Does economic globalization have predictive power for ecological footprint. Environmental Science and Pollution Research, 27, 40552–40562. doi:10.1007/s11356-020-10092-9
Examples
dat <- grunfeld_panel()
# PFTY test (quick with few bootstrap reps)
res <- xtpcaus(dat, y = "invest", x = "mvalue",
panel_id = "firm", time_id = "year",
test = "pfty", pmax = 2L, dmax = 1L,
nboot = 99L, kmax = 2L, seed = 42L)
print(res)
# PQC test
res2 <- xtpcaus(dat, y = "invest", x = "mvalue",
panel_id = "firm", time_id = "year",
test = "pqc", pmax = 2L, nboot = 99L,
quantiles = c(0.25, 0.50, 0.75), seed = 42L)
print(res2)
Panel Cointegrating Polynomial Regressions via FM-OLS
Description
Estimates a polynomial cointegrating regression in a panel using either Group-Mean FM-OLS (Wagner & Reichold 2023) or Pooled FM-OLS (de Jong & Wagner 2022). Models the long-run relationship:
Usage
xtpcmg(
data,
y,
x,
panel_id,
time_id,
model = c("mg", "pmg"),
q = 2L,
controls = NULL,
trend = 1L,
kernel = "ba",
bw = "And91",
effects = "oneway",
corr_rob = FALSE
)
Arguments
data |
A data frame in long format. |
y |
Character. Name of the dependent variable. |
x |
Character. Name of the polynomial (I(1)) regressor. |
panel_id |
Character. Name of the panel identifier variable. |
time_id |
Character. Name of the time variable. |
model |
Character. Estimator: |
q |
Integer. Polynomial degree: |
controls |
Character vector. Names of additional I(1) control
variables. Default is |
trend |
Integer. Deterministic trend type: |
kernel |
Character. HAC kernel: |
bw |
Character or numeric. Bandwidth for HAC estimation. |
effects |
Character. For Pooled FM-OLS: |
corr_rob |
Logical. For Group-Mean FM-OLS: if |
Details
y_{it} = \alpha_i + \beta_1 x_{it} + \beta_2 x_{it}^2 [+ \beta_3 x_{it}^3]
[+ \gamma z_{it}] + u_{it}
where x_{it} and z_{it} are I(1) processes.
Value
An object of class "xtpcmg" with elements:
coefficients (named numeric vector),
vcov (variance-covariance matrix),
se (standard errors),
tstat (t-statistics),
pvalue (two-sided p-values),
model (estimator type: mg or pmg),
q (polynomial degree),
N (number of panel units),
TT (number of time periods),
y (dependent variable name),
x (polynomial variable name),
tp (turning point estimate, quadratic models only),
tp_se (delta-method SE for turning point),
tp_lo and tp_hi (95% CI bounds),
ind_coef (individual FM-OLS estimates, MG model),
swamy_s and swamy_p (Swamy slope homogeneity test).
References
Andrews, D.W.K. (1991). Heteroskedasticity and autocorrelation consistent covariance matrix estimation. Econometrica, 59(3), 817–858. doi:10.2307/2938229
de Jong, R.M. and Wagner, M. (2022). Panel cointegrating polynomial regressions. Annals of Applied Statistics, 16(1), 416–442. doi:10.1214/21-AOAS1536
Wagner, M. and Reichold, K. (2023). Panel cointegrating polynomial regressions. Econometric Reviews, 42(9–10), 782–827. doi:10.1080/07474938.2023.2178141
Examples
dat <- grunfeld_cmg()
# Group-Mean FM-OLS (quadratic EKC-type model)
res <- xtpcmg(dat, y = "invest", x = "mvalue",
panel_id = "firm", time_id = "year",
model = "mg", q = 2L)
print(res)
summary(res)
# Pooled FM-OLS
res2 <- xtpcmg(dat, y = "invest", x = "mvalue",
panel_id = "firm", time_id = "year",
model = "pmg", q = 2L)
print(res2)