MyNixOS website logo
Description

Variable-Lag Time Series Causality Inference Framework.

A framework to infer causality on a pair of time series of real numbers based on variable-lag Granger causality and 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. Please see Chainarong Amornbunchornvej, Elena Zheleva, and Tanya Berger-Wolf (2021) <doi:10.1145/3441452> when referring to this package in publications.

VLTimeCausality: Variable-Lag Time Series Causality Inference Framework

Travis CI build status minimal R version CRAN Status Badge Download arXiv License

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.

Installation

You can install our package from CRAN

install.packages("VLTimeCausality")

For the newest version on github, please call the following command in R terminal.

remotes::install_github("DarkEyes/VLTimeSeriesCausality")

This requires a user to install the "remotes" package before installing VLTimeSeriesCausality.

Example: Inferred VL-Granger causality time series

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
TS <- VLTimeCausality::SimpleSimulationVLtimeseries()

We can plot time series using the following function.

VLTimeCausality::plotTimeSeries(TS$X,TS$Y)

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
out<-VLTimeCausality::VLGrangerFunc(Y=TS$Y,X=TS$X)

The result of VL-Granger causality is below:

out$BICDiffRatio
[1] 0.8882051

out$XgCsY
[1] 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)
ChickEgg <- as.data.frame(ChickEgg)

#============ The the egg causes chicken. 
out_test1 <- VLTimeCausality::VLGrangerFunc(X=ChickEgg$egg,Y=ChickEgg$chicken)
out_test1$p.val
[1] 0.004980847
out_test1$XgCsY_ftest
[1] TRUE 

#============ The reverse direction has no causal relation
out_test2 <- VLTimeCausality::VLGrangerFunc(Y=ChickEgg$egg,X=ChickEgg$chicken)
out_test2$p.val
[1] 1
out_test2$XgCsY_ftest
[1] FALSE

Citation

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

Contact

Metadata

Version

0.1.4

License

Unknown

Platforms (75)

    Darwin
    FreeBSD 13
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd13
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows