leap.exacerbation module

class leap.exacerbation.ExacerbationHistory(num_current_year: int, num_prev_year: int)[source]

Bases: object

A class containing information about the history of asthma exacerbations.

num_current_year

the number of exacerbations in the current year.

num_prev_year

the number of exacerbations in the previous year.

class leap.exacerbation.Exacerbation(config: dict | None = None, province: str = 'CA', parameters: dict | None = None, hyperparameters: dict | None = None, calibration_table: DataFrameGroupBy | None = None, initial_rate: float | None = None)[source]

Bases: object

A class containing information about asthma exacerbations.

property hyperparameters : dict

A dictionary containing the hyperparameters used to compute β0 from a normal distribution:

  • β0_μ: float, the mean of the normal distribution.

  • β0_σ: float, the standard deviation of the normal distribution.

property parameters : dict

A dictionary containing the following keys:

  • β0: float, a constant parameter, randomly selected from a normal distribution with mean β0_μ and standard deviation β0_σ. See hyperparameters.

  • β0_calibration: float, the parameter for the calibration term.

  • βage: float, the parameter for the age term.

  • βsex: float, the parameter for the sex term.

  • βcontrol: float, the parameter for the asthma control term.

  • βcontrol_C: float, the parameter for the controlled asthma term.

  • βcontrol_PC: float, the parameter for the partially-controlled asthma term.

  • βcontrol_UC: float, the parameter for the uncontrolled asthma term.

  • min_year: int, the minimum year for which exacerbation data exists + 1. Currently 2001.

property calibration_table : DataFrameGroupBy

A dataframe grouped by year and sex, with the following columns:

  • year: integer year.

  • sex: 1 = male, 0 = female.

  • age: integer age.

  • calibrator_multiplier: float, TODO.

See exacerbation_calibration.csv.

assign_random_β0()[source]

Assign the parameter β0 a random value from a normal distribution.

load_exacerbation_calibration(province: str) DataFrameGroupBy[source]

Load the exacerbation calibration table.

Parameters:
province: str

A string indicating the province abbreviation, e.g. "BC". For all of Canada, set province to "CA".

Returns:

A dataframe grouped by year and sex.

Each entry is a dataframe with the following columns:

  • year: integer year.

  • sex: 1 = male, 0 = female.

  • age: integer age.

  • calibrator_multiplier: float, TODO.

compute_num_exacerbations(agent: Agent | None = None, age: int | None = None, sex: Sex | int | None = None, year: int | None = None, control_levels: ControlLevels | None = None, initial: bool = False) int[source]

Compute the number of asthma exacerbations in a given year.

Parameters:
agent: Agent | None = None

A person in the model.

age: int | None = None

The age of the person in years.

sex: Sex | int | None = None

The sex of the agent (person), 0 = female, 1 = male.

year: int | None = None

The calendar year, e.g. 2024.

control_levels: ControlLevels | None = None

The asthma control levels.

initial: bool = False

If this is the initial computation.

Returns:

The number of asthma exacerbations.