causal-learn
causal-learn copied to clipboard
how to interpret the output of the ganger_lasso
Hi, thanks for the great work.
I am currently experimenting with the granger_lasso algorithm provided in the repository.
Given that one time series has N dimensions, and the time lag is equal to T. The shape of the output of granger_lasso is [N, N * T].
May I know how I should interpret this and convert it into a [T, N, N] matrix where, along the time lag dimension, the matrix [N, N] represents the influence of the i-th node on the j-th node.
Thank you!
Hi, maybe something as follows could be helpful:
reshaped_coeff = np.zeros((T, N, N))
for t in range(T):
block = coeff[:, N*t:N*(t+1)]
reshaped_coeff[t] = block
Thank you for the prompt reply.
I have one more thing to clarify. In the implementation, it says:
The ij-th entry in A_k represents the causal influence from the j-th variable to the i-th variable.
Should I expect the same for the reshaped matrix?
Thank you!
it should be guaranteed if you use the code provided by kunwz. You can also check whether the t-th NxN matrix is the same as coeff[:, Nt:N(t+1)].