Пример #1
0
def run_simulation(Gamma0,Eps,ineq_slope=2/.9,tfp_level=1.,chi=0):
    Gamma,Z,Y,Shocks,y = {},{},{},{},{}
    Para.ineq_slope=ineq_slope
    Para.chi=chi
    Para.tfp_level=tfp_level
    approximate.calibrate(Para)
    simulate.approximate = approximate
    T=len(Eps)
    Gamma[0] = Gamma0
    Z[0] = 0.
    simulate.simulate_aggstate(Para,Gamma,Z,Y,Shocks,y,T-1,agg_shocks= Eps)    
    return Gamma,Z,Y,Shocks,y 
def run_simulation(
        ex, Gamma0,
        Eps):  ## function to run all cases with MPI and store the simulation
    Para.chi = Case[ex][0]
    conditional_mean_flag = Case[ex][1]
    inequlity_shock_flag = Case[ex][2]
    Gamma, Z, Y, Shocks, y = {}, {}, {}, {}, {}
    T = len(Eps)
    Gamma[0] = Gamma0
    Z[0] = 0.

    if inequlity_shock_flag == 0:
        Para.ineq_slope = 0
    else:
        Para.ineq_slope = 1.0 / 0.8

    approximate.calibrate(Para)
    simulate.approximate = approximate

    if conditional_mean_flag == 1:
        simulate.simulate_aggstate_ConditionalMean(Para,
                                                   Gamma,
                                                   Z,
                                                   Y,
                                                   Shocks,
                                                   y,
                                                   T - 1,
                                                   agg_shocks=Eps)
    else:
        simulate.simulate_aggstate(Para,
                                   Gamma,
                                   Z,
                                   Y,
                                   Shocks,
                                   y,
                                   T - 1,
                                   agg_shocks=Eps)

    data_simulation = Gamma, Z, Y, Shocks, y, Case[ex]
    with open('data_simulation_new' + str(ex) + '.pickle', 'wb') as f:
        pickle.dump(data_simulation, f)
Пример #3
0
Para.gamma = gamma
Para.Gov = gov
Para.chi = -0.06

N = len(thetas)
T = 200
debt = []
alphalist = []

for alpha in np.linspace(.03, .16, 15):
    Gamma, Z, Y, Shocks, y = {}, {}, {}, {}, {}
    Gamma[0] = Gamma0
    Gamma[0][:, 3] = np.linspace(0.2 - alpha, 0.2 + alpha, N)
    Z[0] = 0.
    Para.sigma_E = 0.25  #allows for quicker convergence
    approximate.calibrate(Para)
    simulate.approximate = approximate
    Eps = np.random.randn(T)
    Eps = np.minimum(3., np.maximum(-3., Eps))
    simulate.simulate_aggstate_ConditionalMean(Para,
                                               Gamma,
                                               Z,
                                               Y,
                                               Shocks,
                                               y,
                                               T - 1,
                                               agg_shocks=Eps)
    Para.sigma_E = 0.025
    approximate.calibrate(Para)
    approx = approximate.approximate(Gamma[T - 2])
    data = {}