Python package for Granger causality test with nonlinear forecasting methods.
Project description
# Nonlincausality Python package for Granger causality test with nonlinear forecasting methods.
Contact: mrosol5@gmail.com
This package contains two types of functions.
The first type is an implementation of a modified Granger causality test based on grangercausalitytests function from statsmodels.tsa.stattools. As a Granger causality test is using linear regression for prediction it may not capture more complex causality relations. The first type of presented functions are using nonlinear forecasting methods (using recurrent neural networks or ARMIAX models) for prediction instead of linear regression. For each tested lag this function is creating 2 models. The first one is forecasting the present value of X based on n=current lag past values of X, while the second model is forecasting the same value based on n=current lag past values of X and Y time series. If the prediction error of the second model is statistically significantly smaller than the error of the first model than it means that Y is G-causing X (Y->X). It is also possible to test conditional causality using those functions. The functions based on neural networks can test the causality on the given test set. The first type of function contains: nonlincausalityLSTM(), nonlincausalityGRU(), nonlincausalityNN() and nonlincausalityARIMAX().
The second type of functions is for measuring the change of causality during time. Those functions are using first type functions to create the forecasting models. They calculate the measure of the causality in a given time window ‘w1’ with a given step ‘w2’. The measure of change of the causality during time is the sigmoid function of quotient of errors - 2/(1 + exp(-((RMSE_X/RMSE_XY)-1)))-1. Also the measure of the causality of the whole signal was applied as the logarithm of quotient of variances of errors - ln(var(error_X)/var(error_XY)). Those functions can operate with multiple time series and test causal relations for each pair of signals. The second type of function contains: nonlincausalitymeasureLSTM(), nonlincausalitymeasureGRU(), nonlincausalitymeasureNN() and nonlincausalitymeasureARIMAX().
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for nonlincausality-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5389f27889a7b0466feb7e5952a24e1fd5efd352a40d21fdfc725e514c420f7b |
|
MD5 | 17736c72f8107eb9caa7e9345198af4c |
|
BLAKE2b-256 | 11f49c43fd71229345ea5402e3f81e0bf5c3164229af5457a1c6deb6fcefb1f6 |