How to use the tigramite.independence_tests.ParCorr function in tigramite

To help you get started, we’ve selected a few tigramite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jakobrunge / tigramite / tests / test_pcmci_calculations.py View on Github external
def a_test(request):
    return ParCorr(verbosity=VERBOSITY)
github jakobrunge / tigramite / tests / test_models.py View on Github external
def test_predictions(data_frame_a):
    # TODO NOTE: This doesn't actually test if the predictions make sense, only 
    # that they work!
    # Get the data
    (dataframe, true_parents), links_coeffs = data_frame_a
    T, _ = dataframe.values.shape
    # Build the prediction
    a_cond_ind_test = ParCorr(significance='analytic',
                              fixed_thres=0.01)
    pred = Prediction(dataframe=dataframe,
                      cond_ind_test=a_cond_ind_test,
                      prediction_model=sklearn.linear_model.LinearRegression(),
                      train_indices=range(int(0.8*T)),
                      test_indices=range(int(0.8*T), T),
                      verbosity=0)
    # Load some parameters
    tau_max = 3
    steps_ahead = 0
    target = 2
    # Get the predictors from pc_stable
    all_predictors = pred.get_predictors(selected_targets=[target],
                                         selected_links=None,
                                         steps_ahead=steps_ahead,
                                         tau_max=tau_max,
github jakobrunge / tigramite / tests / test_pcmci_construction.py View on Github external
def a_pcmci(a_sample, request):
    # Unpack the test data and true parent graph
    dataframe, true_parents = a_sample
    # Build the PCMCI instance
    pcmci = PCMCI(selected_variables=None,
                  dataframe=dataframe,
                  cond_ind_test=ParCorr(verbosity=VERBOSITY),
                  verbosity=VERBOSITY)
    # Return the constructed PCMCI, expected results, and common parameters
    return pcmci, true_parents
github jakobrunge / tigramite / tests / test_tigramite_independence_tests.py View on Github external
def setUp(self):

       auto = 0.6
       coeff = 0.6
       T = 1000
       numpy.random.seed(42)
       # True graph
       links_coeffs = {0: [((0, -1), auto)],
                       1: [((1, -1), auto), ((0, -1), coeff)],
                       2: [((2, -1), auto), ((1, -1), coeff)]
                       }

       self.data, self.true_parents_coeffs = pp.var_process(links_coeffs, T=T)
       T, N = self.data.shape 

       self.ci_par_corr = ParCorr(use_mask=False,
                           mask_type=None,
                           significance='analytic',
                           fixed_thres=None,
                           sig_samples=10000,
                           sig_blocklength=3,

                           confidence='analytic',
                           conf_lev=0.9,
                           conf_samples=10000,
                           conf_blocklength=1,

                           recycle_residuals=False,
                           verbosity=0)


       self.ci_gpdc = GPDC(
github jakobrunge / tigramite / tests / test_independence_tests.py View on Github external
def par_corr(request):
    # Unpack the parameters
    sig, recycle, conf = request.param
    # Generate the par_corr independence test
    return ParCorr(mask_type=None,
                   significance=sig,
                   fixed_thres=0.1,
                   sig_samples=10000,
                   sig_blocklength=3,
                   confidence=conf,
                   conf_lev=0.9,
                   conf_samples=10000,
                   conf_blocklength=1,
                   recycle_residuals=recycle,
                   verbosity=0)
github jakobrunge / tigramite / run_pcmci_parallel.py View on Github external
# Maximum number of parents of X to condition on in MCI step, leave this to None
# to condition on all estimated parents.
max_conds_px = None

# Selected links may be used to restricted estimation to given links.
selected_links = None

# Alpha level for MCI tests (just used for printing since all p-values are 
# stored anyway)
alpha_level = 0.05

# Verbosity level. Note that slaves will ouput on top of each other.
verbosity = 0

# Chosen conditional independence test
cond_ind_test = ParCorr()  #confidence='analytic')

# Store results in file
file_name = os.path.expanduser('~') + '/test_results.dat'


#
#  Start of the script
#
if COMM.rank == 0:
    # Only the master node (rank=0) runs this
    if verbosity > -1:
        print("\n##\n## Running Parallelized Tigramite PC algorithm\n##"
              "\n\nParameters:")
        print("\nindependence test = %s" % cond_ind_test.measure
              + "\ntau_min = %d" % tau_min
              + "\ntau_max = %d" % tau_max