tlo.methods.hiv_tb_calibration module

Deviance measure

This module runs at the end of a simulation and calculates a weighted deviance measure for a given set of parameters using outputs from the demography (deaths), HIV and TB modules

class Deviance(name=None, resourcefilepath=None)[source]

This module reads in logged outputs from HIV, TB and demography and compares them with reported data a deviance measure is calculated and returned on simulation end

Bases: tlo.core.Module

Class attributes:

INIT_DEPENDENCIES : {‘Hiv’, ‘Tb’, ‘Demography’}


Functions (defined or overridden in class Deviance):

__init__(name=None, resourcefilepath=None)[source]

Construct a new disease module ready to be included in a simulation.

Initialises an empty parameters dictionary and module-specific random number generator.


name – the name to use for this module. Defaults to the concrete subclass’ name.


Read parameter values from file, if required.

Must be implemented by subclasses.


data_folder – path of a folder supplied to the Simulation containing data files. Typically, modules would read a particular file within here.


Set our property values for the initial population.

Must be implemented by subclasses.

This method is called by the simulation when creating the initial population, and is responsible for assigning initial values, for every individual, of those properties ‘owned’ by this module, i.e. those declared in its PROPERTIES dictionary.

TODO: We probably need to declare somehow which properties we ‘read’ here, so the simulation knows what order to initialise modules in!


population – the population of individuals


Get ready for simulation start.

Must be implemented by subclasses.

This method is called just before the main simulation loop begins, and after all modules have read their parameters and the initial population has been created. It is a good place to add initial events to the event queue.

on_birth(mother_id, child_id)[source]

Initialise our properties for a newborn individual.

Must be implemented by subclasses.

This is called by the simulation whenever a new person is born.

  • mother_id – the person id for the mother of this child (can be -1 if the mother is not identified).

  • child_id – the person id of new child


Make a dict of all data to be used in calculating calibration score

weighted_mean(model_dict, data_dict)[source]
record_death(year, age_years, sex, cause)[source]

Save outputs about one death


This is called after the simulation has ended. Modules do not need to declare this.