bashtage / arch

ARCH models in Python
Other
1.34k stars 248 forks source link

The order of input data for engle_granger() function, what about the order of the cointegrating_vector? #628

Closed danbo6 closed 1 year ago

danbo6 commented 1 year ago

Hi, I found that the order of input data for engle_granger() matters. Say if I have two time series, data1 and data2. So when I call engle_granger(data1, data2) and engle_granger(data2, data1), the returning 'cointegrating_vector' is different. The first and second element from 'cointegrating_vector' are supposed to represent the weights in the final stationary time series. My question is, how to use this cointegrating_vector? Can I simply compare the p value of ngle_granger(data1, data2) and engle_granger(data2, data1) and use the result of 'cointegrating_vector' if its p value is smaller? And create a new stationary time series by new_data = cointegrating_vector[0] data1 + cointegrating_vector[1] data2? Will it be a case the result should be new_data = cointegrating_vector[1] data1 + cointegrating_vector[2] data2? Thnaks!

bashtage commented 1 year ago

It matters because it uses and OLS. The beta you get for y on x is different from x on y. This is a known limitation of EG, and is why many prefer Johansen which is invariant since it examines eigenvalues.

bashtage commented 1 year ago

Closing as answered