Rim

class quantipy.Rim(name, max_iterations=1000, convcrit=0.01, cap=0, dropna=True, impute_method='mean', weight_column_name=None, total=0)
add_group(name=None, filter_def=None, targets=None)

Set weight groups using flexible filter and target defintions.

Main method to structure and specify complex weight schemes.

Parameters:
  • name (str) – Name of the weight group.
  • filter_def (str, optional) – An optional filter defintion given as a boolean expression in string format. Must be a valid input for the pandas DataFrame.query() method.
  • targets (dict) – Dictionary mapping of DataFrame columns to target proportion list.
Returns:

Return type:

None

group_targets(group_targets)

Set inter-group target proportions.

This will scale the weight factors per group to match the desired group proportions and thus effectively change each group’s weighted total number of cases.

Parameters:group_targets (dict) – A dictionary mapping of group names to the desired proportions.
Returns:
Return type:None
report(group=None)

TODO: Docstring

set_targets(targets, group_name=None)

Quickly set simple weight targets, optionally assigning a group name.

Parameters:
  • targets (dict or list of dict) – Dictionary mapping of DataFrame columns to target proportion list.
  • group_name (str, optional) – A name for the simple weight (group) created.
Returns:

Return type:

None

validate()

Summary on scheme target variables to detect and handle missing data.

Returns:df – A summary of missing entries and (rounded) mean/mode/median of value codes per target variable.
Return type:pandas.DataFrame