respy.solve

Everything related to the solution of a structural model.

Module Contents

Functions

get_solve_func(params, options)

Get the solve function.

solve(params, options, state_space)

Solve the model.

_create_choice_rewards(complex_, choice_set, optim_paras, options)

Create wage and non-pecuniary reward for each state and choice.

_solve_with_backward_induction(state_space, optim_paras, options)

Calculate utilities with backward induction.

_full_solution(wages, nonpecs, continuation_values, period_draws_emax_risk, optim_paras)

Calculate the full solution of the model.

respy.solve.get_solve_func(params, options)[source]

Get the solve function.

This function takes a model specification and returns the state space of the model along with components of the solution such as covariates, non-pecuniary rewards, wages, continuation values and expected value functions as attributes of the class.

Parameters
paramspandas.DataFrame

DataFrame containing parameter series.

optionsdict

Dictionary containing model attributes which are not optimized.

Returns
solvesolve()

Function with partialed arguments.

respy.solve.solve(params, options, state_space)[source]

Solve the model.

respy.solve._create_choice_rewards(complex_, choice_set, optim_paras, options)[source]

Create wage and non-pecuniary reward for each state and choice.

In particular the function retrieves dense period choice cores with all covariates (they have aready been calculated in the construction of the state space) from disk. Thereafter the function obtains rewards for choices for each state based on the pre calculated covariates.

Returns
wagesnp.array

Array with dimensions n_states x n_choices. Contains all wages for a particular state choice combination within a dense period choice core.

nonpecsnp.array

Array with dimensions n_states x n_choices. Contains all nonpecs for a particular state choice combination within a dense period choice core.

respy.solve._solve_with_backward_induction(state_space, optim_paras, options)[source]

Calculate utilities with backward induction.

The expected value functions in one period are only computed by interpolation if:

  1. Interpolation is requested.

  2. If there are more states in the period than interpolation points.

  3. If there are at least two interpolation points per dense_index.

Parameters
state_spaceStateSpace

State space of the model which is not solved yet.

optim_parasdict

Parsed model parameters affected by the optimization.

optionsdict

Optimization independent model options.

Returns
state_spaceStateSpace
respy.solve._full_solution(wages, nonpecs, continuation_values, period_draws_emax_risk, optim_paras)[source]

Calculate the full solution of the model.

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

Array containing expected value function for each state.