Code Monkey home page Code Monkey logo

soepy's Introduction

soepy

soepy is an open-source Python package for the simulation and estimation of a dynamic model of human capital accumulation tailored to the German Socio-Economic Panel (SOEP). We build on the seminal paper by Blundell & al. (2016) cited below.

Richard Blundell, Monica Costa Dias, Costas Meghir, Jonathan Shaw (2016). Female labor supply, human capital, and welfare reform. Econometrica, 84(5): 1705-1753.

Build Status Codacy Badge codecov Anaconda-Server Badge License: MIT

soepy's People

Contributors

boryana-ilieva avatar maxblesch avatar sebecker avatar tobiasraabe avatar

Stargazers

Jeremiah avatar mdheller avatar Maxi Schaller avatar Josh Martin avatar Nik Dawson avatar Alan Lujan avatar  avatar  avatar Debasmita Das avatar Marcus Fraaß avatar Mahdi Ben Jelloul avatar  avatar

Watchers

James Cloos avatar Davoud Taghawi-Nejad avatar  avatar Kostas Georgiou avatar

soepy's Issues

refactor attr_dict

I am not too happy with your use of the attr_dict here (and my use in respy). Instead, I would like us to try the use of a NamedTuple https://pymotw.com/2/collections/namedtuple.html for the immutable model_parameters. Let us discuss on our talk tomorrow ...

  • access attributes directly and not by first creating local variables
  • also interesting for the optim paras to move to the label-based approach, at the moment we are still using position-based

set up Anaconda packing

We want to set up an Anaconda package which then allows for collaborative work on colab.google as this requires the installation of soepy.

automatic PR testing

Please ensure that all integrations are also set up with GITHUB so that our PR's are tested with all our quality indicators i.e. travis, codacy, etc

ose_utils

Integrate use of ose_utils library for in testing harness.

proper setup of public package's public functions

Please set up the __init__.py to provide the package's public functions properly by adding, for example,

from soepy.python.simulate.simulate_python import simulate
allowing direct access to soepy.simulate.

refactor education level assignment

We want to revisit the assignment of levels of education based on the years of education the individuals in the data have completed.

Note:
In order to speed up regression tests and ensure that robustness tests are running properly at the same time, we reduced the years of education in the simulated data from 14 to 12. For this value, the only education levels now observed in the data frame is low [1,0,0].

Increasing the coverage rate

The current coverage rate of the master branch is only 83%. This seems to be driven by the relatively low coverage of the shared_auxiliary.py and the solve_auxiliary.py modules. In addition the Codecov batch does not reflect the current coverage rate of the project (It seems like Codecov hasn't run an analysis since 1 month ago.).

We would like to achieve a coverage rate above 90% (green batch). For this purpose we should add new tests to our test framework or adjust already existing ones.

Add test for example init files

We want to make sure that, at every point in time, the current version of the code can simulate based on the example init files included in doc/tutorial/.

PACKAGE_DIR path

PACKAGE_DIR points one level higher than soepy and at the root of the repository. I would like us to not reference anything outside package itself there. So, instead of

PACKAGE_DIR = Path(__file__).parent.parent.absolute() TEST_RESOURCES_DIR = PACKAGE_DIR / "soepy" / "test" / "resources"

we should use

PACKAGE_DIR = Path(__file__).parent.absolute() TEST_RESOURCES_DIR = PACKAGE_DIR / "test" / "resources"
However, this requires to check how the tests that use the two paths are affected.

turn off DeprecationWarnings from matplotlib

============================================================================================= warnings summary =============================================================================================
/home/peisenha/.local/share/anaconda3/lib/python3.7/site-packages/matplotlib/rcsetup.py:20: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Iterable, Mapping

/home/peisenha/.local/share/anaconda3/lib/python3.7/site-packages/matplotlib/colors.py:53: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Sized

/home/peisenha/.local/share/anaconda3/lib/python3.7/site-packages/yaml/constructor.py:126: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
if not isinstance(key, collections.Hashable):

-- Docs: https://docs.pytest.org/en/latest/warnings.html

fix regression tests runner

python regression_vault.py  --request check --num 10

Traceback (most recent call last):
  File "regression_vault.py", line 105, in <module>
    check_vault()
  File "regression_vault.py", line 70, in check_vault
    df = simulate("test.grmpy.yml")
  File "/home/peisenha/OpenSourceEconomics/soepy/soepy/python/simulate/simulate_python.py", line 13, in simulate
    model_params = read_init_file(init_file_name)
  File "/home/peisenha/OpenSourceEconomics/soepy/soepy/python/pre_processing/model_processing.py", line 10, in read_init_file
    with open(init_file_name) as y:
FileNotFoundError: [Errno 2] No such file or directory: 'test.grmpy.yml'

locking down user interface

We want to develop a nice and strict setup for testing the user input so in exchange do much less testing further down the code by using immutable objects wherever possible. In addition, we want to ensure informative error messages for the user input as well

list unpacking

states_all, states_number_period, mapping_states_index, max_states_period = (
state_space_args[0],
state_space_args[1],
state_space_args[2],
state_space_args[3],
)

This can just be replaced by ...

states_all, states_number_period, mapping_states_index, max_states_period = state_space_args

use of list comprehension

draws_sim = draw_disturbances(
model_params.seed_sim,
model_params.shocks_cov,
model_params.num_periods,
model_params.num_agents_sim,
)

This was bugging me all day today, so here is a Pythonic solution.

attrs = ['seed_sim', 'shocks_cov', 'num_periods', 'num_agents_sim']
draws_sim = draw_disturbances(*[getattr(model_params, attr) for attr in attrs])

horizontal entries for coefficients values and their labels

optim_paras:
- 5.406
- 5.574
- 6.949
- 0.152
- 0.229
- 0.306
- 0.150
- 0.096
- 0.116
- 0.081
- 0.057
- 0.073
- -0.10
- -0.30
- 1.00
- 1.25
- 1.60
order:
- gamma_0s1
- gamma_0s2
- gamma_0s3
- gamma_1s1
- gamma_1s2
- gamma_1s3
- g_s1
- g_s2
- g_s3
- delta_s1
- delta_s2
- delta_s3
- theta_p

Can we please have horizontal entries, so the label is clearly mapped to the value?

state space representation

Fedor suggested a more memory-efficient setup for storing the state space elements. We could consider moving there as well to preempt future problems. This issue serves as a reminder.

regression vault

Review the need to generate new regression vault after refactor.
To Dos:

  • adjust data frame to account for benefits
  • change assignment of level of education according to new reduced range of years of education in the simulated sample.

increase codacy grade

We want to have an A from the automated code review. Some of the raised issues (for example security) are not relevant for us but these can then be removed from inspection through proper codacy configuration.

please add pip to environment file

... so this is not an issue anymore.

/Desktop/soepy$ conda env create -f environment.yml
Warning: you have pip-installed dependencies in your environment file, but you do not list pip itself as one of your conda dependencies. Conda may not use the correct pip to install your packages, and they may end up in the wrong place. Please add an explicit pip dependency. I'm adding one for you, but still nagging you.
Collecting package metadata: done

setattr to set attr with string

This code

def create_namedtuple(init_dict):
"""Transfers model specification from a dictionary
to a named tuple class object."""
model_params = cl.namedtuple("model_parameters", "")
model_params.num_periods = init_dict["GENERAL"]["num_periods"]
model_params.num_choices = init_dict["GENERAL"]["num_choices"]
model_params.delta = init_dict["CONSTANTS"]["delta"]
model_params.mu = init_dict["CONSTANTS"]["mu"]
model_params.benefits = init_dict["CONSTANTS"]["benefits"]
model_params.educ_max = init_dict["INITIAL_CONDITIONS"]["educ_max"]
model_params.educ_min = init_dict["INITIAL_CONDITIONS"]["educ_min"]
model_params.seed_sim = init_dict["SIMULATION"]["seed_sim"]
model_params.num_agents_sim = init_dict["SIMULATION"]["num_agents_sim"]
model_params.seed_emax = init_dict["SOLUTION"]["seed_emax"]
model_params.num_draws_emax = init_dict["SOLUTION"]["num_draws_emax"]

can be easily replaced by

    for group in init_dict.keys():
        for label in init_dict[group].keys():
            setattr(model_params, label,  init_dict[group][label])

Update developer docs

Document the new form of the state space, the backward induction and the simulation procedure. Introduce the changes due to numba and model extensions types and kids as version 0.2

python -c "import soepy; soepy.test()"

Please restructure the content of the __init__.py`` files so that the command in the header executes the pytest library and also add this call to the the travis script. Please also move the soepy_config.py`one level up.

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.