emodpy_hiv.plotting.plot_relationship_end module#

emodpy_hiv.plotting.plot_relationship_end.extract_data_for_relationship(filename: str, relationship_type: int)[source]#

Extract the relationship duration information for the given relationship type in the given file. Please note that only relationships that “broke-up” are considered because those are the relationships that went to the completion of the drawn duration. The relationship could have ended prematurely due to things like death or a partner migrating away.

Parameters:
  • filename (str, required) – The path and name of the RelationshipEnd.csv to be read.

  • relationship_type (int, required) – The type of relationship. Options: 0 (transitory), 1 (informal), 2 (marital), 3 (commercial).

Returns:

Dataframe where the rows must be of the given relationship type and with the extra column of the actual relationship duration.

emodpy_hiv.plotting.plot_relationship_end.plot_relationship_duration_histogram(dir_or_filename: str, relationship_type: int, bin_size: float, expected: list[float] | None = None, exp_avg: float | None = None, heterogeneity: float | None = None, scale: float | None = None, show_avg_per_run: bool = False, img_dir: str | None = None)[source]#

Plot the relationship duration histogram for the given relationship type and show information in the title about the expected Weibull distribution. Please note that only relationships that “broke-up” are considered because those are the relationships that went to the completion of the drawn duration. The relationship could have ended prematurely due to things like death or a partner migrating away.

Parameters:
  • dir_or_filename (str, required) – The directory or filename containing the RelationshipEnd.csv files.

  • relationship_type (int, required) – The type of relationship. Options: 0 (transitory), 1 (informal), 2 (marital), 3 (commercial).

  • bin_size (float, required) – The size of the bins for the histogram.

  • expected (list, optional) – Expected values for the Weibull distribution. There must be 16 values.

  • exp_avg (float, optional) – Expected average duration in days. Will be shown in the title.

  • heterogeneity (float, optional) – Heterogeneity parameter for the Weibull distribution. Will be show in the title.

  • scale (float, optional) – Scale parameter for the Weibull distribution. Will be show in the title.

  • show_avg_per_run (bool, optional) – Whether to show the average duration per run. Will be show in the title.

  • img_dir (str, optional) – Directory to save the images. If None, the images will not be saved and a window will be opened.

Returns:

None - but image will be saved or window opened.

emodpy_hiv.plotting.plot_relationship_end.plot_relationship_duration_histogram_with_expected(dir_or_filename: str, relationship_type: str = 'transitory', show_avg_per_run: bool = False, show_expected: bool = False, img_dir: str | None = None)[source]#

Plot the relationship duration histogram for the given relationship type. Please note that only relationships that “broke-up” are considered because those are the relationships that went to the completion of the drawn duration. The relationship could have ended prematurely due to things like death or a partner migrating away.

Parameters:
  • dir_or_filename (str, required) – The directory or filename containing the RelationshipEnd.csv files.

  • relationship_type (str, optional) – The type of relationship. Options: transitory, informal, marital, commercial. Default is “transitory”.

  • show_avg_per_run (bool, optional) – Whether to show the average duration per run. Default is False.

  • show_expected (bool, optional) – Whether to show the expected Weibull distribution. Default is False.

  • img_dir (str, optional) – Directory to save the images. If None, the images will not be saved and a window will be opened. Default is none - don’t save image and open a window.

Returns:

None - but image will be saved or window opened.