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_param_specific_objects(complex_, choice_set, ...)

Create param specific objects.

_create_choice_rewards(states, choice_set, optim_paras)

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

_solve_with_backward_induction(state_space, ...)

Calculate utilities with backward induction.

_full_solution(wages, nonpecs, continuation_values, ...)

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.

Examples

>>> import respy as rp
>>> params, options = rp.get_example_model("robinson_crusoe_basic", with_data=False)
>>> solve = rp.get_solve_func(params, options)
>>> state_space = solve(params)
respy.solve.solve(params, options, state_space)[source]#

Solve the model.

respy.solve._create_param_specific_objects(complex_, choice_set, optim_paras, options, dense_key_to_dense_covariates, transit_keys=None)[source]#

Create param specific objects.

This function creates objects that are not fixed for a given model. Depending on their size they are either kept in working memory such as wages or dumped on disk such as transition probabilities! In the medium run we could also allow for fixed params here by saving values on disk directly! For objects that we store on disk we will just return the prefix of the location.

respy.solve._create_choice_rewards(states, choice_set, optim_paras)[source]#

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

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.