dcegm

Submodules

Classes

Package Contents

class dcegm.setup_model(model_config: Dict, model_specs: Dict, utility_functions: Dict[str, Callable], utility_functions_final_period: Dict[str, Callable], budget_constraint: Callable, state_space_functions: Dict[str, Callable] = None, stochastic_states_transitions: Dict[str, Callable] = None, shock_functions: Dict[str, Callable] = None, alternative_sim_specifications: Dict[str, Callable] = None, debug_info: str = None, model_save_path: str = None, model_load_path: str = None, use_stochastic_sparsity: bool = False)
model_specs
specs_without_jax
model_config
model_funcs
model_structure
batch_info
params_check_info
income_shock_draws_unscaled
income_shock_weights
solve(params, load_sol_path=None, save_sol_path=None)

Solve a discrete-continuous life-cycle model using the DC-EGM algorithm.

Parameters:
  • params (pd.DataFrame) – Params DataFrame.

  • options (dict) – Options dictionary.

  • utility_functions (Dict[str, callable]) – Dictionary of three user-supplied functions for computation of: (i) utility (ii) inverse marginal utility (iii) next period marginal utility

  • budget_constraint (callable) – Callable budget constraint.

  • state_space_functions (Dict[str, callable]) – Dictionary of two user-supplied functions to: (i) get the state specific feasible choice set (ii) update the endogenous part of the state by the choice

  • final_period_solution (callable) – User-supplied function for solving the agent’s last period.

  • transition_function (callable) – User-supplied function returning for each state a transition matrix vector.

solve_and_simulate(params, states_initial, seed, load_sol_path=None, save_sol_path=None)

Solve the model and simulate it.

Parameters:
  • params – The parameters for the model.

  • states_initial – The initial states for the simulation.

  • wealth_initial – The initial wealth for the simulation.

  • n_periods – The number of periods to simulate.

  • seed – The random seed for the simulation.

  • alt_model_funcs_sim – Alternative model functions for simulation.

Returns:

A dictionary containing the solution and simulation results.

get_solve_func()

Create a fast function for solving that is jit compiled in the first call.

get_solve_and_simulate_func(states_initial, seed)

Create a fast function for solving and simulation that is jit compiled in the first call.

create_experimental_ll_func(params_all, observed_states, observed_choices, unobserved_state_specs=None, return_model_solution=False, use_probability_of_observed_states=True, slow_version=False)
validate_exogenous(params)
get_state_choices_idx(states)

Get the indices of the state choices for given states.

get_child_states(state, choice)
get_child_states_and_calc_trans_probs(state, choice, params)

Get the child states for a given state and choice and calculate the transition probabilities.

get_full_child_states_by_asset_id_and_probs(state, choice, params, asset_id, second_continuous_id=None)

Get the child states for a given state and choice and calculate the transition probabilities.

compute_law_of_motions(params)
get_n_state_choices_per_period()
solve_partially(params, n_periods, return_candidates=False)
set_alternative_sim_funcs(alternative_sim_specifications, alternative_specs=None)