The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
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[@]dogado.de.
A framework to infer causality on a pair of time series of real numbers based on Variable-lag Granger causality (VL-Granger) and transfer entropy (VL-Transfer Entropy).
Typically, Granger causality and transfer entropy have an assumption of a fixed and constant time delay between the cause and effect. However, for a non-stationary time series, this assumption is not true. For example, considering two time series of velocity of person A and person B where B follows A. At some time, B stops tying his shoes, then running to catch up A. The fixed-lag assumption is not true in this case.
We propose a framework that allows variable-lags between cause and effect in Granger causality and transfer entropy to allow them to deal with variable-lag non-stationary time series.
You can install our package from CRAN
install.packages("VLTimeCausality")
For the newest version on github, please call the following command in R terminal.
::install_github("DarkEyes/VLTimeSeriesCausality") remotes
This requires a user to install the “remotes” package before installing VLTimeSeriesCausality.
In the first step, we generate time series TS\(X and TS\)Y where TS\(X causes TS\)Y with variable-lags.
library(VLTimeCausality)
# Generate simulation data
<- VLTimeCausality::SimpleSimulationVLtimeseries() TS
We can plot time series using the following function.
::plotTimeSeries(TS$X,TS$Y) VLTimeCausality
A sample of generated time series pair that has a causal relation is plotted below:
We use the following function to infer whether X causes Y.
# Run the function
<-VLTimeCausality::VLGrangerFunc(Y=TS$Y,X=TS$X) out
The result of VL-Granger causality is below:
$BICDiffRatio
out1] 0.8882051
[
$XgCsY
out1] TRUE [
If out\(XgCsY is true, then it means that X VL-Granger-causes Y. The value out\)BICDiffRatio is a BIC difference ratio. If out\(BICDiffRatio>0, it means that X is a good predictor of Y behaviors. The closer out\)BICDiffRatio to 1, the stronger we can claim that X VL-Granger-causes Y.
For the comparison between normal Granger test with our VL-Granger test, we recommend to use the F-test decision criterion the same as typical Granger test criterion.
Below are the results of VL-Granger Causality using F-test.
library(lmtest)
data(ChickEgg)
<- as.data.frame(ChickEgg)
ChickEgg
#============ The the egg causes chicken.
<- VLTimeCausality::VLGrangerFunc(X=ChickEgg$egg,Y=ChickEgg$chicken)
out_test1 $p.val
out_test11] 0.004980847
[$XgCsY_ftest
out_test11] TRUE
[
#============ The reverse direction has no causal relation
<- VLTimeCausality::VLGrangerFunc(Y=ChickEgg$egg,X=ChickEgg$chicken)
out_test2 $p.val
out_test21] 1
[$XgCsY_ftest
out_test21] FALSE [
Chainarong Amornbunchornvej, Elena Zheleva, and Tanya Berger-Wolf (2021). Variable-lag Granger Causality and Transfer Entropy for Time Series Analysis. ACM Transactions on Knowledge Discovery from Data (TKDD), 15(4), 1-30. https://doi.org/10.1145/3441452
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.
Health stats visible at Monitor.