t_end = process_time()
print("Solving a tractable consumption-savings model took " +
      str(t_end - t_start) + " seconds.")

# %%
# Plot the consumption function and whatnot
m_upper = 1.5 * ExampleType.mTarg
conFunc_PF = lambda m: ExampleType.h * ExampleType.PFMPC + ExampleType.PFMPC * m
# plotFuncs([ExampleType.solution[0].cFunc,ExampleType.mSSfunc,ExampleType.cSSfunc],0,m_upper)
plotFuncs([ExampleType.solution[0].cFunc, ExampleType.solution[0].cFunc_U], 0,
          m_upper)

# %%
if do_simulation:
    ExampleType(**simulation_values)  # Set attributes needed for simulation
    ExampleType.track_vars = ["mLvlNow"]
    ExampleType.makeShockHistory()
    ExampleType.initializeSim()
    ExampleType.simulate()

# %%
# Now solve the same model using backward induction rather than the analytic method of TBS.
# The TBS model is equivalent to a Markov model with two states, one of them absorbing (permanent unemployment).
MrkvArray = np.array(
    [[1.0 - base_primitives["UnempPrb"], base_primitives["UnempPrb"]],
     [0.0, 1.0]])  # Define the two state, absorbing unemployment Markov array
init_consumer_objects = {
    "CRRA":
    base_primitives["CRRA"],
    "Rfree":
    np.array(
Beispiel #2
0
        os.path.join(Figures_HARK_dir, 'PhaseDiagramDecreaseThetaPlot.pdf'))
    plt.savefig(
        os.path.join(Figures_HARK_dir, 'PhaseDiagramDecreaseThetaPlot.svg'))
if not in_ipynb:
    plt.show(block=False)
else:
    plt.show(block=True)

# %% [markdown]
# ### Figure 7: Path of $c^{e}$ Before and After $\theta$ Decline

# %%
MyTBStype.T_sim = 100
MyTBStype.aLvlInitMean = 1.
MyTBStype.aLvlInitStd = 0.
MyTBStype.track_vars = ['mLvlNow', 'cLvlNow']
MyTBStype.initializeSim()
MyTBStype.simulate()

# Capture steady states
sscE = MyTBStype.cLvlNow
ssmE = MyTBStype.mLvlNow

# Now lets change the discount factor from 0.96 to 0.97
#MyTBStype.DiscFac = MyTBStype_3.DiscFac
MyTBStype_3.solve()  #remember to resolve the consumer's problem
MyTBStype_3.T_sim = 110
MyTBStype_3.aLvlInitMean = 1.
MyTBStype_3.aLvlInitStd = 0.
MyTBStype_3.track_vars = ['mLvlNow', 'cLvlNow']
MyTBStype_3.initializeSim()