Title: | Optimise economic, social and health trade-offs in a pandemic |
---|---|
Description: | Model and optimise the trade-offs between social and economic activity while containing a pandemic, as presented in Haw et al. (2022) <doi.org/10.1038/s43588-022-00233-0>. |
Authors: | Pratik Gupte [aut, cre] , Imperial College of Science, Technology and Medicine [cph] |
Maintainer: | Pratik Gupte <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.6 |
Built: | 2024-09-18 12:25:03 UTC |
Source: | https://github.com/jameel-institute/daedalus |
Helper functions to create and work with S3 class
<daedalus_country>
objects for use with daedalus()
.
These objects store country parameters for reuse and have methods for easy
parameter access and editing, as well as processing raw country
characteristics for the DAEDALUS model.
daedalus_country( name, parameters = list(contact_matrix = NULL, contacts_workplace = NULL, contacts_consumer_worker = NULL) ) is_daedalus_country(x) ## S3 method for class 'daedalus_country' print(x, ...)
daedalus_country( name, parameters = list(contact_matrix = NULL, contacts_workplace = NULL, contacts_consumer_worker = NULL) ) is_daedalus_country(x) ## S3 method for class 'daedalus_country' print(x, ...)
name |
A string giving the country or territory name; must be from among country_names. |
parameters |
An optional named list of country parameters that are allowed to be modified. Currently, users may only pass their own contact matrix, workplace contacts, and consumer-worker contact matrix. If these are not passed, default values are accessed from stored package data. |
x |
An object of the |
... |
Other parameters passed to |
daedalus_country()
returns an object of the S3 class <daedalus_country>
is_daedalus_country()
returns a logical for whether an object is a
<daedalus_country>
.
print.daedalus_country()
invisibly returns the <daedalus_country>
object x
. Called for printing side-effects.
x <- daedalus_country("Canada") x daedalus_country( "United Kingdom", parameters = list(contact_matrix = matrix(1, 4, 4)) ) # check whether `x` is a <country> object is_daedalus_country(x) # assign class members # using set_data() set_data(x, contact_matrix = matrix(99, 4, 4)) # using assignment operators x$contact_matrix <- matrix(99, 4, 4) x
x <- daedalus_country("Canada") x daedalus_country( "United Kingdom", parameters = list(contact_matrix = matrix(1, 4, 4)) ) # check whether `x` is a <country> object is_daedalus_country(x) # assign class members # using set_data() set_data(x, contact_matrix = matrix(99, 4, 4)) # using assignment operators x$contact_matrix <- matrix(99, 4, 4) x
Helper functions to create and work with S3 class
<daedalus_infection>
objects for use with daedalus()
.
These objects store infection parameters for reuse and have methods for easy
parameter access and editing, as well as processing raw infection
characteristics for the DAEDALUS model.
daedalus_infection(name, ...) is_daedalus_infection(x) ## S3 method for class 'daedalus_infection' print(x, ...)
daedalus_infection(name, ...) is_daedalus_infection(x) ## S3 method for class 'daedalus_infection' print(x, ...)
name |
An epidemic name from among epidemic_names.
Selecting an epidemic automatically pulls in infection parameters
associated with the epidemic; these are stored as packaged data in
|
... |
Other parameters passed to |
x |
An object of the |
Epidemics for which data are available are given below (pathogen in
parentheses). The string indicates the name that must be passed to the name
argument.
"sars_cov_1"
: SARS 2004 (SARS-CoV-1),
"influenza_2009"
: influenza 2009 (influenza A H1N1),
"influenza_1957"
: influenza 1957 (influenza A H2N2),
"influenza_1918"
: influenza 1918 (influenza A H1N1),
"sars_cov_2_pre_alpha"
: Covid-19 wild type (SARS-Cov-2 wild type),
"sars_cov_2_omicron"
: Covid-19 Omicron (SARS-CoV-2 omicron),
"sars_cov_2_pre_delta"
: (SARS-CoV-2 delta).
All infections have the following parameters, which take default values
stored in the package under infection_data. Users can pass
custom values for these parameters as arguments via ...
.
r0
: A single numeric value for the basic reproduction value of the
infection .
sigma
: A single numeric value > 0.0 for the rate of transition from the
exposed compartment to one of two infectious compartments.
p_sigma
: A single numeric value in the range for the
proportion of infectious individuals who are also symptomatic. Asymptomatic
individuals can have a different contribution to the force of infection from
symptomatic individuals.
epsilon
: A single numeric value for the relative contribution of
asymptomatic infectious individuals to the force of infection (compared to
symptomatic individuals).
gamma_Is
: A single numeric value for the recovery rate of infectious
individuals who are not hospitalised.
gamma_Ia
: A single numeric value for the recovery rate from asymptomatic
infection.
gamma_H
: A numeric vector of length N_AGE_GROUPS
(4) for the
age-specific recovery rate for individuals who are hospitalised.
eta
: A numeric vector of length N_AGE_GROUPS
(4) for the age-specific
hospitalisation rate for individuals who are infectious and symptomatic.
omega
: A numeric vector of length N_AGE_GROUPS
(4) for the age-specific
mortality rate for individuals who are hospitalised.
rho
: A single numeric value for the rate at which infection-derived
immunity wanes, returning individuals in the 'recovered' compartment to the
'susceptible' compartment.
daedalus_infection()
returns an object of the S3 class
<daedalus_infection>
.
is_daedalus_infection()
returns a logical for whether an object is a
<daedalus_infection>
.
print.daedalus_infection()
invisibly returns the <daedalus_infection>
object x
. Called for printing side-effects.
# make a <daedalus_infection> object with default parameter values daedalus_infection("sars_cov_1") # modify infection parameters R0 and immunity waning rate daedalus_infection("influenza_1918", r0 = 2.5, rho = 0.01)
# make a <daedalus_infection> object with default parameter values daedalus_infection("sars_cov_1") # modify infection parameters R0 and immunity waning rate daedalus_infection("influenza_1918", r0 = 2.5, rho = 0.01)
Coefficients of openness of economic sectors under different pandemic response strategies. There are four strategies (including no response), with two levels of implementation ("heavy" and "light").
closure_data
closure_data
closure_data
A list with 4 elements, each corresponding to a pandemic response strategy, and each with 2 elements ("heavy" or "light") giving the coefficients of sector openness under different levels of implementation.
All economic sectors are fully open and there is no pandemic response.
Openness coefficients for an elimination strategy.
Openness coefficients for a strategy of mostly economic closures.
Openness coefficients for a strategy of mostly school closures.
Multiple sources; to be updated shortly. See processing details in 'data-raw/closure_data.R
Country-wise data on demography, social contacts, workforce
participation in economic sectors, and gross value added (GVA) per economic
sector.
Demography and social contacts are presented in four bins: [0, 4]
,
[5, 19]
, [20, 64]
, and [65, ]
(combining all individuals aged 65 and higher).
Workforce participation is presented as counts which are assumed to be a
subset of the [20, 64]
age-bin.
GVA data is presented in terms of million dollars per day.
Note that some zero values in worker participation data may reflect missing data for a particular sector.
country_data
country_data
country_data
A list with 197 elements, each corresponding to a recognised country or territory.
A four value named vector for the number of individuals in each demographic group.
A 16-element square matrix giving the mean number of social contacts between individuals of the four age groups.
A 45-element vector giving the number of individuals in each economic sector included in the model.
A 45-element vector giving the daily gross value added of each economic sector in the model, in million dollars.
doi:10.1126/science.abc0035 and OECD; see processing details in 'data-raw/country_data.R
Names for countries and territories included with the package.
country_names
country_names
country_names
A character vector of recognised country or territory names.
Run the DAEDALUS model from R. This is a work in progress.
daedalus( country, infection, response_strategy = c("none", "elimination", "economic_closures", "school_closures"), implementation_level = c("light", "heavy"), response_time = 30, response_threshold = 1000, initial_state_manual = list(), time_end = 300, ... )
daedalus( country, infection, response_strategy = c("none", "elimination", "economic_closures", "school_closures"), implementation_level = c("light", "heavy"), response_time = 30, response_threshold = 1000, initial_state_manual = list(), time_end = 300, ... )
country |
A country or territory object of class |
infection |
An infection parameter object of the class |
response_strategy |
A string for the name of response strategy followed;
defaults to "none". The response strategy determines the country-specific
response threshold following which the response is activated. See
While the response strategy is active, economic contacts are scaled using the
package data object |
implementation_level |
A string for the level at which the strategy is implemented; defaults to "light". |
response_time |
A single numeric value for the time in days at which the selected response is activated. This is ignored if the response has already been activated by the hospitalisation threshold being reached. Defaults to 30 days. |
response_threshold |
A single numeric value for the total number of
hospitalisations that causes an epidemic response
(specified by |
initial_state_manual |
An optional named list with the names
|
time_end |
An integer-like value for the number of timesteps at which to return data. This is treated as the number of days with data returned for each day. Defaults to 300 days. |
... |
Other arguments to be passed to the ODE solver; these are passed
to |
Users can pass the following initial state parameters to
initial_state_manual
:
p_infectious
: A single numeric value in the range giving
the proportion of individuals in each age group and economic sector that are
to be initialised as infectious. Defaults to
1e-6
, or one in every one
million as infectious.
p_asymptomatic
: A single numeric value in the range for
the proportion of initially infectious individuals who are considered to be
asymptomatic. Defaults to 0.0.
A <deSolve>
object.
# country and infection specified by strings using default characteristics output <- daedalus( "Canada", "influenza_1918" ) # country passed as <daedalus_country> with some characteristics modified country_x <- daedalus_country( "Canada", parameters = list(contact_matrix = matrix(5, 4, 4)) # uniform contacts ) output <- daedalus(country_x, "influenza_1918") # with some infection parameters over-ridden by the user output <- daedalus( "United Kingdom", daedalus_infection("influenza_1918", r0 = 1.3) ) # with default initial conditions over-ridden by the user output <- daedalus( "United Kingdom", "influenza_1918", initial_state_manual = list(p_infectious = 1e-3) )
# country and infection specified by strings using default characteristics output <- daedalus( "Canada", "influenza_1918" ) # country passed as <daedalus_country> with some characteristics modified country_x <- daedalus_country( "Canada", parameters = list(contact_matrix = matrix(5, 4, 4)) # uniform contacts ) output <- daedalus(country_x, "influenza_1918") # with some infection parameters over-ridden by the user output <- daedalus( "United Kingdom", daedalus_infection("influenza_1918", r0 = 1.3) ) # with default initial conditions over-ridden by the user output <- daedalus( "United Kingdom", "influenza_1918", initial_state_manual = list(p_infectious = 1e-3) )
Data on the per-capita social contacts within and between each economic sector of the DAEDALUS model.
economic_contacts
economic_contacts
economic_contacts
A list with two elements:
A numeric vector with N_ECON_SECTORS
(45)
elements, giving the per-capita contacts between workers within the same
economic sector.
A square matrix with values set to
, and with its diagonal set to zero, for the number of contacts
between workers across economic sectors.
Adapted from doi:10.1016/j.epidem.2024.100778; see processing details in 'data-raw/economic_contacts.R
Infection parameters used in DAEDALUS to simulate epidemics of interest.
epidemic_names
provides the tags by which epidemics are known for users'
convenience.
infection_data infection_parameter_names epidemic_names
infection_data infection_parameter_names epidemic_names
infection_data
A list with 7 elements, each corresponding to an epidemic (see Details), and providing 10 infection parameters:
r0
: A single numeric value for the basic reproduction value of the
infection .
sigma
: A single numeric value > 0.0 for the rate of transition from the
exposed compartment to one of two infectious compartments.
p_sigma
: A single numeric value in the range for the
proportion of infectious individuals who are also symptomatic. Asymptomatic
individuals can have a different contribution to the force of infection from
symptomatic individuals.
epsilon
: A single numeric value for the relative contribution of
asymptomatic infectious individuals to the force of infection (compared to
symptomatic individuals).
gamma_Is
: A single numeric value for the recovery rate of infectious
individuals who are not hospitalised.
gamma_Ia
: A single numeric value for the recovery rate from asymptomatic
infection.
gamma_H
: A numeric vector of length 4 for the age-specific recovery rate
for individuals who are hospitalised.
eta
: A numeric vector of length N_AGE_GROUPS
(4) for the age-specific
hospitalisation rate for individuals who are infectious and symptomatic.
omega
: A numeric vector of length N_AGE_GROUPS
(4) for the age-specific
mortality rate for individuals who are hospitalised.
rho
: A single numeric value for the rate at which infection-derived
immunity wanes, returning individuals in the 'recovered' compartment to the
'susceptible' compartment.
infection_parameter_names
A character vector with 10 names for the infection parameters in
infection_data
. Mainly for internal use.
epidemic_names
A character vector with 7 elements.
Epidemics for which data are available are (pathogen in parentheses):
SARS 2004 (SARS-CoV-1)
Influenza 2009 (influenza A H1N1)
Influenza 1957 (influenza A H2N2)
Influenza 1918 (influenza A H1N1)
Covid-19 wild type (SARS-Cov-2 wild type)
Covid-19 Omicron (SARS-CoV-2 omicron)
Covid-19 Delta (SARS-CoV-2 delta).
See processing details in 'data-raw/infection_data.R
# check available epidemics epidemic_names
# check available epidemics epidemic_names
Get closure time limits and calculate duration
get_closure_info(mutables)
get_closure_info(mutables)
mutables |
An environment holding the mutable parameters.
See |
A three-element list of the start time, end time, and duration for which closures are active.
Generic and methods for S3 classes for safely getting class parameters.
## S3 method for class 'daedalus_country' get_data(x, to_get, ...) ## S3 method for class 'daedalus_infection' get_data(x, to_get, ...) ## S3 method for class 'daedalus_output' get_data(x, to_get = NULL, ...) get_data(x, ...)
## S3 method for class 'daedalus_country' get_data(x, to_get, ...) ## S3 method for class 'daedalus_infection' get_data(x, to_get, ...) ## S3 method for class 'daedalus_output' get_data(x, to_get = NULL, ...) get_data(x, ...)
x |
An S3 class object from the daedalus package of the
|
to_get |
A string giving the name of the element of |
... |
< |
Returns a member of x
, with the class preserved
(e.g. numeric vector for a country "demography"
).
For <daedalus_output>
objects, returns the model timeseries data when no
element is specified.
# simple example of getting data country_A <- daedalus_country("United Kingdom") get_data(country_A, "demography") get_data(country_A, "demography", "contact_matrix") disease_x <- daedalus_infection("sars_cov_1", r0 = 1.9) get_data(disease_x, "r0") # get model data output <- daedalus("Canada", "influenza_1918") head( get_data(output) )
# simple example of getting data country_A <- daedalus_country("United Kingdom") get_data(country_A, "demography") get_data(country_A, "demography", "contact_matrix") disease_x <- daedalus_infection("sars_cov_1", r0 = 1.9) get_data(disease_x, "r0") # get model data output <- daedalus("Canada", "influenza_1918") head( get_data(output) )
Generic and methods for S3 classes for safely setting class
parameters. Only parameters considered safe to change – mostly contact data
in the <country>
, but all parameters in <infection>
– can be changed in
this way.
## S3 method for class 'daedalus_country' set_data(x, ...) ## S3 method for class 'daedalus_infection' set_data(x, ...) set_data(x, ...)
## S3 method for class 'daedalus_country' set_data(x, ...) ## S3 method for class 'daedalus_infection' set_data(x, ...) set_data(x, ...)
x |
An S3 class object from the daedalus package of the
|
... |
< |
An S3 object of the same class as input x
.
# simple example of setting all contacts to 1 country_A <- daedalus_country("United Kingdom") country_A country_A <- set_data(country_A, contact_matrix = matrix(1, 4, 4)) country_A disease_x <- daedalus_infection("sars_cov_1") disease_x <- set_data(disease_x, r0 = 3.0) disease_x
# simple example of setting all contacts to 1 country_A <- daedalus_country("United Kingdom") country_A country_A <- set_data(country_A, contact_matrix = matrix(1, 4, 4)) country_A disease_x <- daedalus_infection("sars_cov_1") disease_x <- set_data(disease_x, r0 = 3.0) disease_x