How the User Inputs are Processed¶
Model Processing¶
- process_model(model_dict)[source]¶
Check, clean, extend and transform the model specs.
Check the completeness, consistency and validity of the model specifications.
Set default values and extend the model specification where necessary.
- Parameters
model_dict (dict) – The model specification. See: Model specifications
- Returns
dict – nested dictionary of model specs. It has the following entries: - dimensions (dict): Dimensional information like n_states, n_periods, n_controls, n_mixtures. See dimensions. - labels (dict): Dict of lists with labels for the model quantities like factors, periods, controls, stagemap and stages. See labels - anchoring (dict): Information about anchoring. See anchoring - transition_functions (tuple): Tuple of tuples of length n_periods. Each inner tuple has the following two entries: (name_of_transition_function, callable). - update_info (pandas.DataFrame): DataFrame with one row per Kalman update needed in the likelihood function. See update_info. - normalizations (dict): Nested dictionary with information on normalized factor loadings and intercepts for each factor. See normalizations.
- get_dimensions(model_dict)[source]¶
Extract the dimensions of the model.
- Parameters
model_dict (dict) – The model specification. See: Model specifications
- Returns
dict –
- Dimensional information like n_states, n_periods, n_controls,
n_mixtures. See dimensions.
Data Processing¶
- process_data_for_estimation(df, labels, update_info, anchoring_info)[source]¶
Process the data for estimation.
- Parameters
df (DataFrame) – panel dataset in long format. It has a MultiIndex where the first level indicates the period and the second the individual.
labels (dict) – Dict of lists with labels for the model quantities like factors, periods, controls, stagemap and stages. See labels
update_info (pandas.DataFrame) – DataFrame with one row per Kalman update needed in the likelihood function. See update_info.
anchoring_info (dict) – Information about anchoring. See anchoring
- Returns
meas_data (jax.numpy.array) –
- Array of shape (n_updates, n_obs) with data on
observed measurements. NaN if the measurement was not observed.
- control_data (jax.numpy.array): Array of shape (n_periods, n_obs, n_controls)
with observed control variables for the measurement equations.
Model Checking¶
- check_model(model_dict, labels, dimensions, anchoring)[source]¶
Check consistency and validity of the model specification.
labels, dimensions and anchoring information are done before the model checking because processing them will not raise any errors except for easy to understand KeyErrors.
Other specifications are checked in the model dict before processing to make sure that the assumptions we make during the processing are fulfilled.
- Parameters
model_dict (dict) – The model specification. See: Model specifications
dimensions (dict) – Dimensional information like n_states, n_periods, n_controls, n_mixtures. See dimensions.
labels (dict) – Dict of lists with labels for the model quantities like factors, periods, controls, stagemap and stages. See labels
anchoring (dict) – Dictionary with information about anchoring. See anchoring
- Raises
ValueError –