Skip to content

Commit

Permalink
Merge pull request #1275 from alanlujan91/approx_population
Browse files Browse the repository at this point in the history
Add arguments to discretize
  • Loading branch information
mnwhite authored Jun 19, 2024
2 parents 386a049 + 5c3136f commit 13d94c8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
19 changes: 12 additions & 7 deletions Documentation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ For more information on HARK, see [our Github organization](https://github.com/e

## Changes

### 0.15.2 (in development)

Release Date: TBD

#### Major Changes

none

#### Minor Changes

- Fixes bug in `AgentPopulation` that caused discretization of distributions to not work. [1275](https://github.com/econ-ark/HARK/pull/1275)

### 0.15.1

Release Date: June 15, 2024
Expand Down Expand Up @@ -86,13 +98,6 @@ Release Date: February 12, 2024
- Adds option `sim_common_Rrisky` to control whether risky-asset models draw common or idiosyncratic returns in simulation. [#1250](https://github.com/econ-ark/HARK/pull/1250),[#1253](https://github.com/econ-ark/HARK/pull/1253)
- Addresses [#1255](https://github.com/econ-ark/HARK/issues/1255). Makes age-varying stochastic returns possible and draws from their discretized version. [#1262](https://github.com/econ-ark/HARK/pull/1262)
- Fixes bug in the metric that compares dictionaries with the same keys. [#1260](https://github.com/econ-ark/HARK/pull/1260)
- Fixes bug in the calc_jacobian method. [#1342](https://github.com/econ-ark/HARK/pull/1342)
- Fixes bug that prevented risky-asset consumer types from working with time-varying interest rates `Rfree`. [1343](https://github.com/econ-ark/HARK/pull/1343)
- Overhauls and expands condition checking for the ConsIndShock model [#1294](https://github.com/econ-ark/HARK/pull/1294). Condition values and a description of their interpretation is stored in the bilt dictionary of IndShockConsumerType.
- Creates a `models/` directory with Python model configurations for perfect foresight and Fisher 2-period models. [1347](https://github.com/econ-ark/HARK/pull/1347)
- Fixes bug in AgentType simulations where 'who_dies' for period t was being recorded in period t-1 in the history Carlo simulation functions using Python model configurations.[1296](https://github.com/econ-ark/HARK/pull/1296)
- Removes unused `simulation.py` .[1296](https://github.com/econ-ark/HARK/pull/1296)
- Fixes bug that default seed was being used in the initializing of income shock distributions. [1380](https://github.com/econ-ark/HARK/pull/1380)

### 0.13.0

Expand Down
4 changes: 2 additions & 2 deletions HARK/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2005,11 +2005,11 @@ def approx_distributions(self, approx_params: dict):
self.continuous_distributions = {}
self.discrete_distributions = {}

for key, points in approx_params.items():
for key, args in approx_params.items():
param = self.parameters[key]
if key in self.distributed_params and isinstance(param, Distribution):
self.continuous_distributions[key] = param
self.discrete_distributions[key] = param.discretize(points)
self.discrete_distributions[key] = param.discretize(**args)
else:
raise ValueError(
f"Warning: parameter {key} is not a Distribution found "
Expand Down
14 changes: 12 additions & 2 deletions HARK/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ def test_distributed_params(self):
self.assertTrue("DiscFac" in self.agent_pop.distributed_params)

def test_approx_agents(self):
self.agent_pop.approx_distributions({"CRRA": 3, "DiscFac": 4})
self.agent_pop.approx_distributions(
{
"CRRA": {"N": 3, "method": "equiprobable"},
"DiscFac": {"N": 4, "method": "equiprobable"},
}
)

self.assertTrue("CRRA" in self.agent_pop.continuous_distributions)
self.assertTrue("DiscFac" in self.agent_pop.continuous_distributions)
Expand All @@ -166,7 +171,12 @@ def test_approx_agents(self):
self.assertEqual(self.agent_pop.agent_type_count, 12)

def test_create_agents(self):
self.agent_pop.approx_distributions({"CRRA": 3, "DiscFac": 4})
self.agent_pop.approx_distributions(
{
"CRRA": {"N": 3, "method": "equiprobable"},
"DiscFac": {"N": 4, "method": "equiprobable"},
}
)
self.agent_pop.create_distributed_agents()

self.assertEqual(len(self.agent_pop.agents), 12)
Expand Down

0 comments on commit 13d94c8

Please sign in to comment.