jakobrunge/tigramite

link assumptions in run_mci

lcastri opened this issue · 1 comments

Hi,

I have a doubt on how to define the link_assumptions for the _run_mci_or_variants method in the PCMCI.
In the documentation it is written that the link_assumptions field should be define as:
link_assumptions (dict or None) – Dictionary of form {j:{(i, -tau): link_type, …}, …}

so I defined my link_assumptions as follows:
link_assumptions = {0: {(0, -1): '-?>', (1, -1): '-?>', (2, -1): '-?>', (5, -1): '-->'}, 1: {(4, -1): '-->'}, 2: {(1, -1): '-?>', (3, -1): '-->'}, 3: {}, 4: {}, 5: {}}

by using the method as it is, the condition if ((i, -tau) in _int_link_assumptions[j] and _int_link_assumptions[j][(i, -tau)] in ['-->', 'o-o']) is never satisfied because of the -tau

if val_only is False:
    # Run the independence tests and record the results
    if ((i, -tau) in _int_link_assumptions[j] 
       and _int_link_assumptions[j][(i, -tau)] in ['-->', 'o-o']):
       val = 1. 
       pval = 0.
    else:
       val, pval = self.cond_ind_test.run_test(X, Y, Z=Z,
                                                        tau_max=tau_max,
                                                        # verbosity=
                                                        # self.verbosity
                                                        )
       val_matrix[i, j, abs(tau)] = val
       p_matrix[i, j, abs(tau)] = pval

In order to make it work, I removed the minus sign from the -tau as follows:

if val_only is False:
    # Run the independence tests and record the results
    if ((i, tau) in _int_link_assumptions[j] 
       and _int_link_assumptions[j][(i, tau)] in ['-->', 'o-o']):
       val = 1. 
       pval = 0.
    else:
       val, pval = self.cond_ind_test.run_test(X, Y, Z=Z,
                                                        tau_max=tau_max,
                                                        # verbosity=
                                                        # self.verbosity
                                                        )
       val_matrix[i, j, abs(tau)] = val
       p_matrix[i, j, abs(tau)] = pval

Am I defining the link_assumptions in the wrong way? If I define the link_assumptions without the minus sign, does the rest of the PCMCI work?

Thank you in advance

That seems to be a bug! I just fixed it in the master, can you check?