dcegm.final_periods

Wrapper to solve the final period of the model.

Functions

solve_last_two_periods(params, continuous_states_info, ...)

Solves the last two periods of the model.

solve_final_period(→ Tuple[jax.numpy.ndarray, ...)

Compute solution to final period for policy and value function.

calc_value_and_marg_util_for_each_gridpoint(...)

calc_value_and_budget_for_each_gridpoint(...)

Module Contents

dcegm.final_periods.solve_last_two_periods(params: Dict[str, float], continuous_states_info: Dict[str, Any], model_structure: Dict[str, Any], cont_grids_next_period: Dict[str, Any], income_shock_weights: jax.numpy.ndarray, model_funcs: Dict[str, Any], upper_envelope_method: str, last_two_period_batch_info, value_solved, policy_solved, endog_grid_solved, debug_info)

Solves the last two periods of the model.

The last two periods are solved using the EGM algorithm. The last period is solved using the user-specified utility function and the second to last period is solved using the user-specified utility function and the user-specified bequest function.

Parameters:
  • wealth_beginning_of_period (np.ndarray) – 2d array of shape (n_states, n_grid_wealth) of the wealth at the beginning of the period.

  • params (dict) – Dictionary of model parameters.

  • compute_utility (callable) – User supplied utility function.

  • compute_marginal_utility (callable) – User supplied marginal utility function.

  • last_two_period_batch_info (dict) – Dictionary containing information about the batch size and the state space.

  • value_solved (np.ndarray) – 3d array of shape (n_states, n_grid_wealth, n_income_shocks) of the value function for all states, end of period assets, and income shocks.

  • endog_grid_solved (np.ndarray) – 3d array of shape (n_states, n_grid_wealth, n_income_shocks) of the endogenous grid for all states, end of period assets, and income shocks.

dcegm.final_periods.solve_final_period(idx_state_choices_final_period, idx_parent_states_final_period, state_choice_mat_final_period, cont_grids_next_period: Dict[str, Any], continuous_states_info: Dict[str, Any], upper_envelope_method: str, model_structure: Dict[str, Any], params: Dict[str, float], model_funcs: Dict[str, Any], value_solved, policy_solved, endog_grid_solved) Tuple[jax.numpy.ndarray, jax.numpy.ndarray, jax.numpy.ndarray, jax.numpy.ndarray, jax.numpy.ndarray]

Compute solution to final period for policy and value function.

In the last period, everything is consumed, i.e. consumption = savings. Args:

Returns:

  • marginal_utilities_choices (np.ndarray): 3d array of shape

    (n_states, n_grid_wealth, n_income_shocks) of the marginal utility of consumption for all final states, end of period assets, and income shocks.

  • final_value (np.ndarray): 3d array of shape

    (n_states, n_grid_wealth, n_income_shocks) of the optimal value function for all final states, end of period assets, and income shocks.

  • final_policy (np.ndarray): 3d array of shape

    (n_states, n_grid_wealth, n_income_shocks) of the optimal policy for all final states, end of period assets, and income shocks.

Return type:

tuple

dcegm.final_periods.calc_value_and_marg_util_for_each_gridpoint(state_choice_vec, continuous_state_vec, wealth, params, compute_utility, compute_marginal_utility)
dcegm.final_periods.calc_value_and_budget_for_each_gridpoint(state_choice_vec, continuous_state_vec, asset_grid_point_end_of_previous_period, params, compute_utility, compute_assets_begin_of_period, assets_begin)