List of Epidemiology Models¶
This section documents the epidemiological models curated in this collection.
The first class contains code for modelling the extended SEIR model created by Public Health England and University of Cambridge. This is one of the official models used by the UK government for policy making.
It uses an extended version of an SEIR model and contact and region specific matrices.
The second class contains code for modelling the extended SEIRD model created by F. Hoffmann-La Roche Ltd and can be used to model the effects of non-pharmaceutical interventions (NPIs) on the epidemic dynamics.
It uses an extended version of an SEIRD model which differentiates between symptomatic and asymptomatic, as well as super-spreaders infectives.
The third class contains code for modelling the extended SEIR model created by the University of Warwick. This is one of the official models used by the UK government for policy making.
It uses an extended version of an SEIR model with contact and region-specific matrices and can be used to model the effects of within-household dynamics on the epidemic trajectory in different countries. It also differentiates between asymptomatic and symptomatic infections.
Overview:
Public Health England & Cambridge Model¶
- class epimodels.PheSEIRModel[source]¶
PheSEIRModel Class: Base class for constructing the PHE model: a deterministic SEIR used by the Public Health England to model the Covid-19 epidemic in UK based on region.
The population is structured according to their age-group (\(i\)) and region (\(r\)) and every individual will belong to one of the compartments of the SEIR model.
The general SEIR Model has four compartments - susceptible individuals (\(S\)), exposed but not yet infectious (\(E\)), infectious (\(I\)) and recovered (\(R\)).
In the PHE model framework, the exposed and infectious compartments are split into two each:
\begin{eqnarray} \frac{dS(r, t, i)}{dt} &=& -\lambda_{r, t, i} S(r, t, i) \\ \frac{dE^1(r, t, i)}{dt} &=& \lambda_{r, t, i} S( r, t, i) - \kappa E^1(r, t, i) \\ \frac{dE^2(r, t, i)}{dt} &=& \kappa E^1(r, t, i) - \kappa E^2( r, t, i) \\ \frac{dI^1(r, t, i)}{dt} &=& \kappa E^2(r, t, i) - \gamma I^1( r, t, i) \\ \frac{dI^2(r, t, i)}{dt} &=& \gamma I^1(r, t, i) - \gamma I^2( r, t, i) \\ \frac{dR(r, t, i)}{dt} &=& \gamma I^2(r, t, i) \end{eqnarray}where \(S(0) = S_0\), \(E^1(0) = E^1_0\), \(E^2(0) = E^1_0\), \(I^1(0) = I^1_0\), \(I^2(0) = I^2_0\), \(R(0) = R_0\) are also parameters of the model (evaluation at 0 refers to the compartments’ structure at initial time.
The parameter \(\lambda_{r, t, i}\) is the time, age and region-varying rate with which susceptible individuals become infected, which in the context of the PHE model depends on contact and region-specific relative susceptibility matrices. The other two parameters, \(\kappa\) and \(\gamma\) are disease-specific and so do not depend with region, age or time:
\begin{eqnarray} \kappa &=& \frac{2}{d_L} \\ \gamma &=& \frac{2}{d_I} \end{eqnarray}where \(d_L\) refers to mean latent period until disease onset and \(d_I\) to mean period of infection.
Extends
pints.ForwardModel.- age_groups_names()[source]¶
Returns the age group names.
- Returns:
List of the age group names.
- Return type:
list
- check_death_format(new_infections, fatality_ratio, time_to_death, niu)[source]¶
Checks correct format of the inputs of number of death calculation.
- Parameters:
new_infections (numpy.array) – Age-structured matrix of the number of new infections from the simulation method for the PheSEIRModel.
fatality_ratio (list) – List of age-specific fatality ratios.
time_to_death (list) – List of probabilities of death of individual k days after infection.
niu (float) – Dispersion factor for the negative binomial distribution.
- check_positives_format(output, tests, sens, spec)[source]¶
Checks correct format of the inputs of number of positive test results calculation.
- Parameters:
output (numpy.array) – Age-structured output matrix of the simulation method for the PheSEIRModel.
tests (list) – List of conducted tests in specified region and at time point k classified by age groups.
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).
- compute_rt_trajectory(output, k)[source]¶
Computes the time-dependent reproduction at time \(t_k\) from the PHE model.
- Parameters:
output (numpy.array) – Age-structured output matrix of the simulation method for the PheSEIRModel.
k (int) – Index of day for which we intend to sample the number of positive test results by age group.
- Returns:
The reproduction number in specified region at time \(t_k\).
- Return type:
float
Notes
Always run
PheSEIRModel.simulate(),PheSEIRModel.check_positives_format()andPheSEIRModel.compute_transistion_matrix()before running this one.
- compute_transition_matrix()[source]¶
Computes the transition matrix of the PHE model.
- Returns:
Transition matrix of the PHE model in specified region at time \(t_k\).
- Return type:
numpy.array
- loglik_deaths(obs_death, new_infections, fatality_ratio, time_to_death, niu, k)[source]¶
Computes the log-likelihood for the number of deaths at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of deaths is assumed to be distributed according to a negative binomial distribution with mean
\[\mu_{r,t_k,i} = p_i \sum_{l=0}^{k} f_{k-l} \delta_{r,t_l,i}^{infec}\]and variance \(\mu_{r,t_k,i} (\nu + 1)\), where \(p_i\) is the age-specific fatality ratio for age group \(i\), \(f_{k-l}\) is the probability of demise \(k-l\) days after infection and \(\delta_{r,t_l,i}^{infec}\) is the number of new infections in specified region, for age group \(i\) on day \(t_l\).
It uses new_infections output of the simulation method for the PheSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
obs_death (list) – List of number of observed deaths by age group at time point k.
new_infections (numpy.array) – Age-structured matrix of the number of new infections from the simulation method for the PheSEIRModel.
fatality_ratio (list) – List of age-specific fatality ratios.
time_to_death (list) – List of probabilities of death of individual k days after infection.
niu (float) – Dispersion factor for the negative binomial distribution.
k (int) – Index of day for which we intend to sample the number of deaths for by age group.
- Returns:
Age-structured matrix of log-likelihoods for the observed number of deaths in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
PheSEIRModel.new_infections()andPheSEIRModel.check_death_format()before running this one.
- loglik_positive_tests(obs_pos, output, tests, sens, spec, k)[source]¶
Computes the log-likelihood for the number of positive tests at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of positive tests is assumed to be distributed according to a binomial distribution with parameters \(n = n_{r,t_k,i}\) and
\[p = k_{sens} (1-\frac{S_{r,t_k,i}}{N_{r,i}}) + ( 1-k_{spec}) \frac{S_{r,t_k,i}}{N_{r,i}}\]where \(n_{r,t_k,i}\) is the number of tests conducted for people in age group \(i\) in specified region \(r\) at time atep \(t_k\), \(k_{sens}\) and \(k_{spec}\) are the sensitivity and specificity respectively of a test, while is the probability of demise \(k-l\) days after infection and \(\delta_{r,t_l,i}^{infec}\) is the number of new infections in specified region, for age group \(i\) on day \(t_l\).
It uses an output of the simulation method for the PheSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
obs_pos (list) – List of number of observed positive test results by age group at time point k.
output (numpy.array) – Age-structured output matrix of the simulation method for the PheSEIRModel.
tests (list) – List of conducted tests in specified region and at time point k classified by age groups.
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).
k (int) – Index of day for which we intend to sample the number of positive test results by age group.
- Returns:
Age-structured matrix of log-likelihoods for the observed number of positive test results for each age group in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
PheSEIRModel.simulate()andPheSEIRModel.check_positives_format()before running this one.
- mean_deaths(fatality_ratio, time_to_death, k, d_infec)[source]¶
Computes the mean of the negative binomial distribution used to calculate number of deaths for specified age group.
- Parameters:
fatality_ratio (list) – List of age-specific fatality ratios.
time_to_death (list) – List of probabilities of death of individual k days after infection.
k (int) – Index of day for which we intend to sample the number of deaths for by age group.
d_infec (numpy.array) – Age-structured matrix of the number of new infections from the simulation method for the PheSEIRModel.
- Returns:
Age-structured matrix of the expected number of deaths to be observed in specified region at time \(t_k\).
- Return type:
numpy.array
- mean_positives(sens, spec, suscep, pop)[source]¶
Computes the mean of the binomial distribution used to calculate number of positive test results for specified age group.
- Parameters:
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).
suscep (numpy.array) – Age-structured matrix of the current number of susceptibles in the population.
pop (numpy.array) – Age-structured matrix of the current number of individuals in the population.
- Returns:
Age-structured matrix of the expected number of positive test results to be observed in specified region at time \(t_k\).
- Return type:
numpy.array
- n_parameters()[source]¶
Returns the number of parameters.
- Returns:
Number of parameters.
- Return type:
int
- new_infections(output)[source]¶
Computes number of new infections at each time step in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
It uses an output of the simulation method for the PheSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
output (numpy.array) – Age-structured output of the simulation method for the PheSEIRModel.
- Returns:
Age-structured matrix of the number of new infections from the simulation method for the PheSEIRModel.
- Return type:
numpy.array
Notes
Always run
PheSEIRModel.simulate()before running this one.
- output_names()[source]¶
Returns the (selected) output names.
- Returns:
List of the (selected) output names.
- Return type:
list
- parameter_names()[source]¶
Returns the parameter names.
- Returns:
List of the parameter names.
- Return type:
list
- read_contact_data(matrices_contact, time_changes_contact)[source]¶
Reads in the timelines of contact data used for the modelling.
- Parameters:
matrices_contact (list of ContactMatrix) – List of time-dependent contact matrices used for the modelling.
time_changes_contact (list) – List of times at which the next contact matrix recorded starts to be used. In increasing order.
- read_regional_data(matrices_region, time_changes_region)[source]¶
Reads in the timelines of regional data used for the modelling.
- Parameters:
matrices_region (lists of RegionMatrix) – List of time-dependent and region-specific relative susceptibility matrices used for the modelling.
time_changes_region (list) – List of times at which the next instances of region-specific relative susceptibility matrices recorded start to be used. In increasing order.
- region_names()[source]¶
Returns the regions names.
- Returns:
List of the regions names.
- Return type:
list
- samples_deaths(new_infections, fatality_ratio, time_to_death, niu, k)[source]¶
Computes samples for the number of deaths at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of deaths is assumed to be distributed according to a negative binomial distribution with mean
\[\mu_{r,t_k,i} = p_i \sum_{l=0}^{k} f_{k-l} \delta_{r,t_l,i}^{infec}\]and variance \(\mu_{r,t_k,i} (\nu + 1)\), where \(p_i\) is the age-specific fatality ratio for age group \(i\), \(f_{k-l}\) is the probability of demise \(k-l\) days after infection and \(\delta_{r,t_l,i}^{infec}\) is the number of new infections in specified region, for age group \(i\) on day \(t_l\).
It uses an output of the simulation method for the PheSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
new_infections (numpy.array) – Age-structured matrix of the number of new infections from the simulation method for the PheSEIRModel.
fatality_ratio (list) – List of age-specific fatality ratios.
time_to_death (list) – List of probabilities of death of individual k days after infection.
niu (float) – Dispersion factor for the negative binomial distribution.
k (int) – Index of day for which we intend to sample the number of deaths for by age group.
- Returns:
Age-structured matrix of sampled number of deaths in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
PheSEIRModel.new_infections()andPheSEIRModel.check_death_format()before running this one.
- samples_positive_tests(output, tests, sens, spec, k)[source]¶
Computes the samples for the number of positive tests at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of positive tests is assumed to be distributed according to a binomial distribution with parameters \(n = n_{r,t_k,i}\) and
\[p = k_{sens} (1-\frac{S_{r,t_k,i}}{N_{r,i}}) + ( 1-k_{spec}) \frac{S_{r,t_k,i}}{N_{r,i}}\]where \(n_{r,t_k,i}\) is the number of tests conducted for people in age group \(i\) in specified region \(r\) at time atep \(t_k\), \(k_{sens}\) and \(k_{spec}\) are the sensitivity and specificity respectively of a test, while is the probability of demise \(k-l\) days after infection and \(\delta_{r,t_l,i}^{infec}\) is the number of new infections in specified region, for age group \(i\) on day \(t_l\).
It uses an output of the simulation method for the PheSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
output (numpy.array) – Age-structured output matrix of the simulation method for the PheSEIRModel.
tests (list) – List of conducted tests in specified region and at time point k classified by age groups.
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).
k (int) – Index of day for which we intend to sample the number of positive test results by age group.
- Returns:
Age-structured matrix of sampled number of positive test results in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
PheSEIRModel.simulate()andPheSEIRModel.check_positives_format()before running this one.
- set_age_groups(age_groups)[source]¶
Sets age group names and counts their number.
- Parameters:
age_groups (list) – List of age group names considered by the model.
- set_outputs(outputs)[source]¶
Checks existence of outputs and selects only those remaining.
- Parameters:
outputs (list) – List of output names that are selected.
- set_regions(regions)[source]¶
Sets region names.
- Parameters:
regions (list) – List of region names considered by the model.
- simulate(parameters)[source]¶
Simulates the PHE model using a
PheParametersControllerfor the model parameters.Extends the
_split_simulate(). Always apply methodsset_regions(),set_age_groups(),read_contact_data()andread_regional_data()before running thePheSEIRModel.simulate().- Parameters:
parameters (PheParametersController) – Controller class for the parameters used by the forward simulation of the model.
- Returns:
Age-structured output matrix of the simulation for the specified region.
- Return type:
numpy.array
Roche SEIRD Model¶
- class epimodels.RocheSEIRModel[source]¶
RocheSEIRModel Class: Base class for constructing the ODE model: deterministic SEIRD used by the F. Hoffmann-La Roche Ltd to model the Covid-19 epidemic and the effects of non-pharmaceutical interventions (NPIs) on the epidemic dynamic in different countries.
The population is structured such that every individual will belong to one of the compartments of the extended SEIRD model.
The general SEIRD Model has five compartments - susceptible individuals (\(S\)), exposed but not yet infectious (\(E\)), infectious (\(I\)), recovered (\(R\)) and dead (\(D\)).
In the Roche model framework, the infectious compartment is split into 6 distinct ones: depending on whether they are super-spreader or not, and whether are in the presymptomatic phase, which can than evolve into either symptomatic or asymptomatic infectious. We also consider a population divided in age groups, as we expect people of different ages to interact differently between themselves and to be affected differently by the virus, i.e. have different death and recovery rates and proportions of asymptomatic, dead an recovered individuals. The model structure now becomes, for each region:
\begin{eqnarray} \frac{dS_i}{dt} &=& \sum_{j} C_{ij}(- \frac{\beta_a}{N} S_i {I^a}_j - \frac{\beta_{aa}}{N} S_i {I^{aa}}_j - \frac{\beta_s}{N} S_i {I^s}_j - \frac{\beta_{as}}{N} S_i {I^{as}}_j - \frac{\beta_{aas}}{N} S_i {I^{aas}}_j - \frac{\beta_{ss}}{N} S_i {I^{ss}}_j) \\ \frac{dE_i}{dt} &=& -\gamma_e E_i + \sum_{j} C_{ij}( \frac{\beta_a}{N} S_i {I^a}_j + \frac{\beta_{aa}}{N} S_i {I^{aa}}_j + \frac{\beta_s}{N} S_i {I^s}_j + \frac{\beta_{as}}{N} S_i {I^{as}}_j + \frac{\beta_{aas}}{N} S_i {I^{aas}}_j + \frac{\beta_{ss}}{N} S_i {I^{ss}}_j) \\ \frac{d{I^a}_i}{dt} &=& (1 - P_{ss}) \gamma_e E_i - \gamma_s {I^a}_i \\ \frac{d{I^{aa}}_i}{dt} &=& {P_a}_i \gamma_s {I^a}_i - {\gamma_{ra}}_i {I^{aa}}_i \\ \frac{d{I^s}_i}{dt} &=& (1 - {P_a}_i) \gamma_s {I^a}_i - \gamma_q {I^s}_i \\ \frac{d{I^{as}}_i}{dt} &=& P_{ss} \gamma_e E_i - \gamma_s {I^{as}}_i \\ \frac{d{I^{aas}}_i}{dt} &=& {P_a}_i \gamma_s {I^{as}}_i - {\gamma_{ra}}_i {I^{aas}}_i \\ \frac{d{I^{ss}}_i}{dt} &=& (1 - {P_a}_i) \gamma_s {I^{as}}_i - \gamma_q {I^{ss}}_i \\ \frac{d{I^q}_i}{dt} &=& \gamma_q {I^{ss}}_i + \gamma_q {I^s}_i - {\gamma_r}_i {I^q}_i\\ \frac{dR^i}{dt} &=& (1 - {P_d}_i) {\gamma_r}_i {I^q}_i \\ \frac{d{R^a}_i}{dt} &=& {\gamma_{ra}}_i {I^{aas}}_i + {\gamma_{ra}}_i {I^{aa}}_i \\ \frac{dD_i}{dt} &=& {P_d}_i {\gamma_r}_i {I^q}_i \end{eqnarray}where \(i\) is the age group of the individual, \(C_{ij}\) is the \((i,j)`th element of the regional contact matrix, and represents the expected number of contacts in age group :math:`i\) made by an individuals in age group \(j\) on a given day. \(N\) is the total population size.
The transmission parameters are the rates with which different types of infectious individual infects susceptible ones.
The transmission rates for the different types of infectious vectors are:
\(\beta_a\): presymptomatic infectious;
\(\beta_{aa}\): asymptomatic infectious;
\(\beta_s\): symptomatic infectious;
\(\beta_{as}\): presymptomatic super-spreader infectious;
\(\beta_{aas}\): asymptomatic super-spreader infectious;
\(\beta_{ss}\): symptomatic super-spreader infectious.
The transmission rates depend on each other according to the following formulae:
\begin{eqnarray} \beta_a &=& \beta_{aa} = \frac{\beta_s}{2} \\ \beta_{as} &=& \beta_{aas} = \frac{\beta_{ss}}{2} \\ \beta_{s} &=& \beta_{max} - (\beta_{max} - \beta_{min})\frac{ SI^\gamma}{SI^\gamma + SI_50^\gamma} \\ \beta_{as} &=& (1 + b_{ss})\beta_a \\ \beta_{aas} &=& (1 + b_{ss})\beta_{aa} \\ \beta_{ss} &=& (1 + b_{ss})\beta_s \\ \end{eqnarray}where \(b_{ss}\) represents the relative increase in transmission of a super-spreader case and \(\gamma\) is the sharpness of the intervention wave used for function continuity purposes. Larger values of this parameter cause the curve to more closely approach the step function.
The \(P_a\), \(P_{ss}\) and \(P_d\) parameters represent the proportions of people that go on to become asymptomatic, super-spreaders or dead, respectively. Because we expect older people to be more likely to die and younger people to be more likely to be asymptomatic, we consider \(P_a\) and \(P_d\) to be age dependent.
The rates of progression through the different stages of the illness are:
\(\gamma_e\): exposed to presymptomatic infectious status;
\(\gamma_s\): presymptomatic to (a)symptomatic infectious status;
\(\gamma_q\): symptomatic to quarantined infectious status;
\(\gamma_r\): quarantined infectious to recovered (or dead) status;
\(\gamma_{ra}\): asymptomatic to recovered (or dead) status.
Because we expect older and younger people to recover differently from the virus we consider \(\gamma_r\) and \(\gamma_{ra}\) to be age dependent. These rates are computed according to the following formulae:
\begin{eqnarray} \gamma_e &=& \frac{1}{k} \\ \gamma_s &=& \frac{1}{k_s} \\ \gamma_q &=& \frac{1}{k_q} \\ {\gamma_r}_i &=& \frac{1}{{k_r}_i} \\ {\gamma_{ra}}_i &=& \frac{1}{{k_{ri}}_i} \\ \end{eqnarray}where \(k\) refers to mean incubation period until disease onset (i.e. from exposed to presymptomatic infection), \(k_s\) the average time to developing symptoms since disease onset, \(k_q\) the average time until the case is quarantined once the symptoms appear, \(k_r\) the average time until recovery since the start of the quarantine period and \(k_{ri}\) the average time to recovery since the end of the presymptomatic stage for an asymptomatic case.
\(S(0) = S_0\), \(E(0) = E_0\), \(I^a(0) = I^a_0\), \(I^{aa}(0) = I^{aa}_0\), \(I^s(0) = I^s_0\), \(I^{as}(0) = I^{as}_0\), \(I^{aas}(0) = I^{aas}_0\), \(I^{ss}(0) = I^{ss}_0\), \(I^q(0) = I^q_0\), \(R(0) = R_0\), \(R^a(0) = R^a_0\), \(D(0) = D_0\) are also parameters of the model (evaluation at 0 refers to the compartments’ structure at initial time.
Extends
pints.ForwardModel.- age_groups_names()[source]¶
Returns the age group names.
- Returns:
List of the age group names.
- Return type:
list
- check_death_format(new_deaths, niu)[source]¶
Checks correct format of the inputs of number of death calculation.
- Parameters:
new_deaths (numpy.array) – Age-structured matrix of the number of new deaths from the simulation method for the RocheSEIRModel.
niu (float) – Dispersion factor for the negative binomial distribution.
- check_positives_format(output, tests, sens, spec)[source]¶
Checks correct format of the inputs of number of positive test results calculation.
- Parameters:
output (numpy.array) – Age-structured output matrix of the simulation method for the RocheSEIRModel.
tests (list) – List of conducted tests in specified region and at time point k classified by age groups.
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).
- compute_rt_trajectory(output, k)[source]¶
Computes the time-dependent reproduction at time \(t_k\) from the Roche model.
- Parameters:
output (numpy.array) – Age-structured output matrix of the simulation method for the RocheSEIRModel.
k (int) – Index of day for which we intend to sample the number of positive test results by age group.
- Returns:
The reproduction number in specified region at time \(t_k\).
- Return type:
float
Notes
Always run
RocheSEIRModel.simulate(),RocheSEIRModel.check_positives_format()andRocheSEIRModel.compute_transistion_matrix()before running this one.
- compute_transition_matrix()[source]¶
Computes the transition matrix of the Roche model.
- Returns:
Transition matrix of the Roche model in specified region at time \(t_k\).
- Return type:
numpy.array
- formula_SI(sub_indices)[source]¶
Formula for computing the stringency index using the sub-indices computed using the levels prescribed for the non-pharmaceutical interventions.
In the case of the Roche model the stringency index is computed according to the following formula
\[SI = \frac{1}{7}(I_1 + I_2 + max(I_3, I_4) + I_5 + max(I_6, I_7) + I_8 + I_9)\]where \(I_j\) represents sub-index computed for the \(j\) th intervention. For the Roche model, the interventions are defined as in the table bellow:
Intervention
Max Level \(N_j\)
Targeted
General Value
School closing
3 (0, 1, 2, 3)
Yes
1
Workplace closing
3 (0, 1, 2, 3)
Yes
1
Cancel public events
2 (0, 1, 2)
Yes
1
Restrictions on gatherings
4 (0, 1, 2, 3, 4)
Yes
1
Close public transport
2 (0, 1, 2)
Yes
1
Stay at home requirements
3 (0, 1, 2, 3)
Yes
1
Restrictions on internal movement
2 (0, 1, 2)
Yes
1
International travel controls
4 (0, 1, 2, 3, 4)
No
0
Public information campaigns
2 (0, 1, 2)
Yes
1
- Parameters:
sub_indices (list) – List of sub-indices values of strength of each intervention.
- loglik_deaths(obs_death, new_deaths, niu, k)[source]¶
Computes the log-likelihood for the number of deaths at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of deaths is assumed to be distributed according to a negative binomial distribution with mean \(\mu_{r,t_k,i}\) and variance \(\mu_{r,t_k,i} (\nu + 1)\), where \(\mu_{r,t_k,i}\) is the number of new deaths in specified region, for age group \(i\) on day \(t_k\).
It uses new_infections output of the simulation method for the RocheSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
obs_death (list) – List of number of observed deaths by age group at time point k.
new_deaths (numpy.array) – Age-structured matrix of the number of new deaths from the simulation method for the RocheSEIRModel.
niu (float) – Dispersion factor for the negative binomial distribution.
k (int) – Index of day for which we intend to sample the number of deaths for by age group.
- Returns:
Age-structured matrix of log-likelihoods for the observed number of deaths in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
RocheSEIRModel.new_infections()andRocheSEIRModel.check_death_format()before running this one.
- loglik_positive_tests(obs_pos, output, tests, sens, spec, k)[source]¶
Computes the log-likelihood for the number of positive tests at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of positive tests is assumed to be distributed according to a binomial distribution with parameters \(n = n_{r,t_k,i}\) and
\[p = k_{sens} (1-\frac{S_{r,t_k,i}}{N_{r,i}}) + ( 1-k_{spec}) \frac{S_{r,t_k,i}}{N_{r,i}}\]where \(n_{r,t_k,i}\) is the number of tests conducted for people in age group \(i\) in specified region \(r\) at time atep \(t_k\), \(k_{sens}\) and \(k_{spec}\) are the sensitivity and specificity respectively of a test, while is the probability of demise \(k-l\) days after infection and \(\delta_{r,t_l,i}^{infec}\) is the number of new infections in specified region, for age group \(i\) on day \(t_l\).
It uses an output of the simulation method for the RocheSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
obs_pos (list) – List of number of observed positive test results by age group at time point k.
output (numpy.array) – Age-structured output matrix of the simulation method for the RocheSEIRModel.
tests (list) – List of conducted tests in specified region and at time point k classified by age groups.
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).
k (int) – Index of day for which we intend to sample the number of positive test results by age group.
- Returns:
Age-structured matrix of log-likelihoods for the observed number of positive test results for each age group in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
RocheSEIRModel.simulate()andRocheSEIRModel.check_positives_format()before running this one.
- mean_deaths(k, new_deaths)[source]¶
Computes the mean of the negative binomial distribution used to calculate number of deaths for specified age group.
- Parameters:
k (int) – Index of day for which we intend to sample the number of deaths for by age group.
new_deaths (numpy.array) – Age-structured matrix of the number of new deaths from the simulation method for the RocheSEIRModel.
- Returns:
Age-structured matrix of the expected number of deaths to be observed in specified region at time \(t_k\).
- Return type:
numpy.array
- mean_positives(sens, spec, suscep, pop)[source]¶
Computes the mean of the binomial distribution used to calculate number of positive test results for specified age group.
- Parameters:
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).
suscep (numpy.array) – Age-structured matrix of the current number of susceptibles in the population.
pop (numpy.array) – Age-structured matrix of the current number of individuals in the population.
- Returns:
Age-structured matrix of the expected number of positive test results to be observed in specified region at time \(t_k\).
- Return type:
numpy.array
- n_parameters()[source]¶
Returns the number of parameters.
- Returns:
Number of parameters.
- Return type:
int
- new_deaths(output)[source]¶
Computes number of new deaths at each time step in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
It uses an output of the simulation method for the RocheSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
output (numpy.array) – Age-structured output of the simulation method for the RocheSEIRModel.
- Returns:
Age-structured matrix of the number of new deaths from the simulation method for the RocheSEIRModel.
- Return type:
numpy.array
Notes
Always run
RocheSEIRModel.simulate()before running this one.
- new_infections(output)[source]¶
Computes number of new infections at each time step in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
It uses an output of the simulation method for the RocheSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
output (numpy.array) – Age-structured output of the simulation method for the RocheSEIRModel.
- Returns:
Age-structured matrix of the number of new infections from the simulation method for the RocheSEIRModel.
- Return type:
numpy.array
Notes
Always run
RocheSEIRModel.simulate()before running this one.
- output_names()[source]¶
Returns the (selected) output names.
- Returns:
List of the (selected) output names.
- Return type:
list
- parameter_names()[source]¶
Returns the parameter names.
- Returns:
List of the parameter names.
- Return type:
list
- read_contact_data(matrices_contact, time_changes_contact)[source]¶
Reads in the timelines of contact data used for the modelling.
- Parameters:
matrices_contact (list of ContactMatrix) – List of time-dependent contact matrices used for the modelling.
time_changes_contact (list) – List of times at which the next contact matrix recorded starts to be used. In increasing order.
- read_npis_data(max_levels_npi, targeted_npi, general_npi, reg_levels_npi, time_changes_npi, time_changes_flag)[source]¶
Reads in the timelines of non-pharmaceutical interventions used for the modelling. These are expressed as levels of severity for each different type of NPI, e.g. for a “school closer” measure implemented we can assign it a value for 0, 1, 2 or 3 with 3 for the case with most restrictions in place.
- 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_regional_data(matrices_region, time_changes_region)[source]¶
Reads in the timelines of regional data used for the modelling.
- Parameters:
matrices_region (lists of RegionMatrix) – List of time-dependent and region-specific relative susceptibility matrices used for the modelling.
time_changes_region (list) – List of times at which the next instances of region-specific relative susceptibility matrices recorded start to be used. In increasing order.
- region_names()[source]¶
Returns the regions names.
- Returns:
List of the regions names.
- Return type:
list
- samples_deaths(new_deaths, niu, k)[source]¶
Computes samples for the number of deaths at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of deaths is assumed to be distributed according to a negative binomial distribution with mean \(\mu_{r,t_k,i}\) and variance \(\mu_{r,t_k,i} (\nu + 1)\), where \(\mu_{r,t_k,i}\) is the number of new deaths in specified region, for age group \(i\) on day \(t_k\).
It uses an output of the simulation method for the RocheSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
new_deaths (numpy.array) – Age-structured matrix of the number of new deaths from the simulation method for the RocheSEIRModel.
niu (float) – Dispersion factor for the negative binomial distribution.
k (int) – Index of day for which we intend to sample the number of deaths for by age group.
- Returns:
Age-structured matrix of sampled number of deaths in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
RocheSEIRModel.new_infections()andRocheSEIRModel.check_death_format()before running this one.
- samples_positive_tests(output, tests, sens, spec, k)[source]¶
Computes the samples for the number of positive tests at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of positive tests is assumed to be distributed according to a binomial distribution with parameters \(n = n_{r,t_k,i}\) and
\[p = k_{sens} (1-\frac{S_{r,t_k,i}}{N_{r,i}}) + ( 1-k_{spec}) \frac{S_{r,t_k,i}}{N_{r,i}}\]where \(n_{r,t_k,i}\) is the number of tests conducted for people in age group \(i\) in specified region \(r\) at time atep \(t_k\), \(k_{sens}\) and \(k_{spec}\) are the sensitivity and specificity respectively of a test, while is the probability of demise \(k-l\) days after infection and \(\delta_{r,t_l,i}^{infec}\) is the number of new infections in specified region, for age group \(i\) on day \(t_l\).
It uses an output of the simulation method for the RocheSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
output (numpy.array) – Age-structured output matrix of the simulation method for the RocheSEIRModel.
tests (list) – List of conducted tests in specified region and at time point k classified by age groups.
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).
k (int) – Index of day for which we intend to sample the number of positive test results by age group.
- Returns:
Age-structured matrix of sampled number of positive test results in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
RocheSEIRModel.simulate()andRocheSEIRModel.check_positives_format()before running this one.
- set_age_groups(age_groups)[source]¶
Sets age group names and counts their number.
- Parameters:
age_groups (list) – List of age group names considered by the model.
- set_outputs(outputs)[source]¶
Checks existence of outputs and selects only those remaining.
- Parameters:
outputs (list) – List of output names that are selected.
- set_regions(regions)[source]¶
Sets region names.
- Parameters:
regions (list) – List of region names considered by the model.
- simulate(parameters)[source]¶
Simulates the Roche model using a
RocheParametersControllerfor the model parameters.Extends the
_split_simulate(). Always apply methodsset_regions(),set_age_groups(),read_contact_data()andread_regional_data()before running theRocheSEIRModel.simulate().- Parameters:
parameters (RocheParametersController) – Controller class for the parameters used by the forward simulation of the model.
- Returns:
Age-structured output matrix of the simulation for the specified region.
- Return type:
numpy.array
Warwick-Household Model¶
- class epimodels.WarwickSEIRModel[source]¶
WarwickSEIRModel Class: Base class for constructing the ODE model: deterministic SEIR developed by University of Warwick to model the Covid-19 epidemic and the effects of within-household dynamics on the epidemic trajectory in different countries.
The population is structured such that every individual will belong to one of the compartments of the extended SEIR model.
The general SEIR Model has four compartments - susceptible individuals (\(S\)), exposed but not yet infectious (\(E\)), infectious (\(I\)) and recovered (\(R\)).
In the Warwick-Household model framework, the exposed are split first into four compartments, depending on the type of infective that has infected them within the household, and each of them further into three sequential exposed compartments to illustrate different latency stages. The infectious compartment is split into 8 distinct ones: depending on whether they are symptomatic or asymptomatic infectious, and whether they are the first in the household to be infected, if they are quarantined, or are a subsequent infection. We also consider a population divided in age groups, as we expect people of different ages to interact differently between themselves and to be affected differently by the virus, i.e. have different susceptibilities to infection and proportions of asymptomatic individuals. The model structure now becomes, for each region:
\begin{eqnarray} \frac{dS_i}{dt} &=& - \sigma \Big(C^N \big(\frac{S_i}{N} I^F_j + \frac{S_i}{N} I^{SD}_j + \frac{S_i}{N} I^{SU}_j + \tau(\frac{S_i}{N} A^F_j + \frac{S_i}{N} A^S_j)\big) + +C^H (\frac{S_i}{N} I^F_j + \frac{S_i}{N} A^F_j + \frac{S_i}{N} I^{QF}_j) \Big)\\ \frac{dE^{1,F}_i}{dt} &=& \sigma C^N \big(\frac{S_i}{N} I^F_j + \frac{S_i}{N} I^{SD}_i + \frac{S_i}{N} I^{SU}_j + \tau(\frac{S_i}{N} A^F_j + \frac{S_i}{N} A^S_j)\big) - 3 \epsilon E^{1,F}_j \\ \frac{dE^{1,SD}_i}{dt} &=& \sigma C^H \frac{S_i}{N} I^F_i - 3 \epsilon E^{1,SD}_i \\ \frac{dE^{1,SU}_i}{dt} &=& \sigma C^H \frac{S_i}{N} A^F_i - 3 \epsilon E^{1,SU}_i \\ \frac{dE^{1,Q}_i}{dt} &=& \sigma C^H S_i I^{QF}_i - 3 \epsilon E^{1,Q}_i \\ \frac{dE^{2,F}_i}{dt} &=& 3 \epsilon E^{1,F}_i - 3 \epsilon E^{2,F}_i \\ \frac{dE^{2,SD}_i}{dt} &=& 3 \epsilon E^{1,SD}_i - 3 \epsilon E^{2,SD}_i \\ \frac{dE^{2,SU}_i}{dt} &=& 3 \epsilon E^{1,SU}_i - 3 \epsilon E^{2,SU}_i \\ \frac{dE^{2,Q}_i}{dt} &=& 3 \epsilon E^{1,Q}_i - 3 \epsilon E^{2,Q}_i \\ \frac{dE^{3,F}_i}{dt} &=& 3 \epsilon E^{2,F}_i - 3 \epsilon E^{3,F}_i \\ \frac{dE^{3,SD}_i}{dt} &=& 3 \epsilon E^{2,SD}_i - 3 \epsilon E^{3,SD}_i \\ \frac{dE^{3,SU}_i}{dt} &=& 3 \epsilon E^{2,SU}_i - 3 \epsilon E^{3,SU}_i \\ \frac{dE^{1,Q}_i}{dt} &=& 3 \epsilon E^{2,Q}_i - 3 \epsilon E^{3,Q}_i \\ \frac{dI^F_i}{dt} &=& 3 (1-H) \epsilon d E^{3,F}_i - \gamma I^F_i \\ \frac{dI^{SD}_i}{dt} &=& 3 \epsilon d E^{3,SD}_i - \gamma I^{SD}_i \\ \frac{dI^{SU}_i}{dt} &=& 3 (1-H) \epsilon d E^{3,SU}_i - \gamma I^{SU}_i \\ \frac{dI^{QF}_i}{dt} &=& 3 H \epsilon d E^{3,F}_i - \gamma I^{QF}_i \\ \frac{dI^{QS}_i}{dt} &=& 3 H \epsilon d E^{3,SU}_i + 3 \epsilon d E^{3,Q}_i) - \gamma I^{QS}_i \\ \frac{dA^F_i}{dt} &=& 3 \epsilon (1 - d) E^{3,F}_i - \gamma A^F_i \\ \frac{dA^S_i}{dt} &=& 3 \epsilon (1 - d) (E^{3,SD}_i + E^{3,SU}_i) - \gamma A^S_i \\ \frac{dA^Q_i}{dt} &=& 3 \epsilon (1 - d) E^{3,Q}_i - \gamma A^Q_i \\ \frac{dR_i}{dt} &=& \gamma (I^F_i + I^{QF}_i + A^F_i + I^{SD}_i + A^S_i + I^{SU}_i + I^{QS}_i + A^Q_i) \end{eqnarray}where \(i\) is the age group of the individual, \(C^H_{ij}\) is the \((i,j)\) the element of the regional household contact matrix, and represents the expected number of contacts in age group \(i\) within the household made by an individuals in age group \(j\) on a given day. Similarly, \(C^N_{ij}\) is the \((i,j)\) the element of the regional non-household contact matrix and represents the expected number of contacts in age group \(i\) outside the household made by an individual in age group \(j\) on a given day. \(N\) is the total population size.
Non-pharmaceutical interventions will alter the number of contacts individuals will have in each context per day. The correct \(C^H\) and \(C^N\) matrices are calculated each day by computing a weighted average between the baseline matrices for contacts within household (\(C^{H, base}\)), at school (\(C^{S, base}\)), in the workplace (\(C^{W, base}\)) and in all other contexts (\(C^{O, base}\)) and their full-lockdown equivalents which are given by:
\begin{eqnarray} C^{H, lock} &=& q_H * C^{H, base} \\ C^{S, lock} &=& q_S * C^{S, base} \\ C^{W, lock} &=& q_W * C^{W, base} \\ C^{O, lock} &=& q_O * C^{O, base} \\ \end{eqnarray}where \(q_H\) is the coefficient of increase in contacts within the household and \(q_S\), \(q_W\) and \(q_O\) are the decrease in contacts at school, in the workplace, and, respectively, in all other contexts when a full-lockdown is implemented. Therefore, the daily contact matrices \(C^H\) and \(C^N\) applied are given by:
\begin{eqnarray} C^H &=& 1.3 * \big((1-\phi)*C^{H, base} + \phi*C^{H, lock}\big) \\ C^S &=& \big((1-\phi)*C^{S, base} + \phi*C^{S, lock}\big) \\ C^W &=& \big(1-\theta + \theta * (1-\phi + \phi*q_O)\big) * \big( (1-\phi)*C^{W, base} + \phi*C^{W, lock}\big) \\ C^O &=& (1-\phi + \phi*q_O) * \big( (1-\phi)*C^{O, base} + \phi*C^{O, lock}\big) \\ \end{eqnarray}where \(\phi\) is a coefficient indicating the strength of the implemented interventions and \(\theta\) is a scaling factor of any public-facing interactions.
The transmission parameters are the rates with which different types of infectious individual infects susceptible ones. Asymptomatic infections are assumed to have a reduced transmission compared to their symptomatic counterpart. This reduction in transmission is indicated through the parameter \(\tau\) in the force of infection.
The \(\sigma\), \(H\) and \(d\) parameters represent the susceptibilities to the disease, the household quarantine compliance factor and, respectively, the proportions of people that go on to develop symptomatic infections. Because we expect older people to be more likely to be susceptible to infection and younger people to be more likely to be asymptomatic, we consider \(\sigma\) and \(d\) to be age dependent.
The rates of progression through the different stages of the illness are:
\(\epsilon\): exposed to (a)symptomatic infectious status;
\(\gamma\): (a)symptomatic to recovered status.
\(S(0) = S_0\), \(E^{1,F}(0) = E^{1,F}_0\), \(E^{1,SD}(0) = E^{1,SD}_0\), \(E^{1,SU}(0) = E^{1,SU}_0\), \(E^{1,Q}(0) = E^{1,Q}_0\), \(E^{2,F}(0) = E^{2,F}_0\), \(E^{2,SD}(0) = E^{2,SD}_0\), \(E^{2,SU}(0) = E^{2,SU}_0\), \(E^{2,Q}(0) = E^{2,Q}_0\), \(E^{3,F}(0) = E^{3,F}_0\), \(E^{3,SD}(0) = E^{3,SD}_0\), \(E^{3,SU}(0) = E^{3,SU}_0\), \(E^{3,Q}(0) = E^{3,Q}_0\), \(I^F(0) = I^F_0\), \(I^{SD}(0) = I^{SD}_0\), \(I^{SU}(0) = I^{SU}_0\), \(I^{QF}(0) = I^{QF}_0\), \(I^{QS}(0) = I^{QS}_0\), \(A^F(0) = A^F_0\), \(A^S(0) = A^S_0\), \(A^Q(0) = A^Q_0\), \(R(0) = R_0\), are also parameters of the model (evaluation at 0 refers to the compartments’ structure at initial time.
Extends
pints.ForwardModel.- age_groups_names()[source]¶
Returns the age group names.
- Returns:
List of the age group names.
- Return type:
list
- check_death_format(new_deaths, niu)[source]¶
Checks correct format of the inputs of number of death calculation.
- Parameters:
new_deaths (numpy.array) – Age-structured matrix of the number of new deaths from the simulation method for the WarwickSEIRModel.
niu (float) – Dispersion factor for the negative binomial distribution.
- check_new_deaths_format(new_hospitalisation, pHtoDeath, dHtoDeath)[source]¶
Checks correct format of the inputs of number of death calculation.
- Parameters:
new_hospitalisation (numpy.array) – Age-structured array of the daily number of new hospitalised cases.
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.
- check_new_hospital_beds_format(new_hospitalisations, new_icu, tH, tItoH)[source]¶
Checks correct format of the inputs of number of hospital beds occupied calculation.
- Parameters:
new_hospitalisations (numpy.array) – Age-structured array of the daily number of new symptomatic infections hospitalised.
new_icu (numpy.array) – Age-structured array of the daily number of new symptomatic infections admitted to icu.
tH (list) – Weighting distribution of the times spent in hospital by an admitted symptomatic case. Must be normalised.
tItoH (list) – Weighting distribution of the times spent in icu before being moved to a non-icu bed by an admitted symptomatic case. Must be normalised.
- check_new_hospitalisation_format(new_infections, pDtoH, dDtoH)[source]¶
Checks correct format of the inputs of number of hospitalisation calculation.
- Parameters:
new_infections (numpy.array) – Age-structured array of the daily number of new symptomatic infections.
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.
- check_new_icu_beds_format(new_icu, tI)[source]¶
Checks correct format of the inputs of number of ICU beds occupied calculation.
- Parameters:
new_icu (numpy.array) – Age-structured array of the daily number of new symptomatic infections admitted to icu.
tI (list) – Weighting probability distribution of that an ICU admitted case is still in ICU q days later. Must be normalised.
- check_new_icu_format(new_infections, pDtoI, dDtoI)[source]¶
Checks correct format of the inputs of number of ICU admissions calculation.
- Parameters:
new_infections (numpy.array) – Age-structured array of the daily number of new symptomatic infections.
pDtoI (list) – Age-dependent fractions of the number of symptomatic cases that end up in ICU.
dDtoI (list) – Distribution of the delay between onset of symptoms and admission to ICU. Must be normalised.
- check_positives_format(output, tests, sens, spec)[source]¶
Checks correct format of the inputs of number of positive test results calculation.
- Parameters:
output (numpy.array) – Age-structured output matrix of the simulation method for the WarwickSEIRModel.
tests (list) – List of conducted tests in specified region and at time point k classifed by age groups.
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).
- compute_rt_trajectory(output, k)[source]¶
Computes the time-dependent reproduction at time \(t_k\) from the Warwick-Household model.
- Parameters:
output (numpy.array) – Age-structured output matrix of the simulation method for the WarwickSEIRModel.
k (int) – Index of day for which we intend to sample the number of positive test results by age group.
- Returns:
The reproduction number in specified region at time \(t_k\).
- Return type:
float
Notes
Always run
WarwickSEIRModel.simulate(),WarwickSEIRModel.check_positives_format()andWarwickSEIRModel.compute_transistion_matrix()before running this one.
- compute_rt_trajectory_paper(k)[source]¶
Computes the time-dependent reproduction at time \(t_k\) from the Warwick-Household model.
- Parameters:
k (int) – Index of day for which we intend to sample the number of positive test results by age group.
- Returns:
The basic reproduction number in specified region at time \(t_k\).
- Return type:
float
- compute_transition_matrix()[source]¶
Computes the transition matrix of the Warwick-Household model.
- Returns:
Transition matrix of the Warwick-Household model in specified region at time \(t_k\).
- Return type:
numpy.array
- loglik_deaths(obs_death, new_deaths, niu, k)[source]¶
Computes the log-likelihood for the number of deaths at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of deaths is assumed to be distributed according to a negative binomial distribution with mean \(\mu_{r,t_k,i}\) and variance \(\mu_{r,t_k,i} (\nu + 1)\), where \(\mu_{r,t_k,i}\) is the number of new deaths in specified region, for age group \(i\) on day \(t_k\).
It uses new_infections output of the simulation method for the WarwickSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
obs_death (list) – List of number of observed deaths by age group at time point k.
new_deaths (numpy.array) – Age-structured matrix of the number of new deaths from the simulation method for the WarwickSEIRModel.
niu (float) – Dispersion factor for the negative binomial distribution.
k (int) – Index of day for which we intend to sample the number of deaths for by age group.
- Returns:
Age-structured matrix of log-likelihoods for the observed number of deaths in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
WarwickSEIRModel.new_infections()andWarwickSEIRModel.check_death_format()before running this one.
- loglik_positive_tests(obs_pos, output, tests, sens, spec, k)[source]¶
Computes the log-likelihood for the number of positive tests at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of positive tests is assumed to be distributed according to a binomial distribution with parameters \(n = n_{r,t_k,i}\) and
\[p = k_{sens} (1-\frac{S_{r,t_k,i}}{N_{r,i}}) + ( 1-k_{spec}) \frac{S_{r,t_k,i}}{N_{r,i}}\]where \(n_{r,t_k,i}\) is the number of tests conducted for people in age group \(i\) in specified region \(r\) at time atep \(t_k\), \(k_{sens}\) and \(k_{spec}\) are the sensitivity and specificity respectively of a test, while is the probability of demise \(k-l\) days after infection and \(\delta_{r,t_l,i}^{infec}\) is the number of new infections in specified region, for age group \(i\) on day \(t_l\).
It uses an output of the simulation method for the WarwickSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
obs_pos (list) – List of number of observed positive test results by age group at time point k.
output (numpy.array) – Age-structured output matrix of the simulation method for the WarwickSEIRModel.
tests (list) – List of conducted tests in specified region and at time point k classifed by age groups.
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).
k (int) – Index of day for which we intend to sample the number of positive test results by age group.
- Returns:
Age-structured matrix of log-likelihoods for the observed number of positive test results for each age group in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
WarwickSEIRModel.simulate()andWarwickSEIRModel.check_positives_format()before running this one.
- mean_deaths(k, new_deaths)[source]¶
Computes the mean of the negative binomial distribution used to calculate number of deaths for specified age group.
- Parameters:
k (int) – Index of day for which we intend to sample the number of deaths for by age group.
new_deaths (numpy.array) – Age-structured matrix of the number of new deaths from the simulation method for the WarwickSEIRModel.
- Returns:
Age-structured matrix of the expected number of deaths to be observed in specified region at time \(t_k\).
- Return type:
numpy.array
- mean_positives(sens, spec, suscep, pop)[source]¶
Computes the mean of the binomial distribution used to calculate number of positive test results for specified age group.
- Parameters:
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).
suscep (numpy.array) – Age-structured matrix of the current number of susceptibles in the population.
pop (numpy.array) – Age-structured matrix of the current number of individuals in the population.
- Returns:
Age-structured matrix of the expected number of positive test results to be observed in specified region at time \(t_k\).
- Return type:
numpy.array
- n_parameters()[source]¶
Returns the number of parameters.
- Returns:
Number of parameters.
- Return type:
int
- new_deaths(new_hospitalisation, pHtoDeath, dHtoDeath)[source]¶
Computes number of new deaths at each time step in specified region, given the simulated timeline of hospitalised number of individuals, for all age groups in the model.
It uses the array of the number of new symptomatic infections, obtained from an output of the simulation method for the WarwickSEIRModel, a distribution of the delay between onset of symptoms and admission to ICU, as well as the fraction of the number of hospitalised cases that end up dying.
- Parameters:
new_hospitalisation (numpy.array) – Age-structured array of the daily number of new hospitalised cases.
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.
- Returns:
Age-structured matrix of the number of new deaths from the simulation method for the WarwickSEIRModel.
- Return type:
nunmpy.array
Notes
Always run
WarwickSEIRModel.simulate()before running this one.
- new_hospital_beds(new_hospitalisations, new_icu, tH, tItoH)[source]¶
Computes number of hospital beds occupied at each time step in specified region, given the simulated timeline of detectable symptomatic infected number of individuals, for all age groups in the model.
It uses the arrays of the number of new symptomatic infections admitted to hospital and ICU respectively, a distribution of the delay between onset of symptoms and hospitalisation, as well as the fraction of the number of symptomatic cases that end up hospitalised.
- Parameters:
new_hospitalisations (numpy.array) – Age-structured array of the daily number of new symptomatic infections hospitalised.
new_icu (numpy.array) – Age-structured array of the daily number of new symptomatic infections admitted to icu.
tH (list) – Weighting distribution of the times spent in hospital by an admitted symptomatic case. Must be normalised.
tItoH (list) – Weighting distribution of the times spent in icu before being moved to a non-icu bed by an admitted symptomatic case. Must be normalised.
- Returns:
Age-structured matrix of the number of hospital beds occupied.
- Return type:
nunmpy.array
Notes
Always run
WarwickSEIRModel.simulate()before running this one.
- new_hospitalisations(new_infections, pDtoH, dDtoH)[source]¶
Computes number of new hospital admissions at each time step in specified region, given the simulated timeline of detectable symptomatic infected number of individuals, for all age groups in the model.
It uses the array of the number of new symptomatic infections, obtained from an output of the simulation method for the WarwickSEIRModel, a distribution of the delay between onset of symptoms and hospitalisation, as well as the fraction of the number of symptomatic cases that end up hospitalised.
- Parameters:
new_infections (numpy.array) – Age-structured array of the daily number of new symptomatic infections.
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.
- Returns:
Age-structured matrix of the number of new hospital admissions.
- Return type:
nunmpy.array
Notes
Always run
WarwickSEIRModel.simulate()before running this one.
- new_icu(new_infections, pDtoI, dDtoI)[source]¶
Computes number of new ICU admissions at each time step in specified region, given the simulated timeline of detectable symptomatic infected number of individuals, for all age groups in the model.
It uses the array of the number of new symptomatic infections, obtained from an output of the simulation method for the WarwickSEIRModel, a distribution of the delay between onset of symptoms and admission to ICU, as well as the fraction of the number of symptomatic cases that end up in ICU.
- Parameters:
new_infections (numpy.array) – Age-structured array of the daily number of new symptomatic infections.
pDtoI (list) – Age-dependent fractions of the number of symptomatic cases that end up in ICU.
dDtoI (list) – Distribution of the delay between onset of symptoms and admission to ICU. Must be normalised.
- Returns:
Age-structured matrix of the number of new ICU admissions.
- Return type:
nunmpy.array
Notes
Always run
WarwickSEIRModel.simulate()before running this one.
- new_icu_beds(new_icu, tI)[source]¶
Computes number of ICU beds occupied at each time step in specified region, given the simulated timeline of detectable symptomatic infected number of individuals, for all age groups in the model.
It uses the array of the number of new symptomatic infections admitted to ICU, as well as the weighting distribution of the times spent in hospital by an admitted symptomatic case.
- Parameters:
new_icu (numpy.array) – Age-structured array of the daily number of new symptomatic infections admitted to icu.
tI (list) – Weighting probability distribution of that an ICU admitted case is still in ICU q days later. Must be normalised.
- Returns:
Age-structured matrix of the number of hospital beds occupied.
- Return type:
nunmpy.array
Notes
Always run
WarwickSEIRModel.simulate()before running this one.
- new_infections(output)[source]¶
Computes number of new symptomatic infections at each time step in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
It uses an output of the simulation method for the WarwickSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
output (numpy.array) – Age-structured output of the simulation method for the WarwickSEIRModel.
- Returns:
Age-structured matrix of the number of new symptomatic infections from the simulation method for the WarwickSEIRModel.
- Return type:
nunmpy.array
Notes
Always run
WarwickSEIRModel.simulate()before running this one.
- output_names()[source]¶
Returns the (selected) output names.
- Returns:
List of the (selected) output names.
- Return type:
list
- parameter_names()[source]¶
Returns the parameter names.
- Returns:
List of the parameter names.
- Return type:
list
- read_contact_data(house_matrices_contact, school_matrices_contact, work_matrices_contact, other_matrices_contact, time_changes_contact)[source]¶
Reads in the timelines of contact data used for the modelling.
- Parameters:
house_matrices_contact (list of ContactMatrix) – List of time-dependent contact matrices used for the modelling, underlying household interactions.
school_matrices_contact (list of ContactMatrix) – List of time-dependent contact matrices used for the modelling, underlying school interactions.
work_matrices_contact (list of ContactMatrix) – List of time-dependent contact matrices used for the modelling, underlying workplace interactions.
other_matrices_contact (list of ContactMatrix) – List of time-dependent contact matrices used for the modelling, underlying other non-household interactions.
time_changes_contact (list) – List of times at which the next contact matrix recorded starts to be used. In increasing order.
- read_regional_data(house_matrices_region, school_matrices_region, work_matrices_region, other_matrices_region, time_changes_region)[source]¶
Reads in the timelines of regional data used for the modelling.
- Parameters:
house_matrices_region (lists of RegionMatrix) – List of time-dependent and region-specific relative susceptibility matrices used for the modelling, underlying household interactions.
school_matrices_region (lists of RegionMatrix) – List of time-dependent and region-specific relative susceptibility matrices used for the modelling, underlying school interactions.
work_matrices_region (lists of RegionMatrix) – List of time-dependent and region-specific relative susceptibility matrices used for the modelling, underlying workplace interactions.
other_matrices_region (lists of RegionMatrix) – List of time-dependent and region-specific relative susceptibility matrices used for the modelling, underlying other non-household interactions.
time_changes_region (list) – List of times at which the next instances of region-specific relative susceptibility matrices recorded start to be used. In increasing order.
- region_names()[source]¶
Returns the regions names.
- Returns:
List of the regions names.
- Return type:
list
- samples_deaths(new_deaths, niu, k)[source]¶
Computes samples for the number of deaths at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of deaths is assumed to be distributed according to a negative binomial distribution with mean \(\mu_{r,t_k,i}\) and variance \(\mu_{r,t_k,i} (\nu + 1)\), where \(\mu_{r,t_k,i}\) is the number of new deaths in specified region, for age group \(i\) on day \(t_k\).
It uses an output of the simulation method for the WarwickSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
new_deaths (numpy.array) – Age-structured matrix of the number of new deaths from the simulation method for the WarwickSEIRModel.
niu (float) – Dispersion factor for the negative binomial distribution.
k (int) – Index of day for which we intend to sample the number of deaths for by age group.
- Returns:
Age-structured matrix of sampled number of deaths in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
WarwickSEIRModel.new_infections()andWarwickSEIRModel.check_death_format()before running this one.
- samples_positive_tests(output, tests, sens, spec, k)[source]¶
Computes the samples for the number of positive tests at time step \(k\) in specified region, given the simulated timeline of susceptible number of individuals, for all age groups in the model.
The number of positive tests is assumed to be distributed according to a binomial distribution with parameters \(n = n_{r,t_k,i}\) and
\[p = k_{sens} (1-\frac{S_{r,t_k,i}}{N_{r,i}}) + ( 1-k_{spec}) \frac{S_{r,t_k,i}}{N_{r,i}}\]where \(n_{r,t_k,i}\) is the number of tests conducted for people in age group \(i\) in specified region \(r\) at time atep \(t_k\), \(k_{sens}\) and \(k_{spec}\) are the sensitivity and specificity respectively of a test, while is the probability of demise \(k-l\) days after infection and \(\delta_{r,t_l,i}^{infec}\) is the number of new infections in specified region, for age group \(i\) on day \(t_l\).
It uses an output of the simulation method for the WarwickSEIRModel, taking all the rest of the parameters necessary for the computation from the way its simulation has been fitted.
- Parameters:
output (numpy.array) – Age-structured output matrix of the simulation method for the WarwickSEIRModel.
tests (list) – List of conducted tests in specified region and at time point k classifed by age groups.
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).
k (int) – Index of day for which we intend to sample the number of positive test results by age group.
- Returns:
Age-structured matrix of sampled number of positive test results in specified region at time \(t_k\).
- Return type:
numpy.array
Notes
Always run
WarwickSEIRModel.simulate()andWarwickSEIRModel.check_positives_format()before running this one.
- set_age_groups(age_groups)[source]¶
Sets age group names and counts their number.
- Parameters:
age_groups (list) – List of age group names considered by the model.
- set_outputs(outputs)[source]¶
Checks existence of outputs and selects only those remaining.
- Parameters:
outputs (list) – List of output names that are selected.
- set_regions(regions)[source]¶
Sets region names.
- Parameters:
regions (list) – List of region names considered by the model.
- simulate(parameters)[source]¶
Simulates the Warwick model using a
WarwickParametersControllerfor the model parameters.Extends the
_split_simulate(). Always apply methodsset_regions(),set_age_groups(),read_contact_data()andread_regional_data()before running theWarwickSEIRModel.simulate().- Parameters:
parameters (WarwickParametersController) – Controller class for the parameters used by the forward simulation of the model.
- Returns:
Age-structured output matrix of the simulation for the specified region.
- Return type:
numpy.array