causal-learn icon indicating copy to clipboard operation
causal-learn copied to clipboard

how to interpret the output of the ganger_lasso

Open cunjunyu opened this issue 1 year ago • 3 comments

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!

cunjunyu avatar Oct 14 '23 07:10 cunjunyu

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

kunwuz avatar Oct 16 '23 03:10 kunwuz

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!

cunjunyu avatar Oct 16 '23 03:10 cunjunyu

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)].

mingming-gong avatar Dec 12 '23 23:12 mingming-gong