Git Product home page Git Product logo

cstwmpc's Introduction

DistributionOfWealthMPC Mostly Supercedes This Repo

The cstwMPC Repo aims to replicate all the results of the original cstwMPC paper, with minimal updates to the original code to make it work in updated versions of HARK.

DistributionOfWealthMPC is a much more thoroughgoing rewrite that brings everything up to date with the many improvements to HARK that have been made since the cstwMPC paper was published.

DistributionOfWealthMPC should therefore be the starting point for most projects that aim to build on cstwMPC.

cstwMPC Replication Made using the ARK

To replicate estimates and output like those in the paper:

  1. Install Anaconda for Python 3
  2. In the Anaconda terminal (Windows) or Unix-like terminal (other OS):
    • Navigate to ./Code/
    • run "pip install -r requirements.txt"
  3. Run Spyder, and open ./do_min, ./do_mid.py, ./do_all.py, or ./do_custom.py
  4. Run the code by clicking the green arrow button.

Alternatively, you can execute any of the files from the command line, e.g.

`ipython do_min.py`

Running do_min.py will estimate two simple specifications of the model, with no aggregate shocks.

This takes a few minutes to run-- approximately 10-15 minutes on a typical computer.

Running do_mid.py will estimate the two main specifications reported in the paper

This takes several hours to run.

Running do_custom.py will let you choose exactly which model to estimate

Progress will be printed to screen when these files are run.

cstwmpc's People

Contributors

llorracc avatar sbenthall avatar mriduls avatar

Stargazers

Josephbkt avatar Alan Lujan avatar Manuel Alcalá Kovalski avatar Patrick Kofod Mogensen avatar

Watchers

James Cloos avatar  avatar  avatar

cstwmpc's Issues

Clean out legacy code from development branch

After #5 , a development branch for this repository should be chosen.

This branch should only contain that code which is relevant to the functioning of the REMARK.

There is a lot of legacy code here, including apparently a copy of HARK.
Even if there is valuable legacy code in this repository, there's no need to have it in the development branch: it will always be available in the stable release cut before it was removed.

Issue with parallel warning

When you try to run do_min.py, during the execution of the beta distribution model, you get the following output:

Beginning an estimation with the specification name PYbetaDistIndNetWorth...
getKYratioDifference tried center = 0.95 and got -9.73574471397209
getKYratioDifference tried center = 0.995 and got 108.10737279427268
getKYratioDifference tried center = 0.953717726766 and got -9.701892400680814
getKYratioDifference tried center = 0.974358863383 and got -9.318167745132815
getKYratioDifference tried center = 0.984679431691 and got -6.177290169150552
getKYratioDifference tried center = 0.989839715846 and got 14.451949165200366
getKYratioDifference tried center = 0.986224644875 and got -3.033018049642135
getKYratioDifference tried center = 0.987456628336 and got 0.9310485365679941
getKYratioDifference tried center = 0.987167269826 and got -0.14252313644736248
getKYratioDifference tried center = 0.98720568392 and got -0.005530837946649214
getKYratioDifference tried center = 0.987207225666 and got 2.3644569774106117e-05
getKYratioDifference tried center = 0.987206725666 and got -0.001770311032350591
findLorenzDistanceAtTargetKY tried spread = 0.006 and got 10.557361576875467
getKYratioDifference tried center = 0.95 and got -9.734329349907803
getKYratioDifference tried center = 0.995 and got 150.10485470647563
getKYratioDifference tried center = 0.95274053464 and got -9.709581660552622
getKYratioDifference tried center = 0.97387026732 and got -9.317729861064027
getKYratioDifference tried center = 0.98443513366 and got -4.2048296989541445
getKYratioDifference tried center = 0.98971756683 and got 23.17116211727427
getKYratioDifference tried center = 0.98524649173 and got -2.2595894490413553
getKYratioDifference tried center = 0.986105223383 and got 0.41503113163824246
getKYratioDifference tried center = 0.985971970699 and got -0.04742782606564511
getKYratioDifference tried center = 0.985985636528 and got -0.0008789954362544705
getKYratioDifference tried center = 0.985986136528 and got 0.0008280712433954562
findLorenzDistanceAtTargetKY tried spread = 0.008 and got 4.926370337581616
getKYratioDifference tried center = 0.95 and got -9.73111352958761
Traceback (most recent call last):

  File "<ipython-input-1-0e9883c01aa9>", line 1, in <module>
    runfile('U:/gsr_2019/REMARK/REMARKs/cstwMPC/do_min.py', wdir='U:/gsr_2019/REMARK/REMARKs/cstwMPC')

  File "C:\Users\bdwyer\AppData\Local\Continuum\anaconda3\envs\py2\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Users\bdwyer\AppData\Local\Continuum\anaconda3\envs\py2\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 95, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "U:/gsr_2019/REMARK/REMARKs/cstwMPC/do_min.py", line 27, in <module>
    exec(open('cstwMPC_MAIN.py').read())

  File "<string>", line 681, in <module>

  File "C:\Users\bdwyer\AppData\Local\Continuum\anaconda3\envs\py2\lib\site-packages\scipy\optimize\_minimize.py", line 771, in minimize_scalar
    return _minimize_scalar_brent(fun, bracket, args, **options)

  File "C:\Users\bdwyer\AppData\Local\Continuum\anaconda3\envs\py2\lib\site-packages\scipy\optimize\optimize.py", line 2115, in _minimize_scalar_brent
    brent.optimize()

  File "C:\Users\bdwyer\AppData\Local\Continuum\anaconda3\envs\py2\lib\site-packages\scipy\optimize\optimize.py", line 1899, in optimize
    xa, xb, xc, fa, fb, fc, funcalls = self.get_bracket_info()

  File "C:\Users\bdwyer\AppData\Local\Continuum\anaconda3\envs\py2\lib\site-packages\scipy\optimize\optimize.py", line 1876, in get_bracket_info
    xb=brack[1], args=args)

  File "C:\Users\bdwyer\AppData\Local\Continuum\anaconda3\envs\py2\lib\site-packages\scipy\optimize\optimize.py", line 2304, in bracket
    fc = func(*((xc,) + args))

  File "<string>", line 679, in <lambda>

  File "<string>", line 523, in findLorenzDistanceAtTargetKY

  File "C:\Users\bdwyer\AppData\Local\Continuum\anaconda3\envs\py2\lib\site-packages\scipy\optimize\zeros.py", line 754, in brentq
    r = _zeros._brentq(f, a, b, xtol, rtol, maxiter, args, full_output, disp)

  File "<string>", line 522, in <lambda>

  File "<string>", line 483, in getKYratioDifference

  File "<string>", line 172, in solve

  File "C:\Users\bdwyer\AppData\Local\Continuum\anaconda3\envs\py2\lib\site-packages\econ_ark-0.10.1.dev3-py2.7.egg\HARK\core.py", line 979, in solveAgents
    if self.print_parallel_error_once:

AttributeError: 'cstwMPCmarket' object has no attribute 'print_parallel_error_once'

If you comment out lines 976-86 of core.py in HARK and re-indent, as below:

        # try:
        #     multiThreadCommands(self.agents, ['solve()'])
        # except Exception as err:
        #     if self.print_parallel_error_once:
        #         # Set flag to False so this is only printed once.
        #         self.print_parallel_error_once = False
        #         print("**** WARNING: could not execute multiThreadCommands in HARK.core.Market.solveAgents() ",
        #               "so using the serial version instead. This will likely be slower. "
        #               "The multiTreadCommands() functions failed with the following error:", '\n',
        #               sys.exc_info()[0], ':', err)  # sys.exc_info()[0])
        multiThreadCommandsFake(self.agents, ['solve()'])

the error does not arise. I suspect there's some error in the way the print_parallel_error_once attribute of the Market class is being inherited by the cstwMPCmarket when the solution is parallelized.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.