def fill_params_dict_list_dimensions(do_fast_mgc=False): mcorr = DCorr(which_test='unbiased') dcorr = DCorr(which_test='biased') mantel = DCorr(which_test='mantel') mgc = MGC() rv_corr = RVCorr(which_test='rv') hhg = HHG() cca = RVCorr(which_test='cca') mdmr = MDMR() independence_tests = [] # [mgc, mcorr, dcorr, mantel, rv_corr, cca] params_dict_list = [] for sim_name, sim_func in simulations.items(): for test in independence_tests: params_dict = { 'independence_test': test, 'simulation_type': sim_func[1], 'dim': find_dim(sim_name), 'additional_params': {} } params_dict_list.append(params_dict) if do_fast_mgc: fast_mgc = MGC() additional_params = {"is_fast": True} params_dict = { 'independence_test': fast_mgc, 'simulation_type': sim_func[1], 'dim': find_dim(sim_name), 'additional_params': additional_params } params_dict_list.append(params_dict) return params_dict_list
def fill_params_dict_list_sample_sizes(base_path, do_fast_mgc=False): mcorr = DCorr(which_test='unbiased') dcorr = DCorr(which_test='biased') mantel = DCorr(which_test='mantel') mgc = MGC() hhg = HHG() pearson = RVCorr(which_test='pearson') mdmr = MDMR() independence_tests = [mcorr, dcorr, mantel, mgc, hhg, pearson, mdmr] params_dict_list = [] for sim_name, sim_func in simulations.items(): for test in independence_tests: params_dict = { 'independence_test': test, 'simulation_type': sim_func[1], 'base_path': base_path, 'additional_params': {} } params_dict_list.append(params_dict) if do_fast_mgc: fast_mgc = MGC() additional_params = {"is_fast": True} params_dict = { 'independence_test': fast_mgc, 'simulation_type': sim_func[1], 'base_path': base_path, 'additional_params': additional_params } params_dict_list.append(params_dict) return params_dict_list
def fill_params_dict_list_dimensions(): mcorr = DCorr(which_test='unbiased') dcorr = DCorr(which_test='biased') mantel = DCorr(which_test='mantel') mgc = MGC() rv_corr = RVCorr(which_test='rv') hhg = HHG() cca = RVCorr(which_test='cca') mdmr = MDMR() # initialize additional test # add the test that you wish to run in the `independence_tests` list independence_tests = [] # [mgc, mcorr, dcorr, mantel, rv_corr, cca] params_dict_list = [] for sim_name, sim_func in simulations.items(): for test in independence_tests: params_dict = { 'independence_test': test, 'simulation_type': sim_func[1], 'dim': find_dim(sim_name) } params_dict_list.append(params_dict) return params_dict_list
def fill_params_dict_list_sample_sizes(): mcorr = DCorr(which_test='unbiased') dcorr = DCorr(which_test='biased') mantel = DCorr(which_test='mantel') mgc = MGC() hhg = HHG() pearson = RVCorr(which_test='pearson') independence_tests = [] # [mgc, mcorr, dcorr, mantel, pearson] params_dict_list = [] for sim_name, sim_func in simulations.items(): for test in independence_tests: params_dict = { 'independence_test': test, 'simulation_type': sim_func[1] } params_dict_list.append(params_dict) return params_dict_list
def test_local_corr(): # Against a randomly defined data set X = np.array([1.1728, 2.4941, 2.4101, 0.1814, 1.1978, 1.5806, 1.2504, 1.9706, 1.8839, 0.8760], dtype=np.float64).reshape(-1, 1) Y = np.array([3.2311, 12.1113, 11.1350, 1.1989, 3.3127, 4.8580, 3.4917, 7.1748, 6.5792, 2.4012], dtype=np.float64).reshape(-1, 1) rvcorr = RVCorr(None) rvcorr2 = RVCorr(None, 'pearson') rvcorr3 = RVCorr(None, 'cca') test_stat1 = rvcorr.test_statistic(X, Y)[0] test_stat2 = rvcorr2.test_statistic(X, Y)[0] test_stat3 = rvcorr3.test_statistic(X, Y)[0] assert np.round(test_stat1, decimals=2) == 0.90 assert np.round(test_stat2, decimals=2) == 0.95 assert np.round(test_stat3, decimals=2) == 0.90 # Against linear simulations np.random.seed(0) X, Y = sims.linear_sim(100, 1) rvcorr = RVCorr(None) rvcorr2 = RVCorr(None, 'pearson') rvcorr3 = RVCorr(None, 'cca') assert rvcorr.get_name() == 'rv' assert rvcorr2.get_name() == 'pearson' assert rvcorr3.get_name() == 'cca' test_stat1 = rvcorr.test_statistic(X, Y)[0] test_stat2 = rvcorr2.test_statistic(X, Y)[0] test_stat3 = rvcorr3.test_statistic(X, Y)[0] assert np.round(test_stat1, decimals=2) == 0.24 assert np.round(test_stat2, decimals=2) == 0.49 assert np.round(test_stat3, decimals=2) == 0.24