def shrink_mat(array): dim = 5 step = 2 sdist = Stationary(array) ans = np.zeros((dim, dim)) for i in range(dim): for j in range(dim): ans[i,j] = sdist[step*i]*array[step*i, step*j:step*j+2].sum() + \ sdist[step*i+1]*array[step*i+1, step*j:step*j+2].sum() ans[i, j] = ans[i, j] / sdist[step * i:step * i + 2].sum() return ans
data_is_o = data_is_o[:, 2000:] np.save(path_to_data_is_o + '.npy', data_is_o) split_shock(path_to_data_is_o, 25_000, num_core) del data_rand ### end generate shocks ### ### check f = open(nd_log_file, 'w') f.writelines( np.array_str(np.bincount(data_i_s[:, 0]) / np.sum(np.bincount(data_i_s[:, 0])), precision=4, suppress_small=True) + '\n') f.writelines( np.array_str(Stationary(prob), precision=4, suppress_small=True) + '\n') f.writelines( np.array_str(np.bincount(data_is_o[:, 0]) / np.sum(np.bincount(data_is_o[:, 0])), precision=4, suppress_small=True) + '\n') f.writelines( np.array_str(Stationary(prob_yo), precision=4, suppress_small=True) + '\n') # f.writelines('yc_init = ' + str(yc_init) + '\n') # f.writelines('GDP_implied = ' + str(GDP_implied) + '\n') f.close()
data_laborinc = w * data_eps * data_n data_bizinc = p * data_ys - (rs + delk) * data_ks - data_x - w * data_ns print('### labor income wepsn ###') print('') print('simulated result') prob_wepsn = get_transition(data_laborinc[:, -2], data_laborinc[:, -1], num_bins=5, full_output=True)[0] print('transition of wepsn') print(np.array_str(prob_wepsn, precision=4, suppress_small=True)) print('implied SS of wespn') print(Stationary(prob_wepsn)) print('') print('P_eps') print(prob_eps) print('SS of P_eps') print(Stationary(prob_eps)) print('') print('### biz income pys - (rs+delk)ks - wns - x ###') print('') print('simulated result') prob_bizinc = get_transition(data_bizinc[:, -2], data_bizinc[:, -1], num_bins=5,