from HARKestimation import minimizeNelderMead, bootstrapSampleFromData import numpy as np import pylab from time import time # Set booleans to determine which tasks should be done estimate_model = True compute_standard_errors = False make_contour_plot = True #===================================================== # Define objects and functions used for the estimation #===================================================== # Make a lifecycle consumer to be used for estimation, including simulated shocks (plus an initial distribution of wealth) EstimationAgent = Model.ConsumerType(**Params.init_consumer_objects) EstimationAgent(sim_periods=EstimationAgent.T_total + 1) EstimationAgent.makeIncShkHist() EstimationAgent.a_init = drawDiscrete( P=Params.initial_wealth_income_ratio_probs, X=Params.initial_wealth_income_ratio_vals, N=Params.num_agents, seed=Params.seed) # Define the objective function for the estimation def smmObjectiveFxn(DiscFacAdj, CRRA, agent=EstimationAgent, DiscFacAdj_bound=Params.DiscFacAdj_bound, CRRA_bound=Params.CRRA_bound,
import sys from HARKutilities import plotFunc, plotFuncDer, plotFuncs # Basic plotting tools from time import clock # Timing utility from copy import deepcopy # "Deep" copying for complex objects from HARKparallel import multiThreadCommandsFake, multiThreadCommands # Parallel processing mystr = lambda number: "{:.4f}".format(number) # Format numbers as strings import numpy as np # Numeric Python if __name__ == '__main__': # Parallel calls *must* be inside a call to __main__ type_count = 32 # Number of values of CRRA to solve # Make the basic type that we'll use as a template. # The basic type has an artificially dense assets grid, as the problem to be # solved must be sufficiently large for multithreading to be faster than # single-threading (looping), due to overhead. BasicType = Model.ConsumerType(**Params.init_consumer_objects) BasicType.aXtraMax = 100 BasicType.aXtraCount = 64 BasicType.updateAssetsGrid() BasicType.timeFwd() BasicType.assignParameters( LivPrb=[0.98], DiscFac=[0.96], PermGroFac=[1.01], cycles=0) # This is what makes the type infinite horizon BasicType(vFuncBool=False, cubicBool=True) BasicType.IncomeDstn = [ BasicType.IncomeDstn[0] ] # A "one period" infinite horizon model, so only need one period of income distributions # Solve the basic type and plot the results, to make sure things are working start_time = clock() BasicType.solve()