Inference Classes¶
This section documents the classes used for the parameter inference of epidemiological models curated in this collection.
Overview:
- Inference & Optimisation Controller Classes:
- Log-likelihood Initial Conditions Classes:
- Prior Classes:
Public Health England & Cambridge Model¶
- class epimodels.inference.PheSEIRInfer(model)[source]¶
PheSEIRInfer Class: Controller class for the optimisation or inference of parameters of the PHE model in a PINTS framework.
- Parameters:
model (PheSEIRModel) – The model for which we solve the optimisation or inference problem.
- inference_problem_setup(times, num_iter, wd=1, wp=1)[source]¶
Runs the parameter inference routine for the PHE model.
- Parameters:
times (list) – List of time points at which we have data for the log-likelihood computation.
num_iter (integer) – Number of iterations the MCMC sampler algorithm is run for.
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- Returns:
3D-matrix of the proposed parameters for each iteration for each of the chains of the MCMC sampler.
- Return type:
numpy.array
- optimisation_problem_setup(times, wd=1, wp=1)[source]¶
Runs the initial conditions optimisation routine for the PHE model.
- Parameters:
times (list) – List of time points at which we have data for the log-likelihood computation.
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- Returns:
numpy.array – Matrix of the optimised parameters at the end of the optimisation procedure.
float – Value of the log-posterior at the optimised point in the free parameter space.
- read_deaths_data(deaths_data, deaths_times, time_to_death, fatality_ratio)[source]¶
Sets the serology data used for the model’s parameters inference.
- Parameters:
deaths_data (numpy.array) – List of region-specific age-structured number of deaths as a matrix. Each column represents an age group.
deaths_times (numpy.array) – Matrix of timepoints for which deaths data is available.
time_to_death (list) – List of probabilities of death of individual d days after infection.
fatality_ratio (list) – List of age-specific fatality ratios.
- read_model_data(susceptibles_data, infectives_data)[source]¶
Sets the initial data used for the model’s parameters optimisation or inference.
- Parameters:
susceptibles_data (list) – List of regional age-structured lists of the initial number of susceptibles.
infectives_data (list) – List of regional age-structured lists of the initial number of infectives in the first infectives compartment.
- read_serology_data(tests_data, positives_data, serology_times, sens, spec)[source]¶
Sets the serology data used for the model’s parameters inference.
- Parameters:
tests_data (list of numpy.array) – List of region-specific age-structured number of tests conducted as a matrix. Each column represents an age group.
positives_data (list of numpy.array) – List of region-specific age-structured number of positive test results as a matrix. Each column represents an age group.
serology_times (numpy.array) – Matrix of timepoints for which serology data is available.
sens (float or int) – Sensitivity of the test (or ratio of true positives).
spec (float or int) – Specificity of the test (or ratio of true negatives).
- return_loglikelihood(times, x, wd=1, wp=1)[source]¶
Return the log-likelihood used for the optimisation or inference.
- Parameters:
times (list) – List of time points at which we have data for the log-likelihood computation.
x (list) – List of free parameters used for computing the log-likelihood.
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- Returns:
Value of the log-likelihood at the given point in the free parameter space.
- Return type:
float
- class epimodels.inference.PHELogLik(model, susceptibles_data, infectives_data, times, deaths, time_to_death, deaths_times, fatality_ratio, tests_data, positives_data, serology_times, sens, spec, wd=1, wp=1)[source]¶
PHELogLik Class: Controller class to construct the log-likelihood needed for optimisation or inference in a PINTS framework.
- Parameters:
model (PheSEIRModel) – The model for which we solve the optimisation or inference problem.
susceptibles_data (list) – List of regional age-structured lists of the initial number of susceptibles.
infectives_data (list) – List of regional age-structured lists of the initial number of infectives in the first infectives compartment.
times (list) – List of time points at which we have data for the log-likelihood computation.
deaths_data (numpy.array) – List of region-specific age-structured number of deaths as a matrix. Each column represents an age group.
time_to_death (list) – List of probabilities of death of individual d days after infection.
deaths_times (numpy.array) – Matrix of timepoints for which deaths data is available.
fatality_ratio (list) – List of age-specific fatality ratios.
tests_data (list of numpy.array) – List of region-specific age-structured number of tests conducted as a matrix. Each column represents an age group.
positives_data (list of numpy.array) – List of region-specific age-structured number of positive test results as a matrix. Each column represents an age group.
serology_times (numpy.array) – Matrix of timepoints for which serology data is available.
sens (float or int) – Sensitivity of the test (or ratio of true positives).
spec (float or int) – Specificity of the test (or ratio of true negatives).
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- class epimodels.inference.PHELogPrior(model, times)[source]¶
PHELogPrior Class: Controller class to construct the log-prior needed for optimisation or inference in a PINTS framework.
- Parameters:
model (PheSEIRModel) – The model for which we solve the optimisation or inference problem.
times (list) – List of time points at which we have data for the log-likelihood computation.
Roche SEIRD Model¶
- class epimodels.inference.RocheSEIRInfer(model)[source]¶
RocheSEIRInfer Class: Controller class for the optimisation or inference of parameters of the Roche model in a PINTS framework.
- Parameters:
model (RocheSEIRModel) – The model for which we solve the optimisation or inference problem.
- inference_problem_setup(times, num_iter, wd=1, wp=1)[source]¶
Runs the parameter inference routine for the Roche model.
- Parameters:
times (list) – List of time points at which we have data for the log-likelihood computation.
num_iter (integer) – Number of iterations the MCMC sampler algorithm is run for.
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- Returns:
3D-matrix of the proposed parameters for each iteration for each of the chains of the MCMC sampler.
- Return type:
numpy.array
- optimisation_problem_setup(times, wd=1, wp=1)[source]¶
Runs the initial conditions optimisation routine for the Roche model.
- Parameters:
times (list) – List of time points at which we have data for the log-likelihood computation.
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- Returns:
numpy.array – Matrix of the optimised parameters at the end of the optimisation procedure.
float – Value of the log-posterior at the optimised point in the free parameter space.
- read_deaths_data(deaths_data, deaths_times)[source]¶
Sets the serology data used for the model’s parameters inference.
- Parameters:
deaths_data (numpy.array) – List of region-specific age-structured number of deaths as a matrix. Each column represents an age group.
deaths_times (numpy.array) – Matrix of timepoints for which deaths data is available.
- read_model_data(susceptibles_data, infectives_data)[source]¶
Sets the initial data used for the model’s parameters optimisation or inference.
- Parameters:
susceptibles_data (list) – List of regional age-structured lists of the initial number of susceptibles.
infectives_data (list) – List of regional age-structured lists of the initial number of infectives in the presymptomatic infectives compartment.
- read_npis_data(max_levels_npi, targeted_npi, general_npi, reg_levels_npi, time_changes_npi, time_changes_flag)[source]¶
Sets the non-pharmaceutical interventions data used for the model’s parameters inference.
- Parameters:
max_levels_npi (list of int) – List of maximum levels the non-pharmaceutical interventions can reach.
targeted_npi (list of bool) – List of the targeted non-pharmaceutical interventions.
general_npi (list of list of int) – List of the general values of the targeted non-pharmaceutical interventions. In chronological order.
reg_levels_npi (list of list of int) – List of region-specific levels the non-pharmaceutical interventions changes. In chronological order.
time_changes_npi (list) – List of times at which the next instances of region-specific non-pharmaceutical interventions start to be used. In increasing order.
time_changes_flag (list) – List of times at which the next instances of region-specific non-pharmaceutical interventions start to be used. In increasing order.
- read_serology_data(tests_data, positives_data, serology_times, sens, spec)[source]¶
Sets the serology data used for the model’s parameters inference.
- Parameters:
tests_data (list of numpy.array) – List of region-specific age-structured number of tests conducted as a matrix. Each column represents an age group.
positives_data (list of numpy.array) – List of region-specific age-structured number of positive test results as a matrix. Each column represents an age group.
serology_times (numpy.array) – Matrix of timepoints for which serology data is available.
sens (float or int) – Sensitivity of the test (or ratio of true positives).
spec (float or int) – Specificity of the test (or ratio of true negatives).
- return_loglikelihood(times, x, wd=1, wp=1)[source]¶
Return the log-likelihood used for the optimisation or inference.
- Parameters:
times (list) – List of time points at which we have data for the log-likelihood computation.
x (list) – List of free parameters used for computing the log-likelihood.
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- Returns:
Value of the log-likelihood at the given point in the free parameter space.
- Return type:
float
- class epimodels.inference.RocheLogLik(model, susceptibles_data, infectives_data, times, deaths, deaths_times, tests_data, positives_data, serology_times, sens, spec, max_levels_npi, targeted_npi, general_npi, reg_levels_npi, time_changes_npi, time_changes_flag, wd=1, wp=1)[source]¶
RocheLogLik Class: Controller class to construct the log-likelihood needed for optimisation or inference in a PINTS framework.
- Parameters:
model (RocheSEIRModel) – The model for which we solve the optimisation or inference problem.
susceptibles_data (list) – List of regional age-structured lists of the initial number of susceptibles.
infectives_data (list) – List of regional age-structured lists of the initial number of infectives in the presymptomatic infectives compartments.
times (list) – List of time points at which we have data for the log-likelihood computation.
deaths_data (numpy.array) – List of region-specific age-structured number of deaths as a matrix. Each column represents an age group.
deaths_times (numpy.array) – Matrix of timepoints for which deaths data is available.
tests_data (list of numpy.array) – List of region-specific age-structured number of tests conducted as a matrix. Each column represents an age group.
positives_data (list of numpy.array) – List of region-specific age-structured number of positive test results as a matrix. Each column represents an age group.
serology_times (numpy.array) – Matrix of timepoints for which serology data is available.
sens (float or int) – Sensitivity of the test (or ratio of true positives).
spec (float or int) – Specificity of the test (or ratio of true negatives).
max_levels_npi (list of int) – List of maximum levels the non-pharmaceutical interventions can reach.
targeted_npi (list of bool) – List of the targeted non-pharmaceutical interventions.
general_npi (list of list of int) – List of the general values of the targeted non-pharmaceutical interventions. In chronological order.
reg_levels_npi (list of list of int) – List of region-specific levels the non-pharmaceutical interventions changes. In chronological order.
time_changes_npi (list) – List of times at which the next instances of region-specific non-pharmaceutical interventions start to be used. In increasing order.
time_changes_flag (list) – List of times at which the next instances of region-specific non-pharmaceutical interventions start to be used. In increasing order.
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- class epimodels.inference.RocheLogPrior(model, times)[source]¶
RocheLogPrior Class: Controller class to construct the log-prior needed for optimisation or inference in a PINTS framework.
- Parameters:
model (RocheSEIRModel) – The model for which we solve the optimisation or inference problem.
times (list) – List of time points at which we have data for the log-likelihood computation.
Warwick-Household Model¶
- class epimodels.inference.WarwickSEIRInfer(model)[source]¶
WarwickSEIRInfer Class: Controller class for the optimisation or inference of parameters of the Warwick model in a PINTS framework.
- Parameters:
model (WarwickSEIRModel) – The model for which we solve the optimisation or inference problem.
- inference_problem_setup(times, num_iter, wd=1, wp=1)[source]¶
Runs the parameter inference routine for the Warwick model.
- Parameters:
times (list) – List of time points at which we have data for the log-likelihood computation.
num_iter (integer) – Number of iterations the MCMC sampler algorithm is run for.
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- Returns:
3D-matrix of the proposed parameters for each iteration for each of the chains of the MCMC sampler.
- Return type:
numpy.array
- optimisation_problem_setup(times, wd=1, wp=1)[source]¶
Runs the initial conditions optimisation routine for the Warwick model.
- Parameters:
times (list) – List of time points at which we have data for the log-likelihood computation.
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- Returns:
numpy.array – Matrix of the optimised parameters at the end of the optimisation procedure.
float – Value of the log-posterior at the optimised point in the free parameter space.
- read_deaths_data(deaths_data, deaths_times)[source]¶
Sets the serology data used for the model’s parameters inference.
- Parameters:
deaths_data (numpy.array) – List of region-specific age-structured number of deaths as a matrix. Each column represents an age group.
deaths_times (numpy.array) – Matrix of timepoints for which deaths data is available.
- read_delay_data(pDtoH, dDtoH, pHtoDeath, dHtoDeath)[source]¶
Sets the hospitalisation and death delays data used for the model’s parameters inference.
- Parameters:
pDtoH (list) – Age-dependent fractions of the number of symptomatic cases that end up hospitalised.
dDtoH (list) – Distribution of the delay between onset of symptoms and hospitalisation. Must be normalised.
pHtoDeath (list) – Age-dependent fractions of the number of hospitalised cases that die.
dHtoDeath (list) – Distribution of the delay between onset of hospitalisation and death. Must be normalised.
- read_extended_contact_matrices(extended_house_cont_mat, extended_school_cont_mat, extended_work_cont_mat, extended_other_cont_mat)[source]¶
Sets the initial contact matrix with more age groups used for the model’s parameters optimisation or inference.
- Parameters:
extended_house_cont_mat (ContactMatrix) – Initial contact matrix with more age groups used for the modelling, underlying household interactions.
extended_school_cont_mat (ContactMatrix) – Initial contact matrix with more age groups used for the modelling, underlying school interactions.
extended_work_cont_mat (ContactMatrix) – Initial contact matrix with more age groups used for the modelling, underlying workplace interactions.
extended_other_cont_mat (ContactMatrix) – Initial contact matrix with more age groups used for the modelling, underlying other non-household interactions.
- read_extended_population_structure(extended_susceptibles, extended_infectives_prop)[source]¶
Sets the initial data with more age groups used for the model’s parameters optimisation or inference.
- Parameters:
extended_susceptibles (list) – List country-level initial number of susceptibles organised in an extended age classification.
extended_infectives_prop (list) – List country-level initial proportions of infective individuals in each age group when the population is organised in an extended age classification.
- read_model_data(susceptibles_data, infectives_data)[source]¶
Sets the initial data used for the model’s parameters optimisation or inference.
- Parameters:
susceptibles_data (list) – List of regional age-structured lists of the initial number of susceptibles.
infectives_data (list) – List of regional age-structured lists of the initial number of infectives in the presymptomatic infectives compartment.
- read_serology_data(tests_data, positives_data, serology_times, sens, spec)[source]¶
Sets the serology data used for the model’s parameters inference.
- Parameters:
tests_data (list of numpy.array) – List of region-specific age-structured number of tests conducted as a matrix. Each column represents an age group.
positives_data (list of numpy.array) – List of region-specific age-structured number of positive test results as a matrix. Each column represents an age group.
serology_times (numpy.array) – Matrix of timepoints for which serology data is available.
sens (float or int) – Sensitivity of the test (or ratio of true positives).
spec (float or int) – Specificity of the test (or ratio of true negatives).
- return_loglikelihood(times, x, wd=1, wp=1)[source]¶
Return the log-likelihood used for the optimisation or inference.
- Parameters:
times (list) – List of time points at which we have data for the log-likelihood computation.
x (list) – List of free parameters used for computing the log-likelihood.
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- Returns:
Value of the log-likelihood at the given point in the free parameter space.
- Return type:
float
- class epimodels.inference.WarwickLogLik(model, extended_susceptibles, extended_infectives_prop, extended_house_cont_mat, extended_school_cont_mat, extended_work_cont_mat, extended_other_cont_mat, pDtoH, dDtoH, pHtoDeath, dHtoDeath, susceptibles_data, infectives_data, times, deaths, deaths_times, tests_data, positives_data, serology_times, sens, spec, wd=1, wp=1)[source]¶
WarwickLogLik Class: Controller class to construct the log-likelihood needed for optimisation or inference in a PINTS framework.
- Parameters:
model (WarwickSEIRModel) – The model for which we solve the optimisation or inference problem.
extended_susceptibles (list) – List country-level initial number of susceptibles organised in an extended age classification.
extended_infectives_prop (list) – List country-level initial proportions of infective individuals in each age group when the population is organised in an extended age classification.
extended_house_cont_mat (ContactMatrix) – Initial contact matrix with more age groups used for the modelling, underlying household interactions.
extended_school_cont_mat (ContactMatrix) – Initial contact matrix with more age groups used for the modelling, underlying school interactions.
extended_work_cont_mat (ContactMatrix) – Initial contact matrix with more age groups used for the modelling, underlying workplace interactions.
extended_other_cont_mat (ContactMatrix) – Initial contact matrix with more age groups used for the modelling, underlying other non-household interactions.
pDtoH (list) – Age-dependent fractions of the number of symptomatic cases that end up hospitalised.
dDtoH (list) – Distribution of the delay between onset of symptoms and hospitalisation. Must be normalised.
pHtoDeath (list) – Age-dependent fractions of the number of hospitalised cases that die.
dHtoDeath (list) – Distribution of the delay between onset of hospitalisation and death. Must be normalised.
susceptibles_data (list) – List of regional age-structured lists of the initial number of susceptibles.
infectives_data (list) – List of regional age-structured lists of the initial number of infectives in the presymptomatic infectives compartments.
times (list) – List of time points at which we have data for the log-likelihood computation.
deaths_data (numpy.array) – List of region-specific age-structured number of deaths as a matrix. Each column represents an age group.
deaths_times (numpy.array) – Matrix of timepoints for which deaths data is available.
tests_data (list of numpy.array) – List of region-specific age-structured number of tests conducted as a matrix. Each column represents an age group.
positives_data (list of numpy.array) – List of region-specific age-structured number of positive test results as a matrix. Each column represents an age group.
serology_times (numpy.array) – Matrix of timepoints for which serology data is available.
sens (float or int) – Sensitivity of the test (or ratio of true positives).
spec (float or int) – Specificity of the test (or ratio of true negatives).
wd (float or int) – Proportion of the contribution of the deaths data to the log-likelihood.
wp (float or int) – Proportion of the contribution of the serology data to the log-likelihood.
- class epimodels.inference.WarwickLogPrior(model, times)[source]¶
WarwickLogPrior Class: Controller class to construct the log-prior needed for optimisation or inference in a PINTS framework.
- Parameters:
model (WarwickSEIRModel) – The model for which we solve the optimisation or inference problem.
times (list) – List of time points at which we have data for the log-likelihood computation.