Skip to content

Commit

Permalink
adding python model configuration for normalized perfect foresight; g…
Browse files Browse the repository at this point in the history
…eneric monte carlo example shows exact match
  • Loading branch information
sbenthall committed Oct 11, 2023
1 parent b95b0f4 commit 0c52963
Show file tree
Hide file tree
Showing 3 changed files with 384 additions and 154 deletions.
Empty file added HARK/models/__init__.py
Empty file.
33 changes: 33 additions & 0 deletions HARK/models/perfect_foresight_normalized.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from HARK.distribution import Bernoulli
from HARK.model import Control

Check warning on line 2 in HARK/models/perfect_foresight_normalized.py

View check run for this annotation

Codecov / codecov/patch

HARK/models/perfect_foresight_normalized.py#L1-L2

Added lines #L1 - L2 were not covered by tests

# This way of distributing parameters across the scope is clunky
# Can be handled better if parsed from a YAML file, probably
# But it would be better to have a more graceful Python version as well.
CRRA = 2.0,
LivPrb = 0.98

Check warning on line 8 in HARK/models/perfect_foresight_normalized.py

View check run for this annotation

Codecov / codecov/patch

HARK/models/perfect_foresight_normalized.py#L7-L8

Added lines #L7 - L8 were not covered by tests

model = {

Check warning on line 10 in HARK/models/perfect_foresight_normalized.py

View check run for this annotation

Codecov / codecov/patch

HARK/models/perfect_foresight_normalized.py#L10

Added line #L10 was not covered by tests
'shocks' : {
'live' : Bernoulli(p=LivPrb),
},
'parameters' : {
'DiscFac' : 0.96,
'CRRA' : CRRA,
'Rfree' : 1.03,
'LivPrb' : LivPrb,
'PermGroFac' : 1.01,
'BoroCnstArt' : None,
},
'dynamics' : {
'p' : lambda PermGroFac, p: PermGroFac * p,
'r_eff' : lambda Rfree, PermGroFac : Rfree / PermGroFac,
'b_nrm' : lambda r_eff, a_nrm: r_eff * a_nrm,
'm_nrm' : lambda b_nrm: b_nrm + 1,
'c_nrm' : Control(['m_nrm']),
'a_nrm' : lambda m_nrm, c_nrm : m_nrm - c_nrm
},
'reward' : {
'u' : lambda c : c ** (1 - CRRA) / (1 - CRRA)
}
}
Loading

0 comments on commit 0c52963

Please sign in to comment.