dcegm.interfaces.interface¶
Interface functions.
Functions¶
|
Get the number of state-choice periods from the model. |
|
Get policy and value for a given state and choice vector. |
|
Get the value function for a given state and choice vector. |
|
Get the policy function for a given state and choice vector. |
|
Validate the exogenous processes in the model. |
|
Evaluate the exogenous function for a given state-choice vector and params. |
|
|
|
Module Contents¶
- dcegm.interfaces.interface.get_n_state_choice_period(model_structure)¶
Get the number of state-choice periods from the model.
- Parameters:
model (dict) – A dictionary containing model information. Must include ‘model_structure’ with a ‘state_choice_space’ key.
- Returns:
A pandas Series with value counts of the first column of ‘state_choice_space’, sorted by index.
- Return type:
pd.Series
- dcegm.interfaces.interface.policy_and_value_for_states_and_choices(states, choices, params, endog_grid_solved, value_solved, policy_solved, model_config, model_structure, model_funcs)¶
Get policy and value for a given state and choice vector.
- Parameters:
endog_grid_solved (jnp.ndarray) – Endogenous wealth grid for all states and choices.
value_solved (jnp.ndarray) – Value array for all states and choices.
policy_solved (jnp.ndarray) – Policy array for all states and choices.
params (dict) – Dictionary containing model parameters.
model (dict) – Dictionary containing model information and settings.
state_choice_vec (dict) – Dictionary containing a single state and choice.
wealth (float) – The wealth level at which to interpolate.
compute_utility (Callable) – Function to compute utility given the state, choice, and parameters.
second_continuous (float, optional) – An additional continuous state dimension. If provided, interpolation is done in two dimensions.
- Returns:
A tuple of (policy, value) at the given state and choice.
- Return type:
Tuple[float, float]
- dcegm.interfaces.interface.value_for_state_and_choice(states, choices, params, endog_grid_solved, value_solved, model_config, model_structure, model_funcs)¶
Get the value function for a given state and choice vector.
- Parameters:
endog_grid_solved (jnp.ndarray) – Endogenous wealth grid for all states and choices.
value_solved (jnp.ndarray) – Value array for all states and choices.
params (dict) – Dictionary containing model parameters.
model (dict) – Dictionary containing model information and settings.
state_choice_vec (dict) – Dictionary containing a single state and choice.
wealth (float) – The wealth level at which to interpolate.
second_continuous (float, optional) – An additional continuous state dimension. If provided, interpolation is done in two dimensions.
- Returns:
The value at the given state and choice.
- Return type:
float
- dcegm.interfaces.interface.policy_for_state_choice_vec(states, choices, endog_grid_solved, policy_solved, model_structure, model_config)¶
Get the policy function for a given state and choice vector.
- Parameters:
endog_grid_solved (jnp.ndarray) – Endogenous wealth grid for all states and choices.
policy_solved (jnp.ndarray) – Policy array for all states and choices.
model (dict) – Dictionary containing model information and settings.
state_choice_vec (dict) – Dictionary containing a single state and choice.
wealth (float) – The wealth level at which to interpolate.
second_continuous (float, optional) – An additional continuous state dimension. If provided, interpolation is done in two dimensions.
- Returns:
The policy at the given state and choice.
- Return type:
float
- dcegm.interfaces.interface.validate_stochastic_transition(params, model_config, model_funcs, model_structure)¶
Validate the exogenous processes in the model.
This function checks that transition probabilities for each exogenous process are non-negative, sum to 1, and have the correct dimensionality. It raises a ValueError if any checks fail.
- Parameters:
model (dict) – A dictionary representing the model. Must contain ‘model_funcs’ with ‘processed_stochastic_funcs’, ‘model_structure’ with ‘state_choice_space_dict’, and relevant ‘options’ keys.
params (dict) – Dictionary containing the model parameters.
- Returns:
True if all exogenous processes are valid; otherwise, a ValueError is raised.
- Return type:
bool
- dcegm.interfaces.interface.stochastic_transition_vec(state_choice_vec_dict, func, params)¶
Evaluate the exogenous function for a given state-choice vector and params.
- Parameters:
state_choice_vec_dict (dict) – Dictionary containing state-choice values.
func (Callable) – Stochastic state transition function to be evaluated.
params (dict) – Dictionary of model parameters.
- Returns:
The exogenous process outcomes for the given state-choice combination and parameters.
- Return type:
jnp.ndarray or float
- dcegm.interfaces.interface.choice_values_for_states(value_solved, endog_grid_solved, state_choice_indexes, params, states, model_config, model_funcs)¶
- dcegm.interfaces.interface.choice_policies_for_states(policy_solved, endog_grid_solved, state_choice_indexes, states, model_config)¶