Use case

Here, we have a multivariate time series dataset called AirQualityUCI. We have to test whether NOx has a Granger causality of NO2.

Since we don't have a library in Python for multivariate Granger causality, we will do this in R by using the lmtest package.

Load the lmtest library. In case the library isn't there, you will need to install it, as follows:

install.packages("lmtest")
library(lmtest)

Load the data. Then, make use of the grangertest function to find out whether there is any significant relationship between NOx and NO2:

data= read.csv("AirQualityUCI.csv")
grangertest(NOx.GT. ~ NO2.GT., order = 3, data = data)

The output for this is as follows:

So, the f-test has become significant, which means that the coefficients of lagged NO2 have a significant impact on NOx.