Skip to content

Commit

Permalink
Fixed Cubic interpolation issue
Browse files Browse the repository at this point in the history
There was an errant point at aNrm=0, just had to remove it.
  • Loading branch information
mnwhite committed Mar 15, 2024
1 parent 28afed2 commit 1c3b683
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions HARK/ConsumptionSaving/ConsRiskyAssetModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
ValueFuncCRRA,
)
from HARK.rewards import UtilityFuncCRRA
from HARK.utilities import plot_funcs


class IndShockRiskyAssetConsumerType(IndShockConsumerType):
Expand Down Expand Up @@ -84,7 +83,7 @@ def __init__(self, verbose=False, quiet=False, **kwds):
solver = ConsIndShkRiskyAssetSolver # risky share of 1

self.solve_one_period = make_one_period_oo_solver(solver)
#self.solve_one_period = solve_one_period_ConsIndShockRiskyAsset
# self.solve_one_period = solve_one_period_ConsIndShockRiskyAsset

def pre_solve(self):
self.update_solution_terminal()
Expand Down Expand Up @@ -610,14 +609,13 @@ def calc_hNrm(S):
# bNrm represents R*a, balances after asset return shocks but before income.
# This just uses the highest risky return as a rough shifter for the aXtraGrid.
if BoroCnstNat_iszero:
aNrmNow = aXtraGrid
bNrmNow = np.insert(
RiskyMaxNext * aXtraGrid, 0, RiskyMinNext * aXtraGrid[0]
)
else:
# Add an asset and bank balances point at exactly zero
aNrmNow = np.insert(aXtraGrid, 0, 0.0)
# Add a bank balances point at exactly zero
bNrmNow = RiskyMaxNext * np.insert(aXtraGrid, 0, 0.0)
aNrmNow = aXtraGrid

# Define local functions for taking future expectations when the interest
# factor *is* independent from the income shock distribution. These go
Expand Down Expand Up @@ -666,7 +664,6 @@ def calc_vPPnext(S, b):

# "Recurve" the intermediate pseudo-inverse marginal value function
Intermed_vPfunc = MargValueFuncCRRA(Intermed_vPnvrsFunc, CRRA)
plot_funcs(Intermed_vPfunc, 0., 20.)

# If the value function is requested, calculate "intermediate" value
if vFuncBool:
Expand Down Expand Up @@ -716,8 +713,6 @@ def calc_vPPnext(R, a):
dcda = EndOfPrdvPP / uFunc.der(np.array(cNrmNow), order=2)
MPC = dcda / (dcda + 1.0)
MPC_for_interpolation = np.insert(MPC, 0, MPCmaxNow)

#print(MPC_for_interpolation) # TODO: Figure out where the NaN in second element is coming from

# Limiting consumption is zero as m approaches mNrmMin
c_for_interpolation = np.insert(cNrmNow, 0, 0.0)
Expand Down

0 comments on commit 1c3b683

Please sign in to comment.