commit notes for issues to raise pull request notes etc - npalmer-professional/HARK-1 GitHub Wiki

Few things:

Thought it would be an easy merge but a few things have come up: 1. difference between py2 and py3 imports in package. Now must use absolute import style particuarlly in packages. Figured it out but took a bit. 2. took some time to figure out the appropriate way to bring my fork up to the most recent version of econ-ARK 3. the "remove spaces" update a while back means every diff file I'd look at has 200 diffs pop up per file. Here's a common view from my diff tool: ...blah. There were definitely a handful of non-trivial edits I had to make in a few places (for example, Py2 and Py3 handle "None" differently in inequality comaprisons) that I'd assumed would be obvious from the diffs... but they aren't. Ah well. Will just plough through this. - Note: this made me miss some non-trivial code updates that I had to re-hunt-down. Still faster than first time but whew, caused extra pile-on time. (eg. when fixed the default-to-serial thing in core.py, after missing it initially, had to re-test a number of things to confirm the fix didn't introduce bugs.) 4. also, package structure means can't direclty run "main" files in Py3 (related to imports difference between py2 and py3 again). As temporary fix so I can run tests I replaced "if name == 'main':" with "def demo():", as sugested bu Jason previously, and that's been working well. This will be eventually turned into notebooks.

Items 1. and 2. I discussed / cleared with Jason (just to be sure I was doing reasonable things) starting here if you're interested: ...I have some links to useful resources related to both topics there.

Side note: there are a lot more cross-dependencies between files than I expected. HARK.parallel is called from more than one place in the "standard" files, and always needs to be updated at same time as the core.

NOTE: need to put these issues in after putting in the merge request:

For ./HARK/ConsumptionSaving/ConsMarkovModel.py we get the following error when trying to run the "main" demo:

AttributeError: 'MarkovSmallOpenEconomy' object has no attribute 'PermShkAggDstn'

In [1]: from HARK.ConsumptionSaving import ConsMedModel In [2]: ConsMedModel.demo() HARK/ConsumptionSaving/ConsMedModel.py:629: RuntimeWarning: divide by zero encountered in power vPgrid = cLvlGrid**(-self.CRRA) HARK/utilities.py:140: RuntimeWarning: divide by zero encountered in reciprocal return( c**(1.0 - gam) / (1.0 - gam) ) HARK/utilities.py:140: RuntimeWarning: divide by zero encountered in power return( c**(1.0 - gam) / (1.0 - gam) ) HARK/ConsumptionSaving/ConsMedModel.py:643: RuntimeWarning: invalid value encountered in multiply vGrid = utility(cLvlGrid,gam=self.CRRA) + MedShkGrid_tiled*utility(MedGrid,gam=self.CRRAmed) HARK/ConsumptionSaving/ConsIndShockModel.py:707: RuntimeWarning: divide by zero encountered in double_scalars self.PatFac/solution_next.MPCmax)

NOTE: /home/npalmer/workspace/HARK-1/HARK/ConsumptionSaving/Demos/Chinese_Growth.py doesn't produce any plots?

  • submit this as an issue along with PR.

NOTE: renamed Try-Alternative-Parameter-Values.py to TryAlternativeParameterValues.py to make it import-able.

NOTE: Under Python 3, we now get this error when running FashionVictim.demo():

AttributeError: Can't pickle local object 'FashionVictimType.update.<locals>.<lambda>'

This appears to be a difference in how pickle works under old vs new Py. Hmmmmm. Need to do two things:

  1. Actually track down and solve this error
  2. Add a flag to this model, and perhaps all models, that allow the user to explicitly run the model in non-parallel mode. My current temporary solution in core.py attempts parallel first, and if that breaks, prints a warning then defaults to serial. UNCLEAR THIS IS THE BEST APPROACH!

NOTE: Error that appears when running StructuralEstimation:

AttributeError: 'TempConsumerType' object has no attribute 'PermGroFacAgg'

Because I wanted to ge this running, I appled the "quick fix" of just adding this attribute to the EstimationParameters.py file. See that file for how to make this error re-appear for fixing purposes. Longer-term we should probably make this a nicer fix by changing the method call.

Note: for cstwMPC this integer division needs to be confirmed as correct: This line: replication_factor = len(self.agents)/param_count replaced with this line: replication_factor = len(self.agents) // param_count NOTE ALSO that using "old_div" doesn't work under my standard Anaconda install, because (according to Google) I need to do an extra instalation step. I think that is highly not desirable here for many reasons.

Note: for these files for cstwMPC, there are some errors that appear to be because the values just don't exist:

  • MakeCSTWfigsForSlides:

    • from HARK.cstwMPC import MakeCSTWfigsForSlides
    • NameError: name 'InfiniteType' is not defined
  • MakeCSTWfigs:

    • from HARK.cstwMPC import MakeCSTWfigs
    • FileNotFoundError: [Errno 2] No such file or directory: './HARK-1/HARK/cstwMPC/Results/LCbetaPointNetWorthLorenzFig.txt'

Note: this files in cstwMPC were not updated:

  • cstwMPCold.py
  • SetupParamsCSTWold.py

Need to confirm if they need updating.

cstwMPC, cAndCwithStickyE,

Note: In cstwMPC, for a number of files we need to explicitly define the path to the current file. This is due to the new HARK package structure. Here's the line I use in these files to fine the current file path (what we typically would refer to as "./") : import os my_file_path = os.path.dirname(os.path.abspath(file))

Note: In cAndCwithStickyE, for a number of files we need to explicitly define the path to the current file. This is due to the new HARK package structure. Here's the line I use in these files to fine the current file path (what we typically would refer to as "./") : import os my_file_path = os.path.dirname(os.path.abspath(file))

Note: In cAndCwithStickyE.StickyEtools, I had to make all strings "raw" strings because otherwise the "\u" characters messed things up. Essentially that means starting all strings with the letter 'r'. For example: "a string" becomes r"a string" This needs to be confirmed as reasonable by someone who uses this regularly.

Note: In cAndCwithStickyE.StickyE_MAIN, the only procedures that were tested were -- further testing by another person familiar with the code should likely be done:

# Choose which models to do work for
do_SOE  = False
do_DSGE = False
do_RA   = True

# Choose what kind of work to do for each model
run_models = True       # Whether to solve models and generate new simulated data
calc_micro_stats = False # Whether to calculate microeconomic statistics (only matters when run_models is True)
make_tables = False      # Whether to make LaTeX tables in the /Tables folder
use_stata = False        # Whether to use Stata to run the simulated time series regressions
save_data = False        # Whether to save data for use in Stata (as a tab-delimited text file)
run_ucost_vs_pi = False  # Whether to run an exercise that finds the cost of stickiness as it varies with update probability
run_value_vs_aggvar = False # Whether to run an exercise to find value at birth vs variance of aggregate permanent shocks

Note: on HARK-1/Testing/ I simply confirmed that these files would execute. It is unclear if these are doing what we want them to do, however they are lowest on the priority list so I leave them as-is.

⚠️ **GitHub.com Fallback** ⚠️