def a_pcmciplus_order_independence(request): # Set the parameters links_coeffs, time, seed_val = request.param # Retrieve lags tau_min, tau_max = pp._get_minmax_lag(links_coeffs) # Generate the data data, _ = pp.structural_causal_process(links=links_coeffs, T=time, noises=None, seed=seed_val) # Get the true parents # true_parents = pp._get_parents(links_coeffs, exclude_contemp=False) true_graph = pp.links_to_graph(links_coeffs, tau_max=tau_max) return pp.DataFrame(data), true_graph, links_coeffs, tau_min, tau_max
if __name__ == '__main__': import tigramite.data_processing as pp np.random.seed(6) def lin_f(x): return x links = { 0: [((0, -1), 0.8, lin_f)], 1: [((1, -1), 0.8, lin_f), ((0, -1), 0.5, lin_f)], 2: [((2, -1), 0.8, lin_f), ((1, 0), -0.6, lin_f)] } # noises = [np.random.randn for j in links.keys()] data, nonstat = pp.structural_causal_process(links, T=10000) true_parents = pp._get_true_parent_neighbor_dict(links) dataframe = pp.DataFrame(data) med = Models(dataframe=dataframe, model=sklearn.linear_model.LinearRegression(), data_transform=None) # Fit the model med.get_fit(all_parents=true_parents, tau_max=3) print(med.get_val_matrix()) # for j, i, tau, coeff in pp._iter_coeffs(links): # print(i, j, tau, coeff, med.get_coeff(i=i, tau=tau, j=j)) # for causal_coeff in [med.get_ce(i=0, tau=-2, j=2),