GrangerFunc: GrangerFunc

Description Usage Arguments Value Examples

View source: R/granger.R

Description

GrangerFunc is a Granger Causality function. It tests whether X Granger-causes Y.

Usage

1
2
3
4
5
6
7
8
9
GrangerFunc(
  Y,
  X,
  maxLag = 1,
  alpha = 0.05,
  autoLagflag = TRUE,
  gamma = 0.5,
  family = gaussian
)

Arguments

Y

is a numerical time series of effect

X

is a numerical time series of cause

maxLag

is a maximum possible time delay. The default is 1.

alpha

is a significance level of F-test to determine whether X Granger-causes Y. The default is 0.05.

autoLagflag

is a flag for enabling the automatic lag inference function. The default is true. If it is set to be true, then maxLag is set automatically using cross-correlation. Otherwise, if it is set to be false, then the function takes the maxLag value to infer Granger causality.

gamma

is a parameter to determine whether X Granger-causes Y using BIC difference ratio.

family

is a parameter of family of function for Generalized Linear Models function (glm). The default is gaussian.

Value

This function returns of whether X Granger-causes Y.

ftest

F-statistic of Granger causality.

p.val

A p-value from F-test.

BIC_H0

Bayesian Information Criterion (BIC) derived from Y regressing on Y past.

BIC_H1

Bayesian Information Criterion (BIC) derived from Y regressing on Y,X past.

XgCsY

The flag is true if X Granger-causes Y using BIC difference ratio where BICDiffRatio >= gamma.

XgCsY_ftest

The flag is true if X Granger-causes Y using F-test where p.val>=alpha.

XgCsY_BIC

The flag is true if X Granger-causes Y using BIC where BIC_H0>=BIC_H1.

maxLag

A maximum possible time delay.

H0

glm object of Y regressing on Y past.

H1

glm object of Y regressing on Y,X past.

BICDiffRatio

Bayesian Information Criterion difference ratio: (BIC_H0-BIC_H1)/BIC_H0.

Examples

1
2
3
4
# Generate simulation data
TS <- SimpleSimulationVLtimeseries()
# Run the function
out<-GrangerFunc(Y=TS$Y,X=TS$X)

VLTimeCausality documentation built on Jan. 24, 2022, 5:07 p.m.