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.

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.

In the first step, we generate time series TS$X and TS$Y where TS$X causes TS$Y with variable-lags.

```
library(VLTimeSeriesCausality)
# 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 Granger causality is below:

```
out$BICDiffRatio
[1] 0.8882051
out$XgCsY
[1] TRUE
```

Chainarong Amornbunchornvej, Elena Zheleva, and Tanya Berger-Wolf (2019). Variable-lag Granger Causality for Time Series Analysis. In Proceedings of the 6th IEEE International Conference on Data Science and Advanced Analytics (DSAA), pp. 21-30. IEEE. link

- Developer: C. Amornbunchornvej
- Strategic Analytics Networks with Machine Learning and AI (SAI), NECTEC, Thailand
- Homepage: Link

**Any scripts or data that you put into this service are public.**

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.