Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reference guide about the state space. #372

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

mo2561057
Copy link
Member

@mo2561057 mo2561057 commented Jul 29, 2020

Complete reference guide for the new state space.

Todo

  • Add key terms to glossary.

@codecov
Copy link

codecov bot commented Jul 29, 2020

Codecov Report

Merging #372 into main will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #372   +/-   ##
=======================================
  Coverage   85.43%   85.43%           
=======================================
  Files          47       47           
  Lines        3418     3418           
=======================================
  Hits         2920     2920           
  Misses        498      498           
Flag Coverage Δ
#end_to_end 74.69% <100.00%> (ø)
#integration 65.03% <100.00%> (ø)
#unit 68.78% <100.00%> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
respy/interpolate.py 95.12% <ø> (ø)
respy/solve.py 100.00% <ø> (ø)
respy/state_space.py 88.05% <ø> (ø)
respy/tests/test_randomness.py 100.00% <ø> (ø)
respy/tests/test_replication_kw_94.py 36.84% <ø> (ø)
docs/conf.py 100.00% <100.00%> (ø)
respy/interface.py 89.47% <100.00%> (ø)
respy/tests/test_parallelization.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1162210...1769eba. Read the comment docs.

@tobiasraabe tobiasraabe changed the title Ref state space Add reference guide about the state space. Jul 29, 2020
Copy link
Member

@tobiasraabe tobiasraabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not particular confident in the review myself :). Maybe we should talk tomorrow to resolve the issue. We should both read this section (https://respy--372.org.readthedocs.build/en/372/development/contributing_to_respy.html#types-of-documents) and the link to find out where we want to go with this.

groups. This guide contains an explanation the most important components of the state
space.

The implementation of the state space in respy serves several purposes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this paragraph should be split into two parts.

The first part defines what is meant by the state space which is exactly what you do in the beginning. If you feel you delve too much into the economics, you could draft references to the explanations written by Rafael and Benedikt.

The other part defines the problem we need to solve. Talk about memory demands. Reference the curse of the dimensionality. Maybe a back-of-the-envelop calculation: 52 Mio states for KW97. A float64 variables costs 400mb and int8 52mb. The other part defines the problem we need to solve. Talk about memory demands. Reference the curse of the dimensionality. Maybe a back-of-the-envelop calculation: 52 Mio states for KW97. A float64 variables costs 400mb and int8 52mb. What is a float? 10 wages and nonpecs, 1 expected vlaue functions, temporariliy 5 continuation values, 4 of 16 coviarates-> 20 * 400mb = 8GB. What is uint8? 6 state dimensions, 12 covariates -> 18 * 52MB = 1GB.

Then, I could also add some history information. The evolution of the state space: storing all states in tabular format and having a matrix to find child states -> having core states in tabular format and adding dense information if necessary combined with period specific indexer.

a tuple for the choice set which contains booleans for whether a choice is available.
The complex index for a dense index also contains the dense vector in the last position.
Communication
-------------

.. _state_space_methods:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following are docstrings.


Returns
----------
wages : np.array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wages : np.array
wages : numpy.ndarray

Array with dimensions n_states x n_choices.
Contains all wages for a particular state choice
combination within a dense period choice core.
nonpecs : np.array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nonpecs : np.array
nonpecs : numpy.ndarray

This is the correct type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you need to write out numpy and pandas

@@ -171,6 +189,10 @@ def _full_solution(
In contrast to approximate solution, the Monte Carlo integration is done for each
state and not only a subset of states.

Returns
----------
period_expected_value_functions: np.array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
period_expected_value_functions: np.array
period_expected_value_functions: numpy.ndarray


See also
--------
See :ref:`state space location indices <state_space_location_indices>`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no indent.

@@ -331,6 +366,11 @@ def set_attribute_from_keys(self, attribute, value):
value : numpy.ndarray
The value to which the Numpy array is set.

See also
--------
A more theoretical explanation can be found here: See :ref:`set attribute
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no ikndent.

essentially copies the full state space. The disjunction makes use of this property. By
expressing a state as a combination of a dense and a core state we avoid several
duplications.
.. _dense_grid:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that some of the information below should be moved to the attribute section in the docstring of the state space.

the objects are saved to disk after they are created and only called whenever
they are required.

Division
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partly attribute description or moved up where the separation by choice sets is explained.

@tobiasraabe tobiasraabe added this to the 2.0.1 milestone Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants