Ejemplo n.º 1
0
        params["UnempPrb"] = 0.05
        params["IncUnemp"] = 0.3
        params["UnempPrbRet"] = 0.0
        params["IncUnempRet"] = 0.0

        params.update({
            "BoroCnstArt": 0.0,
            "vFuncBool": False,
            "CubicBool": False,
            "aXtraMin": 0.001,
            "aXtraMax": 50.0,
            "aXtraNestFac": 3,
            "aXtraCount": 48,
            "aXtraExtra": [None],
        })
        example = ConsIndShockModel.IndShockConsumerType(**params)
    else:
        params = copy.deepcopy(params)
        params.pop("PermShkStd", None)
        params.pop("TranShkStd", None)
        example = ConsIndShockModel.PerfForesightConsumerType(**params)
    examples.append(example)
    results.append(st.empty())

for i, example in enumerate(examples):
    example.solve()
    results[i].markdown(
        f"**Model {1+i}** agent's human wealth is {example.solution[0].hNrm:.02f} times "
        f"his current income level, with its consumption function is defined (consumption is "
        f"positive) down to m_t = {example.solution[0].mNrmMin:.02f}.")
Ejemplo n.º 2
0
Params.init_consumer_objects[
    "PermGroFacAgg"] = 1.0  # Aggregate permanent income growth factor
Params.init_consumer_objects[
    "aNrmInitMean"] = -10.0  # Mean of log initial assets
Params.init_consumer_objects[
    "aNrmInitStd"] = 1.0  # Standard deviation of log initial assets
Params.init_consumer_objects[
    "pLvlInitMean"] = 0.0  # Mean of log initial permanent income
Params.init_consumer_objects[
    "pLvlInitStd"] = 0.0  # Standard deviation of log initial permanent income
Params.init_consumer_objects[
    "CubicBool"] = False  # Not available in the bequest model

# %%
# Make an instance of a lifecycle consumer to be used for estimation
LifeCyclePop = cShksModl.IndShockConsumerType(**Params.init_consumer_objects)

# %% {"code_folding": [0]}
# Solve and simulate the model (ignore the "warning" message)
LifeCyclePop.solve()  # Obtain consumption rules by age
LifeCyclePop.unpackcFunc()  # Expose the consumption rules

# Which variables do we want to track
LifeCyclePop.track_vars = [
    'aNrmNow', 'pLvlNow', 'mNrmNow', 'cNrmNow', 'TranShkNow', 't_cycle'
]

LifeCyclePop.T_sim = 120  # Nobody lives to be older than 145 years (=25+120)
LifeCyclePop.initializeSim(
)  # Construct the age-25 distribution of income and assets
LifeCyclePop.simulate(
Ejemplo n.º 3
0
import HARK.ConsumptionSaving.ConsIndShockModel as Model  # Consumption-saving model with idiosyncratic shocks
from HARK.utilities import plotFuncs, plotFuncsDer  # Basic plotting tools
from time import clock  # Timing utility
from copy import deepcopy  # "Deep" copying for complex objects
from HARK.parallel 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.IndShockConsumerType(**Params.init_idiosyncratic_shocks)
    BasicType.cycles = 0
    BasicType(aXtraMax=100, aXtraCount=64)
    BasicType(vFuncBool=False, CubicBool=True)
    BasicType.updateAssetsGrid()
    BasicType.timeFwd()

    # Solve the basic type and plot the results, to make sure things are working
    start_time = clock()
    BasicType.solve()
    end_time = clock()
    print('Solving the basic consumer took ' + mystr(end_time - start_time) +
          ' seconds.')
    BasicType.unpackcFunc()
    print('Consumption function:')
    plotFuncs(BasicType.cFunc[0], 0, 5)  # plot consumption