コード例 #1
0
]  # Irrelevant to the individual's choice; attach later to "market" economy object

# Instantiate the baseline agent type with the parameters defined above
BaselineType = cstwMPC.cstwMPCagent(**Params.init_cjSOE)
BaselineType.AgeDstn = np.array(1.0)  # Fix the age distribution of agents

# Make desired number of agent types (to capture ex-ante heterogeneity)
EstimationAgentList = []
for n in range(Params.pref_type_count):
    EstimationAgentList.append(deepcopy(BaselineType))
    EstimationAgentList[n].seed = n  # Give every instance a different seed

# %% {"code_folding": [0]}
# Make an economy for the consumers to live in

EstimationEconomy = cstwMPC.cstwMPCmarket(**Params.init_market)
EstimationEconomy.print_parallel_error_once = True  # Avoids a bug in the code

EstimationEconomy.agents = EstimationAgentList
EstimationEconomy.act_T = Params.T_sim_PY  # How many periods of history are good enough for "steady state"

# %% {"code_folding": [0]}
# Uninteresting parameters that also need to be set
EstimationEconomy.KYratioTarget = KY_target
EstimationEconomy.LorenzTarget = lorenz_target
EstimationEconomy.LorenzData = lorenz_long_data
EstimationEconomy.PopGroFac = PopGroFac_cjSOE  # Population growth characterizes the entire economy
EstimationEconomy.ignore_periods = Params.ignore_periods_PY  # Presample periods

#Display statistics about the estimated model (or not)
EstimationEconomy.LorenzBool = False
コード例 #2
0
        else:
            PerpetualYouthType = cstwMPCagent(**Params.init_infinite)
        PerpetualYouthType.AgeDstn = np.array(1.0)
        EstimationAgentList = []
        for n in range(pref_type_count):
            EstimationAgentList.append(deepcopy(PerpetualYouthType))

    # Give all the AgentTypes different seeds
    for j in range(len(EstimationAgentList)):
        EstimationAgentList[j].seed = j

    # Make an economy for the consumers to live in
    market_dict = copy(Params.init_market)
    market_dict['AggShockBool'] = do_agg_shocks
    market_dict['Population'] = Population
    EstimationEconomy = cstwMPCmarket(**market_dict)
    EstimationEconomy.agents = EstimationAgentList
    EstimationEconomy.KYratioTarget = KY_target
    EstimationEconomy.LorenzTarget = lorenz_target
    EstimationEconomy.LorenzData = lorenz_long_data
    if do_lifecycle:
        EstimationEconomy.PopGroFac = Params.PopGroFac
        EstimationEconomy.TypeWeight = Params.TypeWeight_lifecycle
        EstimationEconomy.T_retire = Params.working_T - 1
        EstimationEconomy.act_T = Params.T_sim_LC
        EstimationEconomy.ignore_periods = Params.ignore_periods_LC
    else:
        EstimationEconomy.PopGroFac = 1.0
        EstimationEconomy.TypeWeight = [1.0]
        EstimationEconomy.act_T = Params.T_sim_PY
        EstimationEconomy.ignore_periods = Params.ignore_periods_PY