Package 'daedalus'

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

Help Index


Represent countries and territories for DAEDALUS

Description

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.

Usage

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, ...)

Arguments

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 ⁠<daedalus_country>⁠ class.

...

Other parameters passed to print().

Value

  • 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.

Examples

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

Represent countries and territories for DAEDALUS

Description

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.

Usage

daedalus_infection(name, ...)

is_daedalus_infection(x)

## S3 method for class 'daedalus_infection'
print(x, ...)

Arguments

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 daedalus::infection_data. Default infection parameters for epidemics can be over-ridden by passing them as a named list to ....

...

Other parameters passed to print().

x

An object of the ⁠<daedalus_infection>⁠ class.

Details

Included epidemics

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).

Infection parameters

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 R0R_0.

  • 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 [0.0,1.0][0.0, 1.0] 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.

Value

  • 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.

Examples

# 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)

Pandemic response strategy data for DAEDALUS

Description

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").

Usage

closure_data

Format

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.

none

All economic sectors are fully open and there is no pandemic response.

elimination

Openness coefficients for an elimination strategy.

economic_closures

Openness coefficients for a strategy of mostly economic closures.

school_closures

Openness coefficients for a strategy of mostly school closures.

Source

Multiple sources; to be updated shortly. See processing details in 'data-raw/closure_data.R


Country demographic data for DAEDALUS

Description

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.

Usage

country_data

Format

country_data

A list with 197 elements, each corresponding to a recognised country or territory.

demography

A four value named vector for the number of individuals in each demographic group.

contact_matrix

A 16-element square matrix giving the mean number of social contacts between individuals of the four age groups.

workers

A 45-element vector giving the number of individuals in each economic sector included in the model.

gva

A 45-element vector giving the daily gross value added of each economic sector in the model, in million dollars.

Source

doi:10.1126/science.abc0035 and OECD; see processing details in 'data-raw/country_data.R


Country names for DAEDALUS

Description

Names for countries and territories included with the package.

Usage

country_names

Format

country_names

A character vector of recognised country or territory names.


DAEDALUS model for health, social and economic costs of a pandemic

Description

Run the DAEDALUS model from R. This is a work in progress.

Usage

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,
  ...
)

Arguments

country

A country or territory object of class ⁠<daedalus_country>⁠, or a country or territory name from those included in the package; see country_names. Country-specific data such as the community and workplace contacts, the demography, and the distribution of the workforce into economic sectors is automatically accessed from package data for the relevant country name if it is passed as a string. To override package defaults for country characteristics, pass a ⁠<daedalus_country>⁠ object instead. See daedalus_country() for more.

infection

An infection parameter object of the class ⁠<infection>⁠, or an epidemic name for which data are provided in the package; see epidemic_names for parameters from a historical epidemic or epidemic wave. Passing the name as a string automatically accesses the default parameters of an infection. Create an pass a ⁠<daedalus_infection>⁠ to tweak infection parameters.

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 response_threshold.

While the response strategy is active, economic contacts are scaled using the package data object daedalus::closure_data.

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 response_strategy) to be triggered, if it has not already been triggered via response_time. Currently defaults to 1000, which overrides the default response- and country-specific threshold values held in country_data.

initial_state_manual

An optional named list with the names p_infectious and p_asymptomatic for the proportion of infectious and symptomatic individuals in each age group and economic sector. Defaults to 1e-6 and 0.0 respectively.

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 deSolve::ode().

Details

Initial state

Users can pass the following initial state parameters to initial_state_manual:

  • p_infectious: A single numeric value in the range [0.0,1.0][0.0, 1.0] 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 [0.0,1.0][0.0, 1.0] for the proportion of initially infectious individuals who are considered to be asymptomatic. Defaults to 0.0.

Value

A ⁠<deSolve>⁠ object.

Examples

# 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)
)

Economic sector contacts data for DAEDALUS

Description

Data on the per-capita social contacts within and between each economic sector of the DAEDALUS model.

Usage

economic_contacts

Format

economic_contacts

A list with two elements:

contacts_workplace

A numeric vector with N_ECON_SECTORS (45) elements, giving the per-capita contacts between workers within the same economic sector.

contacts_between_sectors

A square matrix with values set to 10610^{-6}, and with its diagonal set to zero, for the number of contacts between workers across economic sectors.

Source

Adapted from doi:10.1016/j.epidem.2024.100778; see processing details in 'data-raw/economic_contacts.R


Infection characteristics for model epidemics

Description

Infection parameters used in DAEDALUS to simulate epidemics of interest.

epidemic_names provides the tags by which epidemics are known for users' convenience.

Usage

infection_data

infection_parameter_names

epidemic_names

Format

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 R0R_0.

  • 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 (0.0,1.0)(0.0, 1.0) 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.

Details

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).

Source

See processing details in 'data-raw/infection_data.R

Examples

# check available epidemics
epidemic_names

Get closure time limits and calculate duration

Description

Get closure time limits and calculate duration

Usage

get_closure_info(mutables)

Arguments

mutables

An environment holding the mutable parameters. See prepare_mutable_parameters() for a template.

Value

A three-element list of the start time, end time, and duration for which closures are active.


Get parameters from DAEDALUS classes

Description

Generic and methods for S3 classes for safely getting class parameters.

Usage

## 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, ...)

Arguments

x

An S3 class object from the daedalus package of the ⁠<daedalus_country>⁠ or ⁠<infection>⁠ class.

to_get

A string giving the name of the element of x to return.

...

<dynamic-dots> Other arguments to class methods. Class methods do not currently support any other arguments.

Value

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.

Examples

# 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)
)

Set parameters in DAEDALUS classes

Description

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.

Usage

## S3 method for class 'daedalus_country'
set_data(x, ...)

## S3 method for class 'daedalus_infection'
set_data(x, ...)

set_data(x, ...)

Arguments

x

An S3 class object from the daedalus package of the ⁠<daedalus_country>⁠ or ⁠<infection>⁠ class.

...

<dynamic-dots> Named optional arguments for parameters to be changed, with their new values. The only values allowed for ⁠<daedalus_country>⁠ objects are "contact_matrix", "contacts_workplace", and "contacts_consumer_worker".

Value

An S3 object of the same class as input x.

Examples

# 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