-
-
Notifications
You must be signed in to change notification settings - Fork 204
standalone model configuration file with model, approximation, solution, and simulation parameters #1463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
standalone model configuration file with model, approximation, solution, and simulation parameters #1463
Changes from all commits
4c58ca7
8eb9e67
5f99811
7348331
b4ec61e
9718464
0224a6d
e1fe4d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,84 @@ | ||||||||||||||||||
| from HARK.distribution import Bernoulli, Lognormal, MeanOneLogNormal | ||||||||||||||||||
|
||||||||||||||||||
| from HARK.distribution import Bernoulli, Lognormal, MeanOneLogNormal | |
| from HARK.distributions import Bernoulli, Lognormal, MeanOneLogNormal |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"configuraiton" is misspelled in this docstring; this should be corrected to "configuration" for clarity and consistency with the rest of the documentation.
| This file shows the model configuraiton in Python. | |
| This file shows the model configuration in Python. |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this Python configuration, the shocks entries are specified as lists like [Bernoulli, {"p": "LivPrb"}], but construct_shocks and DBlock expect either Distribution instances or tuples of (DistributionClass, args_dict) (see HARK/model.py:81-129 and 196-215). Using lists here means this configuration cannot be passed directly into DBlock/construct_shocks as intended; these should be tuples to match the established convention and behavior.
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, the risky_return shock is defined as a list [Lognormal.from_mean_std, {"mean": "Rfree + EqP", "std": 0.1}]. To be compatible with construct_shocks and the existing block definitions (e.g., HARK/models/consumer.py:59-64), this should be a tuple rather than a list so it is recognized as a constructor-plus-args pair.
| "risky_return": [ | |
| Lognormal.from_mean_std, | |
| {"mean": "Rfree + EqP", "std": 0.1}, | |
| ] | |
| "risky_return": ( | |
| Lognormal.from_mean_std, | |
| {"mean": "Rfree + EqP", "std": 0.1}, | |
| ) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,90 @@ | ||||||||||||||||||||||||||||||
| model: &consumer_portfolio | ||||||||||||||||||||||||||||||
| agents: | ||||||||||||||||||||||||||||||
| consumer: | ||||||||||||||||||||||||||||||
| count: 100 # a model with 100 consumers | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| calibration: | ||||||||||||||||||||||||||||||
| # - DiscFac: 0.96 put this in the solution section | ||||||||||||||||||||||||||||||
| - CRRA: 2.0 | ||||||||||||||||||||||||||||||
| - R: 1.03 # note: this can be overriden by the portfolio dynamics | ||||||||||||||||||||||||||||||
| - Rfree: 1.03 | ||||||||||||||||||||||||||||||
| - EqP: 0.02 | ||||||||||||||||||||||||||||||
| - PermGroFac: 1.01 | ||||||||||||||||||||||||||||||
| - TranShkStd: 0.1 | ||||||||||||||||||||||||||||||
|
Comment on lines
+7
to
+13
|
||||||||||||||||||||||||||||||
| # - DiscFac: 0.96 put this in the solution section | |
| - CRRA: 2.0 | |
| - R: 1.03 # note: this can be overriden by the portfolio dynamics | |
| - Rfree: 1.03 | |
| - EqP: 0.02 | |
| - PermGroFac: 1.01 | |
| - TranShkStd: 0.1 | |
| # DiscFac: 0.96 put this in the solution section | |
| CRRA: 2.0 | |
| R: 1.03 # note: this can be overriden by the portfolio dynamics | |
| Rfree: 1.03 | |
| EqP: 0.02 | |
| PermGroFac: 1.01 | |
| TranShkStd: 0.1 |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value m: b + theta, includes a trailing comma in the mathematical expression. Given that expressions are parsed via SymPy (see HARK/parser.py:39-45), this extra comma will cause a parse error and should be removed so the expression is valid (e.g., b + theta).
| m: b + theta, | |
| m: b + theta |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reward expression u: c ** (1 - CRRA) / (1 - CRRA)} has an extra closing brace at the end. Because reward expressions are parsed as mathematical text (see HARK/parser.py:39-45 and HARK/model.py:262-264), this stray } will make the YAML example invalid or unparseable; it should be removed so the expression is valid.
| u: c ** (1 - CRRA) / (1 - CRRA)} | |
| u: c ** (1 - CRRA) / (1 - CRRA) |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here stigma is set to the literal text Control(["a"]), rather than using the !Control YAML tag as in the c variable above. With the current harklang_loader (see HARK/parser.py:48-67), this value will be treated as a plain string instead of a control token, and the trailing comma also makes it invalid as a mathematical expression; this should be rewritten to use the !Control tag without the extra comma.
| stigma: Control(["a"]), | |
| stigma: !Control | |
| inset: a |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment # defaults to infinite horizion problem contains a typo in "horizion"; it should be "horizon" for clarity.
| # defaults to infinite horizion problem | |
| # defaults to infinite horizon problem |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The !Linspace tag used here is not registered in the current YAML loader (harklang_loader only adds constructors for !Bernoulli, !MeanOneLogNormal, !Lognormal, and !Control in HARK/parser.py:48-65). As written, attempting to load this YAML with harklang_loader will raise a constructor error; either the tag needs a corresponding constructor, or this should be expressed using supported tags/structures.
| m: !Linspace # grid over continuous state space | |
| m: # grid over continuous state space |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The !MonteCarlo tag used for the simulation block is not registered in harklang_loader (see HARK/parser.py:48-67), so loading this YAML with that loader will fail with an unknown tag error. To make this example loadable, a constructor for !MonteCarlo needs to be added or the tag should be removed/changed to a supported construct.
| simulation: !MonteCarlo | |
| simulation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"paramaters" is misspelled here; it should be "parameters". While updating this line, consider also adding a
#before the PR number so the link formatting matches adjacent entries (e.g.,[#1463](...)).