Ejemplo n.º 1
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}.")

st.pyplot(
    plotFuncs(
        [e.solution[0].cFunc for e in examples],
        0.0,
        10,
Ejemplo n.º 2
0
# Make agent live for sure until the terminal period
pf_dict['T_retire'] = t_cycle
pf_dict['LivPrb'] = [1] * t_cycle

# Shut down income growth
pf_dict['PermGroFac'] = [1] * t_cycle

# Decrease grid for speed
pf_dict['aXtraCount'] = 100

# %% Create both agents
port_agent = cpm.PortfolioConsumerType(**pf_dict)
port_agent.solve()

pf_agent = cis.PerfForesightConsumerType(**pf_dict)
pf_agent.solve()

# %% Construct the analytical solution

rho = pf_dict['CRRA']
R = pf_dict['Rfree']
Beta = pf_dict['DiscFac']
T = pf_dict['T_cycle'] + 1

thorn_r = (R * Beta)**(1 / rho) / R

ht = lambda t: (1 - (1 / R)**(T - t + 1)) / (1 - 1 / R) - 1
kappa = lambda t: (1 - thorn_r) / (1 - thorn_r**(T - t + 1))

true_cFunc = lambda t, m: np.minimum(m, kappa(t) * (m + ht(t)))