Skip to main content

Heterogenous Agents Resources & toolKit

Project description

Heterogeneous Agents Resources and toolKit (HARK)

HARK is a toolkit for the structural modeling of economic choices of optimizing and non-optimizing heterogeneous agents. For more information on using HARK, see the Econ-ARK Website.

The Econ-ARK project is fiscally sponsored by NumFOCUS. Consider making a tax-deductible donation to help the project pay for developer time, professional services, travel, workshops, and a variety of other needs.


This project is bound by a Code of Conduct.

Questions/Comments/Help

We have a Gitter Econ-ARK community.

Table of Contents

Install

Install from Anaconda Cloud by running:

conda install -c conda-forge econ-ark

Install from PyPi by running:

pip install econ-ark

Once HARK is installed, you can copy its example notebooks into a local working directory of your choice from within a Python environment:

from HARK import install_examples

install_examples()

Follow the simple prompts to make an examples subdirectory inside the directory you specify. We recommend starting with /examples/Gentle-Intro/Gentle-Intro-to-HARK.ipynb.

Usage

We start with almost the simplest possible consumption model: A consumer with CRRA utility

has perfect foresight about everything except the (stochastic) date of death.

The agent's problem can be written in Bellman form as:


To model the above problem, start by importing the PerfForesightConsumerType model from the appropriate HARK module then create an agent instance using the appropriate parameters:

from HARK.models import PerfForesightConsumerType

# Create an instance of a Perfect Foresight agent with otherwise default parameters
PFexample = PerfForesightConsumerType(cycles=0)

With cycles=0, the default parameters yield a single period cycle that repeats forever.

Once the model is created, ask the the agent to solve the problem with its solve() method:

# Tell the agent to solve the problem
PFexample.solve()

Solving the problem populates the agent's solution list attribute with solutions to each period of the problem. In the case of an infinite horizon model, there is just one element in the list, at index-zero.

You can retrieve the solution's consumption function from the cFunc attribute:

# Retrieve the consumption function of the solution
PFexample.solution[0].cFunc

Or you can retrieve the solved value for human wealth normalized by permanent income from the solution's .hNrm attribute:

# Retrieve the solved value for human wealth normalized by permanent income
PFexample.solution[0].hNrm

For a detailed explanation of the above example please see the demo notebook A Gentle Introduction to HARK.

For more examples please visit the examples section of the documentation, or the econ-ark/DemARK repository.

The examples can also be copied to a local working directory for you to run and investigate; see the Install section above.

Citation

If using Econ-ARK in your work or research please cite our Digital Object Identifier or copy the BibTex below.

DOI

[1] Carroll, Christopher D, Palmer, Nathan, White, Matthew N., Kazil, Jacqueline, Low, David C, & Kaufman, Alexander. (2017, October 3). econ-ark/HARK

BibText

@InProceedings{carroll_et_al-proc-scipy-2018,
  author    = { {C}hristopher {D}. {C}arroll and {A}lexander {M}. {K}aufman and {J}acqueline {L}. {K}azil and {N}athan {M}. {P}almer and {M}atthew {N}. {W}hite },
  title     = { {T}he {E}con-{A}{R}{K} and {H}{A}{R}{K}: {O}pen {S}ource {T}ools for {C}omputational {E}conomics },
  booktitle = { {P}roceedings of the 17th {P}ython in {S}cience {C}onference },
  pages     = { 25 - 30 },
  year      = { 2018 },
  editor    = { {F}atih {A}kici and {D}avid {L}ippa and {D}illon {N}iederhut and {M} {P}acer },
  doi       = { 10.25080/Majora-4af1f417-004 }
}

For more on acknowledging Econ-ARK visit our website.

Support

Looking for help? Please open a GitHub issue or reach out to us through the gitter community.

Release Types

  • Current: Under active development. Code for the Current release is in the branch for its major version number (for example, v0.10.x).
  • Development: Under active development. Code for the Current release is in the development.

Current releases follow Semantic Versioning. For more information please see the Release documentation.

Documentation

Documentation for the latest release is at docs.econ-ark.org.

Introduction

For Students: A Gentle Introduction to HARK

Most of what economists have done so far with 'big data' has been like what Kepler did with astronomical data: Organizing the data, and finding patterns and regularities and interconnections.

An alternative approach called 'structural modeling' aims to do, for economic data, what Newton did for astronomical data: Provide a deep and rigorous mathematical (or computational) framework that distills the essence of the underlying behavior that produces the 'big data.'

The notebook A Gentle Introduction to HARK details how you can easily utilize our toolkit for structural modeling. Starting with a simple Perfect Foresight Model we solve an agent problem, then experiment with adding income shocks and changing constructed attributes.

For Economists: Structural Modeling with HARK

Dissatisfaction with the ability of Representative Agent models to answer important questions raised by the Great Recession has led to a strong movement in the macroeconomics literature toward 'Heterogeneous Agent' models, in which microeconomic agents (consumers; firms) solve a structural problem calibrated to match microeconomic data; aggregate outcomes are derived by explicitly simulating the equilibrium behavior of populations solving such models.

The same kinds of modeling techniques are also gaining popularity among microeconomists, in areas ranging from labor economics to industrial organization. In both macroeconomics and structural micro, the chief barrier to the wide adoption of these techniques has been that programming a structural model has, until now, required a great deal of specialized knowledge and custom software development.

HARK provides a robust, well-designed, open-source toolkit for building such models much more efficiently than has been possible in the past.

Our DCEGM Upper Envelope notebook illustrates using HARK to replicate the Iskhakov, Jørgensen, Rust, and Schjerning paper for solving the discrete-continuous retirement saving problem.

The notebook Making Structural Estimates From Empirical Results is another demonstration of using HARK to conduct a quick structural estimation based on Table 9 of MPC Heterogeneity and Household Balance Sheets by Fagereng, Holm, and Natvik.

For Computational Economics Developers

HARK provides a modular and extensible open-source toolkit for solving heterogeneous-agent partial-and general-equilibrium structural models. The code for such models has always been handcrafted, idiosyncratic, poorly documented, and sometimes not generously shared from leading researchers to outsiders. The result being that it can take years for a new researcher to become proficient. By building an integrated system from the bottom up using object-oriented programming techniques and other tools, we aim to provide a platform that will become a focal point for people using such models.

HARK is written in Python, making significant use of libraries such as numpy and scipy which offer a wide array of mathematical and statistical functions and tools. Our modules are generally categorized into Tools (mathematical functions and techniques), Models (particular economic models and solvers) and Applications (use of tools to simulate an economic phenomenon).

For more information on how you can create your own Models or use Tools and Model to create Applications please see the documentation

Contributing to HARK

We want contributing to Econ-ARK to be fun, enjoyable, and educational for anyone, and everyone.

Contributions go far beyond pull requests and commits. Although we love giving you the opportunity to put your stamp on HARK, we are also thrilled to receive a variety of other contributions including:

  • Documentation updates, enhancements, designs, or bugfixes
  • Spelling or grammar fixes
  • REAME.md corrections or redesigns
  • Adding unit, or functional tests
  • Triaging GitHub issues -- e.g. pointing out the relevant files, checking for reproducibility
  • Searching for #econ-ark on twitter and helping someone else who needs help
  • Answering questions from StackOverflow tagged with econ-ark
  • Teaching others how to contribute to HARK
  • Blogging, speaking about, or creating tutorials about HARK
  • Helping others in our mailing list

If you are worried or don’t know how to start, you can always reach out to us through the gitter community(#tsc-technical-steering-committee) or simply submit an issue and a member can help give you guidance!

To install for development see the Quickstart Guide.

For more information on contributing to HARK please see the contributing guide. This is the guide that collaborators follow in maintaining the Econ-ARK project.

Disclaimer

This is a beta version of HARK. The code has not been extensively tested as it should be. We hope it is useful, but there are absolutely no guarantees (expressed or implied) that it works or will do what you want. Use at your own risk. And please, let us know if you find bugs by posting an issue to the GitHub page!

Detailed Explanations and Examples

To help users understand the purpose and features of the repository, we have provided detailed explanations and examples in various sections of the documentation. Here are some key resources:

  • Overview and Examples: This section provides an introduction to HARK and includes various examples to help users understand how to use the toolkit.
  • Guides: This section includes guides on installation, quick start, and contributing to HARK.
  • Reference: This section provides detailed explanations and examples of the various tools and models available in the repository.

For more information and resources, please visit the Econ-ARK documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

econ_ark-0.17.0.tar.gz (17.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

econ_ark-0.17.0-py3-none-any.whl (2.3 MB view details)

Uploaded Python 3

File details

Details for the file econ_ark-0.17.0.tar.gz.

File metadata

  • Download URL: econ_ark-0.17.0.tar.gz
  • Upload date:
  • Size: 17.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for econ_ark-0.17.0.tar.gz
Algorithm Hash digest
SHA256 7578307d38508f7afb976023832d1aa7217e25ed58355073c982f6b0ff1fd97e
MD5 94efa45ada9ded9a094d4ea70cf22231
BLAKE2b-256 e7e7c330a15890c2f9dde43e3371bdd39a01f749242bf9fbb625e82b23be7907

See more details on using hashes here.

Provenance

The following attestation bundles were made for econ_ark-0.17.0.tar.gz:

Publisher: release.yml on econ-ark/HARK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file econ_ark-0.17.0-py3-none-any.whl.

File metadata

  • Download URL: econ_ark-0.17.0-py3-none-any.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for econ_ark-0.17.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bcb4f441f98807b8d5d003e119808cdcff800b2d8c50248bf8ad8114346563a9
MD5 92d8cc7c5f9ac7ae5f11bd2e0942b771
BLAKE2b-256 ec44f1dc5e1827ad388255aa7fb1249c91b25be914087fa46d9ffecd0f6c7af5

See more details on using hashes here.

Provenance

The following attestation bundles were made for econ_ark-0.17.0-py3-none-any.whl:

Publisher: release.yml on econ-ark/HARK

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page