dcegm.interpolation.interp1d¶
Functions¶
|
Linear interpolation formula. |
|
Get index of the highest value in x that is smaller than x_new. |
|
Interpolate policy and value function given a single wealth grid point. |
|
Interpolate value function on a single wealth point. |
|
Interpolate policy function on a single wealth point. |
Calculate the interpolated value with accounting for a possible credit |
Module Contents¶
- dcegm.interpolation.interp1d.linear_interpolation_formula(y_high: float | jax.numpy.ndarray, y_low: float | jax.numpy.ndarray, x_high: float | jax.numpy.ndarray, x_low: float | jax.numpy.ndarray, x_new: float | jax.numpy.ndarray)¶
Linear interpolation formula.
- dcegm.interpolation.interp1d.get_index_high_and_low(x, x_new)¶
Get index of the highest value in x that is smaller than x_new.
- Parameters:
x (np.ndarray) – 1d array of shape (n,) containing the x-values.
x_new (float) – The new x-value at which to evaluate the interpolation function.
- Returns:
- Index of the value in the wealth grid which is higher than x_new. Or in
case of extrapolation last or first index of not nan element.
- Return type:
int
- dcegm.interpolation.interp1d.interp1d_policy_and_value_on_wealth(wealth: float | jax.numpy.ndarray, wealth_grid: jax.numpy.ndarray, policy_grid: jax.numpy.ndarray, value_grid: jax.numpy.ndarray, compute_utility: Callable, state_choice_vec: Dict[str, int], params: Dict[str, float], discount_factor) Tuple[float, float]¶
Interpolate policy and value function given a single wealth grid point.
- Parameters:
wealth (float | jnp.ndarray) – New wealth point(s) to interpolate.
wealth_grid (jnp.ndarray) – Solved endogenous wealth grid.
policy_grid (jnp.ndarray) – Solved policy function.
value_grid (jnp.ndarray) – Solved value function.
state_choice_vec (Dict) – Dictionary containing a single state and choice.
params (Dict) – Dictionary containing the model parameters.
- Returns:
policy_interp (float): Interpolated optimal policy for wealth.
value_interp (float): Interpolated value for wealth.
- Return type:
tuple
- dcegm.interpolation.interp1d.interp_value_on_wealth(wealth: float | jax.numpy.ndarray, wealth_grid: jax.numpy.ndarray, value: jax.numpy.ndarray, compute_utility: Callable, state_choice_vec: Dict[str, int], params: Dict[str, float], discount_factor: float) jax.numpy.ndarray | float¶
Interpolate value function on a single wealth point.
- Parameters:
wealth (float) – New wealth point to interpolate.
wealth_grid (jnp.ndarray) – Solved endogenous wealth grid.
value (jnp.ndarray) – Solved value function.
state_choice_vec (Dict) – Dictionary containing a single state and choice.
params (Dict) – Dictionary containing the model parameters.
- Returns:
Interpolated value for wealth.
- Return type:
jnp.ndarray | float
- dcegm.interpolation.interp1d.interp_policy_on_wealth(wealth: float | jax.numpy.ndarray, endog_grid: jax.numpy.ndarray, policy: jax.numpy.ndarray) float¶
Interpolate policy function on a single wealth point.
- Parameters:
wealth (float) – New wealth point to interpolate.
endog_grid (jnp.ndarray) – Solved endogenous wealth grid.
value (jnp.ndarray) – Solved value function.
state_choice_vec (Dict) – Dictionary containing a single state and choice.
params (Dict) – Dictionary containing the model parameters.
- Returns:
Interpolated value for wealth.
- Return type:
float
- dcegm.interpolation.interp1d.interp_value_and_check_creditconstraint(value_high: float | jax.numpy.ndarray, wealth_high: float | jax.numpy.ndarray, value_low: float | jax.numpy.ndarray, wealth_low: float | jax.numpy.ndarray, new_wealth: float | jax.numpy.ndarray, compute_utility: Callable, endog_grid_min: float | jax.numpy.ndarray, value_at_zero_wealth: float | jax.numpy.ndarray, state_choice_vec: Dict[str, int], params: Dict[str, float], discount_factor: float) float | jax.numpy.ndarray¶
Calculate the interpolated value with accounting for a possible credit constrained solution.
This function first calculates the interpolated value and then checks if we are in the credit constrained region, i.e. below endog_grid_min. If so, it returns the value as the sum of the utility when consumed all wealth and the discounted value at zero savings. Creditconstrained means it is optimal to consume all!
- Parameters:
value_high (float) – Value function value at the higher end of the interpolation interval.
wealth_high (float) – Endogenous wealth grid value at the higher end of the interpolation interval.
value_low (float) – Value function value at the lower end of the interpolation interval.
wealth_low (float) – Endogenous wealth grid value at the lower end of the interpolation interval.
new_wealth (float) – New endogenous wealth grid value.
endog_grid_min (float) – Minimum endogenous wealth grid value.
value_at_zero_wealth (float) – The value at zero wealth.
state_choice_vec (Dict) – Dictionary containing a single state and choice.
params (dict) – Dictionary containing the model parameters.
- Returns:
value_interp (float): Interpolated value function.
- Return type:
tuple