dcegm.egm.solve_euler_equation¶
Auxiliary functions for the EGM algorithm.
Functions¶
Calculate candidates for the optimal policy and value function. |
|
Write second continuous grid point into state_choice_vec. |
|
Compute optimal child-state- and choice-specific policy and value function. |
|
|
Solve the Euler equation for given discrete choice and child states. |
Module Contents¶
- dcegm.egm.solve_euler_equation.calculate_candidate_solutions_from_euler_equation(continuous_grids_info: jax.numpy.ndarray, marg_util_next: jax.numpy.ndarray, emax_next: jax.numpy.ndarray, state_choice_mat: jax.numpy.ndarray, idx_post_decision_child_states: jax.numpy.ndarray, model_funcs: Dict[str, Callable], has_second_continuous_state: bool, params: Dict[str, float]) Tuple[jax.numpy.ndarray, jax.numpy.ndarray, jax.numpy.ndarray, jax.numpy.ndarray]¶
Calculate candidates for the optimal policy and value function.
- dcegm.egm.solve_euler_equation.compute_optimal_policy_and_value_wrapper(marg_util_next: jax.numpy.ndarray, emax_next: jax.numpy.ndarray, second_continuous_grid: jax.numpy.ndarray, assets_grid_end_of_period: jax.numpy.ndarray, state_choice_vec: Dict, model_funcs: Dict[str, Callable], params: Dict[str, float]) Tuple[jax.numpy.ndarray, jax.numpy.ndarray, jax.numpy.ndarray, jax.numpy.ndarray]¶
Write second continuous grid point into state_choice_vec.
- dcegm.egm.solve_euler_equation.compute_optimal_policy_and_value(marg_util_next: jax.numpy.ndarray, emax_next: jax.numpy.ndarray, assets_grid_end_of_period: jax.numpy.ndarray, state_choice_vec: Dict, model_funcs: Dict[str, Callable], params: Dict[str, float]) Tuple[jax.numpy.ndarray, jax.numpy.ndarray, jax.numpy.ndarray, jax.numpy.ndarray]¶
Compute optimal child-state- and choice-specific policy and value function.
Given the marginal utilities of possible child states and next period wealth, we compute the optimal policy and value functions by solving the euler equation and using the optimal consumption level in the bellman equation.
- Parameters:
marg_utils (np.ndarray) – 1d array of shape (n_stochastic_states,) containing the state-choice specific marginal utilities for a given point on the savings grid.
emax (np.ndarray) – 1d array of shape (n_stochastic_states,) containing the state-choice specific expected maximum value for a given point on the savings grid.
assets_grid_end_of_period (np.ndarray) – 1d array of shape (n_grid_wealth,) containing the exogenous savings grid.
trans_vec_state (np.ndarray) – 1d array of shape (n_stochastic_states,) containing for each exogenous process state the corresponding transition probability.
state_choice_vec (np.ndarray) – A dictionary containing the states and a
vector. (corresponding admissible choice of a particular state choice)
compute_inverse_marginal_utility (Callable) – Function for calculating the inverse marginal utility, which takes the marginal utility as only input.
compute_value (callable) – Function for calculating the value from consumption level, discrete choice and expected value. The inputs
`discount_rate`and`compute_utility`are already partialled in.params (dict) – Dictionary of model parameters.
- Returns:
- endog_grid (np.ndarray): 1d array of shape (n_grid_wealth + 1,)
containing the current state- and choice-specific endogenous grid.
- policy (np.ndarray): 1d array of shape (n_grid_wealth + 1,)
containing the current state- and choice-specific policy function.
- value (np.ndarray): 1d array of shape (n_grid_wealth + 1,)
containing the current state- and choice-specific value function.
- expected_value_zero_savings (float): The agent’s expected value given that
she saves nothing.
- Return type:
tuple
- dcegm.egm.solve_euler_equation.solve_euler_equation(state_choice_vec: dict, marg_util_next: jax.numpy.ndarray, emax_next: jax.numpy.ndarray, compute_inverse_marginal_utility: Callable, compute_stochastic_transition_vec: Callable, params: Dict[str, float], discount_factor: float, interest_rate: float) Tuple[jax.numpy.ndarray, jax.numpy.ndarray]¶
Solve the Euler equation for given discrete choice and child states.
We integrate over the exogenous process and income uncertainty and then apply the inverese marginal utility function.
- Parameters:
marg_utils (np.ndarray) – 1d array of shape (n_stochastic_states,) containing the state-choice specific marginal utilities for a given point on the savings grid.
emax (np.ndarray) – 1d array of shape (n_stochastic_states,) containing the state-choice specific expected maximum value for a given point on the savings grid.
trans_vec_state (np.ndarray) – 1d array of shape (n_stochastic_states,) containing for each exogenous process state the corresponding transition probability.
compute_inverse_marginal_utility (callable) – Function for calculating the inverse marginal utility, which takes the marginal utility as only input. (n_stochastic_states, n_grid_wealth) with the maximum values.
params (dict) – Dictionary of model parameters.
- Returns:
- policy (np.ndarray): 1d array of the agent’s current state- and
choice-specific consumption policy. Has shape (n_grid_wealth,).
- expected_value (np.ndarray): 1d array of the agent’s current state- and
choice-specific expected value. Has shape (n_grid_wealth,).
- Return type:
tuple