respy.tests._former_code

Module Contents

Functions

_create_state_space_kw94(n_periods, n_types, edu_starts, edu_max)

Create the state space.

_create_state_space_kw97_base(n_periods, n_types, edu_starts, edu_max)

Create the state space for the base model of Keane and Wolpin (1997).

_create_state_space_kw97_extended(n_periods, n_types, edu_starts, edu_max)

Create the state space for the extended model of Keane and Wolpin (1997).

respy.tests._former_code._create_state_space_kw94(n_periods, n_types, edu_starts, edu_max)[source]

Create the state space.

The state space consists of all admissible combinations of the following elements: period, experience in OCCUPATION A, experience in OCCUPATION B, years of schooling, the lagged choice and the type of the agent.

The major problem which is solved here is that the natural representation of the state space is a graph where each parent node is connected with its children’s nodes. This structure makes it easy to traverse the graph. In contrast to that, for many subsequent calculations, e.g. generating the covariates for each state, a tabular format has better performance, but looses the information on the connections.

The current implementation of states and indexer allows to have both advantages at the cost of an additional object. states stores the information on states in a tabular format. indexer is a matrix where each characteristic of the state space represents one dimension. The values of the matrix are the indices of states in states. Traversing the state space is as easy as incrementing the right indices of indexer by 1 and use the resulting index in states.

Parameters
n_periodsint

Number of periods in the state space.

n_typesint

Number of types of agents.

edu_startsnumpy.ndarray

Contains levels of initial education.

edu_maxint

Maximum level of education which can be obtained by an agent.

Returns
statesnumpy.ndarray

Array with shape (n_states, 6) containing period, experience in OCCUPATION A, experience in OCCUPATION B, years of schooling, the lagged choice and the type of the agent.

indexernumpy.ndarray

A matrix where each dimension represents a characteristic of the state space. Switching from one state is possible via incrementing appropriate indices by 1.

Examples

>>> n_periods = 40
>>> n_types = 1
>>> edu_starts, edu_max = np.array([10]), 20
>>> states, indexer = _create_state_space_kw94(
...     n_periods, n_types, edu_starts, edu_max
... )
>>> states.shape
(317367, 6)
>>> len(indexer)
40
>>> indexer[-1].shape
(40, 40, 21, 4, 1)
respy.tests._former_code._create_state_space_kw97_base(n_periods, n_types, edu_starts, edu_max)[source]

Create the state space for the base model of Keane and Wolpin (1997).

Examples

>>> n_periods = 40
>>> n_types = 1
>>> edu_starts, edu_max = np.array([10]), 20
>>> states, indexer = _create_state_space_kw97_base(
...     n_periods, n_types, edu_starts, edu_max
... )
>>> states.shape
(848672, 6)
>>> len(indexer)
40
>>> indexer[-1].shape
(40, 40, 40, 21, 1)
respy.tests._former_code._create_state_space_kw97_extended(n_periods, n_types, edu_starts, edu_max)[source]

Create the state space for the extended model of Keane and Wolpin (1997).

Examples

>>> n_periods = 40
>>> n_types = 1
>>> edu_starts, edu_max = np.array([10]), 20
>>> states, indexer = _create_state_space_kw97_extended(
...     n_periods, n_types, edu_starts, edu_max
... )
>>> states.shape
(3770152, 7)
>>> len(indexer)
40
>>> indexer[-1].shape
(40, 40, 40, 21, 5, 1)