Linear granger causality
from causallearn.search.Granger.Granger import Granger G = Granger() p_value_matrix = G.granger_test_2d(data) coeff = G.granger_lasso(data)
data: numpy.ndarray, shape (n_samples, n_features). Data, where n_samples is the number of samples and n_features is the number of features. Note that for granger_test_2d(), the shape of input data is (n_samples, 2).
p_value_matrix: p values for x1->x2 and x2->x1 (for ‘granger_test_2d’, which is the granger causality test for two-dimensional time series).
coeff: coefficient matrix (for ‘granger_lasso’, which is the granger causality test for multi-dimensional time series).