GrangerFunc is a Granger Causality function. It tests whether X
Granger-causes Y
.
GrangerFunc(
Y,
X,
maxLag = 1,
alpha = 0.05,
autoLagflag = TRUE,
gamma = 0.5,
family = gaussian
)
This function returns of whether X
Granger-causes Y
.
F-statistic of Granger causality.
A p-value from F-test.
Bayesian Information Criterion (BIC) derived from Y
regressing on Y
past.
Bayesian Information Criterion (BIC) derived from Y
regressing on Y
,X
past.
The flag is true if X
Granger-causes Y
using BIC difference ratio where BICDiffRatio >= gamma
.
The flag is true if X
Granger-causes Y
using F-test where p.val>=alpha
.
The flag is true if X
Granger-causes Y
using BIC where BIC_H0>=BIC_H1
.
A maximum possible time delay.
glm object of Y
regressing on Y
past.
glm object of Y
regressing on Y,X
past.
Bayesian Information Criterion difference ratio: (BIC_H0-BIC_H1)/BIC_H0
.
is a numerical time series of effect
is a numerical time series of cause
is a maximum possible time delay. The default is 1.
is a significance level of F-test to determine whether X
Granger-causes Y
. The default is 0.05.
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.
is a parameter to determine whether X
Granger-causes Y
using BIC difference ratio.
is a parameter of family of function for Generalized Linear Models function (glm). The default is gaussian
.
# Generate simulation data
TS <- SimpleSimulationVLtimeseries()
# Run the function
out<-GrangerFunc(Y=TS$Y,X=TS$X)
Run the code above in your browser using DataLab