in econml/data/dynamic_panel_dgp.py [0:0]
def generate_coefs(index, columns):
simulated_coefs_df = pd.DataFrame(0, index=index, columns=columns)
# get the indices of each group of features
ind_demo = [columns.index(col) for col in columns if "demo" in col]
ind_proxy = [columns.index(col) for col in columns if "proxy" in col]
ind_investment = [columns.index(col)
for col in columns if "investment" in col]
for i in range(7):
outcome_name = simulated_coefs_df.index[i]
if "proxy" in outcome_name:
ind_same_proxy = [
ind for ind in ind_proxy if outcome_name in columns[ind]]
# print(ind_same_proxy)
random_proxy_name = np.random.choice(
[proxy for proxy in index[:4] if proxy != outcome_name]
)
ind_random_other_proxy = [
ind for ind in ind_proxy if random_proxy_name in columns[ind]
]
# demo
simulated_coefs_df.iloc[
i, np.random.choice(ind_demo, 2)
] = np.random.uniform(0.004, 0.05)
# same proxy
simulated_coefs_df.iloc[i, ind_same_proxy] = sorted(
np.random.choice(expon.pdf(np.arange(10)) *
5e-1, 6, replace=False)
)
simulated_coefs_df.iloc[i, ind_random_other_proxy] = sorted(
np.random.choice(expon.pdf(np.arange(10)) *
5e-2, 6, replace=False)
)
elif "investment" in outcome_name:
ind_same_invest = [
ind for ind in ind_investment if outcome_name in columns[ind]
]
random_proxy_name = np.random.choice(index[:4])
ind_random_other_proxy = [
ind for ind in ind_proxy if random_proxy_name in columns[ind]
]
simulated_coefs_df.iloc[
i, np.random.choice(ind_demo, 2)
] = np.random.uniform(0.001, 0.05)
simulated_coefs_df.iloc[i, ind_same_invest] = sorted(
np.random.choice(expon.pdf(np.arange(10)) *
5e-1, 6, replace=False)
)
simulated_coefs_df.iloc[i, ind_random_other_proxy] = sorted(
np.random.choice(expon.pdf(np.arange(10)) *
1e-1, 6, replace=False)
)
return simulated_coefs_df