plot_relationship_start
extract_assortivity_risk(start_rel_filename, relationship_type, male_risk_value='LOW')
For the given relationship type, extract the number of relationships that started during each time step for each risk value pair. The male risk value is constant so it should return a dataframe with three columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_rel_filename
|
(str, required)
|
The name and path of the RelationshipStart.csv file to be read. |
required |
relationship_type
|
(int, required)
|
The type of relationship. Options: 0 (transitory), 1 (informal), 2 (marital), 3 (commercial). |
required |
male_risk_value
|
str
|
The risk value of the male in the relationship being plotted. This will be either LOW, MEDIUM, or HIGH. Capitalization matters. Default is LOW. |
'LOW'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Dataframe with three columns where each column is for a risk value pairing. Each row should represent a simulation time (in days) that had relationhips created of that time and risk value pairing. There is no guarantee that relationships are created each time step. |
Source code in emodpy_hiv/plotting/plot_relationship_start.py
plot_relationship_assortivity_risk(dir_or_filename, relationship_type, male_risk_value='LOW', show_avg_per_run=False, show_regression=False, regression_dir=None, img_dir=None)
Create a plot showing the number of relationships of a given type that started during the timestep for a male with the give risk value versus females with the other possible values. For example, if the male's risk value is HIGH, the plot will contain three curves: HIGH-LOW, HIGH-MEDIUM, and HIGH-HIGH. They will all be for the given relationship type. We only do three curves because the data can be quite noisy.
The plot also has the option to show a least squares regression line for each risk value pair. A CSV file can be saved with the regression data. This can be used to compare with the plot_a_vs_b() function to compare the regression from two different sets of files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_or_filename
|
(str, required)
|
The directory or filename containing the RelationshipStart.csv files. |
required |
relationship_type
|
str
|
The type of relationship. Options: 0 (transitory), 1 (informal), 2 (marital), 3 (commercial). |
required |
male_risk_value
|
str
|
The risk value of the male in the relationship being plotted. This will be either LOW, MEDIUM, or HIGH. Capitalization matters. Default is LOW. |
'LOW'
|
show_avg_per_run
|
bool
|
If 'dir_or_filename' is a directory, this will calculate the average number of relationships started at each timestep for the different files in the directory. Default is False. |
False
|
show_regression
|
bool
|
If true, a least squares regression line will be calculated and shown on the plot. There will be one line for each risk value pair. Default is False. |
False
|
regression_dir
|
str
|
If 'show_regression' is true and this provides a path to a directory, then a CSV file will be saved with the data points of the displayed regression lines. The name of the file will be the relationship type and the male's risk value. For example, COMMERCIAL-HIGH.csv. Default is None. |
None
|
img_dir
|
str
|
Directory to save the images. If None, the images will not be saved and a window will be opened. |
None
|
Returns:
Source code in emodpy_hiv/plotting/plot_relationship_start.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
plot_relationship_assortivity_risk_all(dir_or_filename, regression_dir=None, img_dir=None)
Create a plot for each combination male risk value and relationship type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_or_filename
|
(str, required)
|
The directory or filename containing the RelationshipStart.csv files or a specific file. |
required |
regression_dir
|
str
|
If provided, a CSV file will be created for each plot where the CSV file has one column for each risk value combination - three columns because the male's value is fixed. |
None
|
img_dir
|
str
|
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. |
None
|
Returns: