models¶
This module contains the model functions that can be passed to
the respyabc.respyabc() function and functions that
support these models.
-
respyabc.models.compute_choice_frequencies(df)[source]¶ Calculate choice frequencies per Period in the discrete choice model.
- Parameters
df (pandas.DataFrame) – A pandas data frame containing the output of the discrete choice model.
- Returns
- Return type
A pandas data frame containing the relative choice frequencies of each period.
-
respyabc.models.compute_choice_frequencies_to_model_output_frequencies(df)[source]¶ Processes the choice frequencies to the output frequencies.
- Parameters
df (pandas.DataFrame) – Data frame for which the choice frequencies should be created.
- Returns
output_frequencies – A dictionary containing the relative frequencies of each choice in each period.
- Return type
dict
-
respyabc.models.compute_model(parameter, model_to_simulate, parameter_for_simulation, options_for_simulation, descriptives='choice_frequencies')[source]¶ - Compute K&W 1994 model. Function is a wrapper around
the respy.get_simulate_func() function to compute the model using the parameters from Kean & Wolpin 1994 but being able to vary over thr parameters.
- Parameters
parameter (dict) – A dictionary contaning the variables as key and the corresponding magnitude as value.
model_to_simulate (func) – Function produced by
respyabc.respyabc.get_simulate_func_options()Model that specififes the respy set-up.parameter_for_simulation (pandas.DataFrame) – Parameter that specify the respy model.
options_for_simulation (pandas.DataFrame) – Options that specify the respy model.
descriptives ({choice_frequencies`,``wage_moments``}, optional) – Determines how the descriptives with which the distance is computed are computed. The default is
"choice_frequencies".
- Returns
output_frequencies – A dictionary containing the relative frequencies of each choice in each period.
- Return type
dict
-
respyabc.models.compute_wage_moments(df)[source]¶ Calculate first and second wage moment in the discrete choice model.
- Parameters
df (pandas.DataFrame) – A pandas data frame containing the output of the discrete choice model.
- Returns
- Return type
A pandas data frame containing the first and second wage moments of each period.
-
respyabc.models.fill_nan(df)[source]¶ Fill missing values in data frame with zeros.
- Parameters
df (pandas.DataFrame) – A pandas data frame containing missing values.
- Returns
- Return type
A pandas data frame containing zeros instead of the missing values.
-
respyabc.models.transform_multiindex_to_single_index(df, column1, column2, link='_')[source]¶ Replaces a multiindex with a concatenated single index version of the multiindex.
- Parameters
df (pandas.DataFrame) – Pandas data frame with a multiindex.
column1 (str) – Name of first multiindex column.
column2 (str) – Name of second multiindex column.
link (str, optional) – String that is used to seperate the two multiindex columns within the new string.
- Returns
- Return type
Single indexed data frame.