Package 'grangers'

Title: Inference on Granger-Causality in the Frequency Domain
Description: Contains five functions performing the calculation of unconditional and conditional Granger-causality spectra, and bootstrap inference on both, via the bootstrap approach of Farne' and Montanari <arXiv:1803.00374>.
Authors: Matteo Farne' <[email protected]>, Angela Montanari <[email protected]>
Maintainer: Matteo Farne' <[email protected]>
License: GPL (>= 2)
Version: 0.1.0
Built: 2025-03-05 03:31:13 UTC
Source: https://github.com/matfar88/grangers

Help Index


Conditional Granger-causality test of Breitung and Candelon (2006)

Description

Inference on the conditional Granger-causality spectrum is provided by the parametric test of Breitung and Candelon (2006).

Usage

bc_test_cond(x, y, z, ic.chosen = "SC", max.lag = min(4, length(x) -
  1), plot = F, type.chosen = "none", p = 0, conf = 0.95)

Arguments

x

univariate time series.

y

univariate time series (of the same length of ⁠x⁠).

z

univariate time series (of the same length of ⁠x⁠).

ic.chosen

estimation method parameter ⁠ic⁠ to be passed to function VAR of package vars. Defaults to ”SC” (Schwarz criterion). Alternatives are ⁠c(''AIC'',''HQ'',''SC'',''FPE'')⁠.

max.lag

maximum number of lags ⁠lag.max⁠ to be passed to function VAR. Defaults to ⁠min(4, length(x) - 1)⁠.

plot

logical; if TRUE, it returns the plot of conditional Granger-causality spectrum. Defaults to FALSE.

type.chosen

parameter ⁠type⁠ to be passed to function VAR.

p

parameter ⁠p⁠ to be passed to function VAR. It corresponds to the number of lags of the second VAR model. Defaults to 0.

conf

prescribed confidence level. It defaults to 0.95.

Details

⁠bc_test_cond⁠ calculates the test of Breitung and Candelon (2006) on the conditional Granger-causality of a time series ⁠x⁠ (effect variable) on a time series ⁠z⁠ (conditioning variable) respect to a time series ⁠y⁠ (cause variable). It requires package vars.

Value

⁠frequency⁠: frequencies used by Fast Fourier Transform.

⁠n⁠: time series length.

⁠confidence_level⁠: prescribed confidence level.

⁠significant_frequencies⁠: frequencies at which the test is significant..

⁠F-test⁠: computed F-test at each frequency.

⁠F-threshold⁠: F-threshold at each frequency under prescribed confidence level.

⁠roots⁠: roots of the estimated VAR model.

⁠delays⁠: delays of the estimated VAR model.

The result is returned invisibly if plot is TRUE.

Author(s)

Matteo Farne', Angela Montanari, [email protected]

References

Breitung, J., Candelon, B., 2006. Testing for short- and long-run causality: A frequency-domain approach. Journal of Econometrics. 132, 2, 363–378.

Farne', M., Montanari, A., 2018. A bootstrap test to detect prominent Granger-causalities across frequencies. <arXiv:1803.00374>, Submitted.

See Also

VAR.

Examples

RealGdp.rate.ts<-euro_area_indicators[,1]
	m3.rate.ts<-euro_area_indicators[,2]
	hicp.rate.ts<-euro_area_indicators[,4]	
	cond_bc<-bc_test_cond(RealGdp.rate.ts,m3.rate.ts,hicp.rate.ts,ic.chosen="SC",max.lag=2)

Unconditional Granger-causality test of Breitung and Candelon (2006)

Description

Inference on the unconditional Granger-causality spectrum is provided by the parametric test of Breitung and Candelon (2006).

Usage

bc_test_uncond(x, y, ic.chosen = "SC", max.lag = min(4, length(x) - 1),
  plot = F, type.chosen = "none", p = 0, conf = 0.95)

Arguments

x

univariate time series.

y

univariate time series (of the same length of ⁠x⁠).

ic.chosen

estimation method parameter ⁠ic⁠ to be passed to function VAR of package vars. Defaults to ”SC” (Schwarz criterion). Alternatives are ⁠c(''AIC'',''HQ'',''SC'',''FPE'')⁠.

max.lag

maximum number of lags ⁠lag.max⁠ to be passed to function VAR. Defaults to ⁠min(4, length(x) - 1)⁠.

plot

logical; if TRUE, it returns the plot of conditional Granger-causality spectrum. Defaults to FALSE.

type.chosen

parameter ⁠type⁠ to be passed to function VAR.

p

parameter ⁠p⁠ to be passed to function VAR. It corresponds to the number of lags of the second VAR model. Defaults to 0.

conf

prescribed confidence level. It defaults to 0.95.

Details

⁠bc_test_uncond⁠ calculates the test of Breitung and Candelon (2006) on the unconditional Granger-causality of a time series ⁠x⁠ (effect variable) respect to a time series ⁠y⁠ (cause variable). It requireNamespaces package vars.

Value

⁠frequency⁠: frequencies used by Fast Fourier Transform.

⁠n⁠: time series length.

⁠confidence_level⁠: prescribed confidence level.

⁠significant_frequencies⁠: frequencies at which the test is significant..

⁠F-test⁠: computed F-test at each frequency.

⁠F-threshold⁠: F-threshold at each frequency under prescribed confidence level.

⁠roots⁠: roots of the estimated VAR model.

⁠delays⁠: delays of the estimated VAR model.

The result is returned invisibly if plot is TRUE.

Author(s)

Matteo Farne', Angela Montanari, [email protected]

References

Breitung, J., Candelon, B., 2006. Testing for short- and long-run causality: A frequency-domain approach. Journal of Econometrics. 132, 2, 363–378.

Farne', M., Montanari, A., 2018. A bootstrap test to detect prominent Granger-causalities across frequencies. <arXiv:1803.00374>, Submitted.

See Also

VAR.

Examples

RealGdp.rate.ts<-euro_area_indicators[,1]
m3.rate.ts<-euro_area_indicators[,2]
	uncond_bc<-bc_test_uncond(RealGdp.rate.ts,m3.rate.ts,ic.chosen="SC",max.lag=2)

Six Euro Area Monetary Indicators

Description

This data set gives thre quarterly time series of real gross domestic product, M3 aggregate, M1 aggregate, inflation rate (HICP), unemployment rate and long-term interest rate for the Euro Area from Q1,1999 to Q4,2017, according to the ECB Real Time DataBase (RTDB).

Usage

euro_area_indicators

Format

A matrix containing as columns six quarterly time series ranging from Q1,1999 to Q4,2017.

Details

Documentation of the dataset 'euro_area_indicators'

Source

ECB Real Time DataBase 'https://sdw.ecb.europa.eu/browse.do?node=9689716'.

References

Farne', M., Montanari, A., 2018. A bootstrap test to detect prominent Granger-causalities across frequencies. <arXiv:1803.00374>, Submitted.

Euro Area Real Time Database documentation. 'http://sdw.ecb.europa.eu/web/docu/rtdb_docu.pdf'


Conditional Granger-causality estimation

Description

Conditional Granger-causality spectrum was first defined in Geweke (1984). It measures the strength of the causal link from time series ⁠y⁠ to time series ⁠x⁠ once removed the mediating effect of ⁠z⁠ in the frequency domain. Differently from function Granger.unconditional, this function provides only the unidirectional causality from ⁠y⁠ to ⁠x⁠. Here we need to estimate two VAR models: the first on ⁠x⁠ and ⁠z⁠, the second on ⁠x⁠, ⁠y⁠, ⁠z⁠, by package vars. Parameters specified for function VAR hold for both estimations. For computational details we refer to Ding et al. (2006).

Usage

Granger.conditional(x, y, z, ic.chosen = "SC", max.lag = min(4,
  length(x) - 1), plot = F, type.chosen = "none", p1 = 0, p2 = 0)

Arguments

x

univariate time series.

y

univariate time series (of the same length of ⁠x⁠).

z

univariate time series (of the same length of ⁠x⁠).

ic.chosen

estimation method parameter ⁠ic⁠ to be passed to function VAR of package vars. Defaults to ”SC” (Schwarz criterion). Alternatives are ⁠c(''AIC'',''HQ'',''SC'',''FPE'')⁠.

max.lag

maximum number of lags ⁠lag.max⁠ to be passed to function VAR. Defaults to ⁠min(4, length(x) - 1)⁠.

plot

logical; if TRUE, it returns the plot of conditional Granger-causality spectrum. Defaults to FALSE.

type.chosen

parameter ⁠type⁠ to be passed to function VAR. Defaults to ⁠''none''⁠. Alternatives are ⁠c(''none'',''const'',''trend'')⁠.

p1

parameter ⁠p⁠ to be passed to function VAR. It corresponds to the number of lags of the first VAR model. Defaults to 0.

p2

parameter ⁠p⁠ to be passed to function VAR. It corresponds to the number of lags of the second VAR model. Defaults to 0.

Details

⁠Granger.conditional⁠ calculates the Granger-causality conditional spectrum of a time series ⁠x⁠ (effect variable) on a time series ⁠z⁠ (conditioning variable) respect to a time series ⁠y⁠ (cause variable). It requireNamespaces package vars.

Value

⁠frequency⁠: frequencies used by Fast Fourier Transform.

⁠n⁠: time series length.

⁠Conditional_causality_y.to.x.on.z⁠: computed conditional Granger-causality from ⁠y⁠ to ⁠x⁠ on ⁠z⁠.

⁠roots_1⁠: the roots of the estimated VAR on ⁠x⁠ and ⁠y⁠.

⁠roots_2⁠: the roots of the estimated VAR on ⁠x⁠, ⁠y⁠ and ⁠z⁠.

The result is returned invisibly if plot is TRUE.

Author(s)

Matteo Farne', [email protected]

References

Geweke J., 1984. Measures of conditional linear dependence and feedback between time series. J. Am. Stat. Assoc. 79, 907–915.

Ding, M., Chen, Y., Bressler, S.L., 2006. Granger Causality: Basic Theory and Application to Neuroscience, Chap.17. Handbook of Time Series Analysis Recent Theoretical Developments and Applications.

Farne', M., Montanari, A., 2018. A bootstrap test to detect prominent Granger-causalities across frequencies. <arXiv:1803.00374>, Submitted.

See Also

VAR.

Examples

RealGdp.rate.ts<-euro_area_indicators[,1]
	m3.rate.ts<-euro_area_indicators[,2]
	hicp.rate.ts<-euro_area_indicators[,4]
	cond_m3.to.gdp.by.hicp<-
Granger.conditional(RealGdp.rate.ts,m3.rate.ts,hicp.rate.ts,"SC",4)

Inference on conditional Granger-causality

Description

Inference on the conditional Granger-causality spectrum is provided generating bootstrap time series by the stationary boostrap of Politis and Romano (1994). For computational details we refer to Ding et al. (2006) and Farne' and Montanari (2018).

Usage

Granger.inference.conditional(x, y, z, ic.chosen = "SC",
  max.lag = min(4, length(x) - 1), plot = F, type.chosen = "none",
  p1 = 0, p2 = 0, nboots = 1000, conf = 0.95, bp = NULL,
  ts_boot = 1)

Arguments

x

univariate time series.

y

univariate time series (of the same length of ⁠x⁠).

z

univariate time series (of the same length of ⁠x⁠).

ic.chosen

estimation method parameter ⁠ic⁠ to be passed to function VAR of package vars. Defaults to ”SC” (Schwarz criterion). Alternatives are ⁠c(''AIC'',''HQ'',''SC'',''FPE'')⁠.

max.lag

maximum number of lags ⁠lag.max⁠ to be passed to function VAR. Defaults to ⁠min(4, length(x) - 1)⁠.

plot

logical; if TRUE, it returns the plot of unconditional Granger-causality spectra on both directions with computed thresholds. Defaults to FALSE.

type.chosen

parameter ⁠type⁠ to be passed to function VAR. Defaults to ⁠''none''⁠. Alternatives are ⁠c(''none'',''const'',''trend'')⁠.

p1

parameter ⁠p⁠ to be passed to function VAR. It corresponds to the number of lags of the first VAR model. Defaults to 0.

p2

parameter ⁠p⁠ to be passed to function VAR. It corresponds to the number of lags of the second VAR model. Defaults to 0.

nboots

number of bootstrap series to be computed by function tsbootstrap of package tseries. It defaults to 1000.

conf

prescribed confidence level. It defaults to 0.95.

bp

matrix containing previously simulated bootstrap series, having as rows time points, as columns variables ⁠x⁠ and ⁠y⁠ (in this order). It defaults to NULL.

ts_boot

boolean equal to 1 if the stationary bootstrap of Politis and Romano (1994) is applied, 0 otherwise. It defaults to 1.

Details

⁠Granger.inference.conditional⁠ provides bootstrap inference for the Granger-causality conditional spectrum of a time series ⁠x⁠ (effect variable) on a time series ⁠z⁠ (conditioning variable) respect to a time series ⁠y⁠ (cause variable). It requires packages vars and tseries.

Value

⁠frequency⁠: frequencies used by Fast Fourier Transform.

⁠n⁠: time series length.

⁠nboots⁠: number of bootstrap series used.

⁠confidence_level⁠: prescribed confidence level.

⁠stat_yes⁠: boolean equal to 0 if no stationary VAR is estimated across bootstrap samples, 1 otherwise.

⁠non_stationarity_rate_1⁠: percentage of non-stationary VAR models (at least one root larger than one) estimated on bootstrapped ⁠x⁠ and ⁠z⁠.

⁠non_stationarity_rate_2⁠: percentage of non-stationary VAR models (at least one root larger than one) estimated on bootstrapped ⁠x⁠ and ⁠y⁠ and ⁠z⁠.

⁠delay1_mean⁠: mean number of delays of stationary VAR models estimated on ⁠x⁠ and ⁠z⁠.

⁠delay2_mean⁠: mean number of delays of stationary VAR models estimated on ⁠x⁠ and ⁠y⁠ and ⁠z⁠.

⁠quantile_conditional_causality_y.to.x.on.z⁠: computed quantile of the Granger- causality conditional spectrum from ⁠y⁠ to ⁠x⁠ on ⁠z⁠. Differently from function Granger.inference.unconditional, this function provides only the quantile of the unidirectional causality from ⁠y⁠ to ⁠x⁠.

⁠freq_y.to.x.on.z⁠: frequencies at which the Granger-causality conditional spectrum from ⁠y⁠ to ⁠x⁠ condtional on ⁠z⁠ exceeds the computed threshold.

⁠q_max_x.on.z⁠: computed quantile of the Granger- causality conditional spectrum from ⁠y⁠ to ⁠x⁠ on ⁠z⁠ under Bonferroni correction. Differently from function Granger.inference.unconditional, this function provides only the quantile of the unidirectional causality from ⁠y⁠ to ⁠x⁠.

⁠freq_max_y.to.x.on.z⁠: frequencies at which the Granger-causality conditional spectrum from ⁠y⁠ to ⁠x⁠ conditional on ⁠z⁠ exceeds the computed threshold under Bonferroni correction.

The result is returned invisibly if plot is TRUE.

Author(s)

Matteo Farne', Angela Montanari, [email protected]

References

Politis D. N. and Romano J. P., (1994). ”The Stationary Bootstrap”. Journal of the American Statistical Association, 89, 1303–1313.

Ding, M., Chen, Y., Bressler, S.L., 2006. Granger Causality: Basic Theory and Application to Neuroscience, Chap.17. Handbook of Time Series Analysis Recent Theoretical Developments and Applications.

Farne', M., Montanari, A., 2018. A bootstrap test to detect prominent Granger-causalities across frequencies. <arXiv:1803.00374>, Submitted.

See Also

VAR and tsbootstrap.

Examples

RealGdp.rate.ts<-euro_area_indicators[,1]
m3.rate.ts<-euro_area_indicators[,2]
hicp.rate.ts<-euro_area_indicators[,4]
	inf_cond_m3.to.gdp.by.hicp_0.95<-
Granger.inference.conditional(RealGdp.rate.ts,m3.rate.ts,hicp.rate.ts,nboots=10)

Inference on unconditional Granger-causality

Description

Inference on the unconditional Granger-causality spectrum is provided generating bootstrap time series by the stationary boostrap of Politis and Romano (1994). For computational details we refer to Ding et al. (2006) and Farne' and Montanari (2018).

Usage

Granger.inference.unconditional(x, y, ic.chosen = "SC",
  max.lag = min(4, length(x) - 1), plot = F, type.chosen = "none",
  p = 0, nboots = 1000, conf = 0.95, bp = NULL, ts_boot = 1)

Arguments

x

univariate time series.

y

univariate time series (of the same length of ⁠x⁠).

ic.chosen

estimation method parameter ⁠ic⁠ to be passed to function VAR of package vars. Defaults to ”SC” (Schwarz criterion). Alternatives are ⁠c(''AIC'',''HQ'',''SC'',''FPE'')⁠.

max.lag

maximum number of lags ⁠lag.max⁠ to be passed to function VAR. Defaults to ⁠min(4, length(x) - 1)⁠.

plot

logical; if TRUE, it returns the plot of unconditional Granger-causality spectra on both directions with computed thresholds. Defaults to FALSE.

type.chosen

parameter ⁠type⁠ to be passed to function VAR. Defaults to ⁠''none''⁠. Alternatives are ⁠c(''none'',''const'',''trend'')⁠.

p

parameter ⁠p⁠ to be passed to function VAR. Defaults to 0.

nboots

number of bootstrap series to be computed by function tsbootstrap of package tseries. It defaults to 1000.

conf

prescribed confidence level. It defaults to 0.95.

bp

matrix containing previously simulated bootstrap series, having as rows time points, as columns variables ⁠x⁠ and ⁠y⁠ (in this order). It defaults to NULL.

ts_boot

boolean equal to 1 if the stationary bootstrap of Politis and Romano (1994) is applied, 0 otherwise. It defaults to 1.

Details

⁠Granger.inference.unconditional⁠ provides bootstrap inference for the Granger-causality unconditional spectrum of a time series ⁠x⁠ (effect variable) respect to a time series ⁠y⁠ (cause variable). It requires packages vars and tseries.

Value

⁠frequency⁠: frequencies used by Fast Fourier Transform.

⁠n⁠: time series length.

⁠nboots⁠: number of bootstrap series used.

⁠confidence_level⁠: prescribed confidence level.

⁠stat_yes⁠: boolean equal to 0 if no stationary VAR is estimated across bootstrap samples, 1 otherwise.

⁠non_stationarity_rate⁠: percentage of non-stationary VAR models (at least one root larger than one) estimated on bootstrapped ⁠x⁠ and ⁠y⁠.

⁠delay_mean⁠: mean number of delays of stationary VAR models estimated on ⁠x⁠ and ⁠y⁠.

⁠quantile_unconditional_causality_y.to.x⁠: computed quantile of the Granger-causality unconditional spectrum from ⁠y⁠ to ⁠x⁠.

⁠quantile_unconditional_causality_x.to.y⁠: computed quantile of the Granger-causality unconditional spectrum from ⁠x⁠ to ⁠y⁠.

⁠freq_y.to.x⁠: frequencies at which the Granger-causality unconditional spectrum from ⁠y⁠ to ⁠x⁠ exceeds the computed threshold.

⁠freq_x.to.y⁠: frequencies at which the Granger-causality unconditional spectrum from ⁠x⁠ to ⁠y⁠ exceeds the computed threshold.

⁠q_max_x⁠: computed quantile of the Granger-causality unconditional spectrum from ⁠y⁠ to ⁠x⁠ under Bonferroni correction.

⁠q_max_y⁠: computed quantile of the Granger-causality unconditional spectrum from ⁠x⁠ to ⁠y⁠ under Bonferroni correction.

⁠freq_max_y.to.x⁠: frequencies at which the Granger-causality unconditional spectrum from ⁠y⁠ to ⁠x⁠ exceeds the computed threshold under Bonferroni correction.

⁠freq_max_x.to.y⁠: frequencies at which the Granger-causality unconditional spectrum from ⁠x⁠ to ⁠y⁠ exceeds the computed threshold under Bonferroni correction.

The result is returned invisibly if plot is TRUE.

Author(s)

Matteo Farne', Angela Montanari, [email protected]

References

Politis D. N. and Romano J. P., (1994). ”The Stationary Bootstrap”. Journal of the American Statistical Association, 89, 1303–1313.

Ding, M., Chen, Y., Bressler, S.L., 2006. Granger Causality: Basic Theory and Application to Neuroscience, Chap.17. Handbook of Time Series Analysis Recent Theoretical Developments and Applications.

Farne', M., Montanari, A., 2018. A bootstrap test to detect prominent Granger-causalities across frequencies. <arXiv:1803.00374>, Submitted.

See Also

VAR and tsbootstrap.

Examples

RealGdp.rate.ts<-euro_area_indicators[,1]
m3.rate.ts<-euro_area_indicators[,2]
	inf_uncond_m3_0.95<-Granger.inference.unconditional(RealGdp.rate.ts,m3.rate.ts,nboots=10)

Unconditional Granger-causality estimation

Description

Unconditional Granger-causality spectrum was first defined in Geweke (1982). It measures the strength of the causal link from time series ⁠y⁠ to time series ⁠x⁠ and viceversa in the frequency domain. It needs to estimate a VAR model on ⁠x⁠ and ⁠y⁠ by package vars. For computational details we refer to Ding et al. (2006).

Usage

Granger.unconditional(x, y, ic.chosen = "SC", max.lag = min(4,
  length(x) - 1), plot = F, type.chosen = "none", p = 0)

Arguments

x

univariate time series.

y

univariate time series (of the same length of ⁠x⁠).

ic.chosen

estimation method parameter ⁠ic⁠ to be passed to function VAR of package vars. Defaults to ”SC” (Schwarz criterion). Alternatives are ⁠c(''AIC'',''HQ'',''SC'',''FPE'')⁠.

max.lag

maximum number of lags ⁠lag.max⁠ to be passed to function VAR. Defaults to ⁠min(4, length(x) - 1)⁠.

plot

logical; if TRUE, it returns the plot of unconditional Granger-causality spectra on both directions. Defaults to FALSE.

type.chosen

parameter ⁠type⁠ to be passed to function VAR. Defaults to ⁠''none''⁠. Alternatives are ⁠c(''none'',''const'',''trend'')⁠.

p

parameter ⁠p⁠ to be passed to function VAR. Defaults to 0.

Details

⁠Granger.unconditional⁠ calculates the Granger-causality unconditional spectrum of a time series ⁠x⁠ (effect variable) respect to a time series ⁠y⁠ (cause variable). It requireNamespaces package vars.

Value

⁠frequency⁠: frequencies used by Fast Fourier Transform.

⁠n⁠: time series length.

⁠Unconditional_causality_y.to.x⁠: computed unconditional Granger-causality from ⁠y⁠ to ⁠x⁠.

⁠Unconditional_causality_x.to.y⁠: computed unconditional Granger-causality from ⁠x⁠ to ⁠y⁠.

⁠roots⁠: the roots of the estimated VAR on ⁠x⁠ and ⁠y⁠.

The result is returned invisibly if plot is TRUE.

Author(s)

Matteo Farne', Angela Montanari, [email protected]

References

Geweke, J., 1982. Measurement of linear dependence and feedback between multiple time series. J. Am. Stat. Assoc. 77, 304–313.

Ding, M., Chen, Y., Bressler, S.L., 2006. Granger Causality: Basic Theory and Application to Neuroscience, Chap.17. Handbook of Time Series Analysis Recent Theoretical Developments and Applications.

Farne', M., Montanari, A., 2018. A bootstrap test to detect prominent Granger-causalities across frequencies. <arXiv:1803.00374>, Submitted.

See Also

VAR.

Examples

RealGdp.rate.ts<-euro_area_indicators[,1]
m3.rate.ts<-euro_area_indicators[,2]
uncond_m3<-Granger.unconditional(RealGdp.rate.ts,m3.rate.ts,"SC",4)