This vignette shows how to model time-limited economic closures,
including sequential closures, using the
<daedalus_npi>
class.
<daedalus_npi>
objects are created using
daedalus_npi()
, and the class documentation explains more
about the allowed parameters.
Creating an NPI class object
An economic closure or NPI class object is created by passing
arguments to daedalus_npi()
. The daedalus model
currently only supports economic closures as part of NPIs, so these
terms are used interchangeably.
The minimum number of arguments required are name
,
country
, and infection
. The openness
coefficient vector, start and end time, and maximum duration are
optional.
The different use cases for each argument are explained below.
# not run
daedalus_npi(
name, country, infection,
openness,
start_time, end_time,
max_duration
)
Common rules for NPI triggers
Note that the following rules apply to all NPIs:
-
NPIs are broadly independent of each other, and trigger when their condition is met.
- Internally, all events in NPIs (in
daedalus::events::response
) check for whether they would be redundant, i.e., whether they would actually make a change to the NPI flag. So events that would switch the flag toon
do not occur if they flag is alreadyon
(the same applies tooff
). This allows accurate calculation of the duration for which an NPI has been active.
- Internally, all events in NPIs (in
The
country
argument controls the hospital capacity, the breaching of which triggers the NPI. This trigger overrides the start time trigger, so a NPI may trigger earlier than expected.The
infection
argument allows the NPI to end when the epidemic stops growing. This trigger overrides the end time trigger, so an NPI may end sooner than expected.-
All NPIs end after a maximum default duration of 365 days. This can be changed using the
max_duration
argument. This argument overrides theend_time
argument: if the NPIend_time
is specified as more thanmax_duration
days after thestart_time
, the response will end atstart_time + max_duration
, not atend_time
.- It is possible for responses started by any trigger to end on
max_duration
, and then to end onend_time
if it has been relaunched at a time-point in between. We advise users to await further developments in which state-dependent and time-dependent NPIs are separated.
- It is possible for responses started by any trigger to end on
Public-concern social distancing, when set to be NPI-linked, follows the rules for NPI launching and ending laid out above.
When a response is activated upon hitting its start time, the same response will not be logged as activating due to the hospital capacity trigger, even if that condition is met, as long as the response is active (that is, model time end time, or epidemic is still growing).
When a response ends due to time conditions being met, it may launch again if the hospital capacity condition is met. Future versions of daedalus may allow this to be prevented.
Time-limiting a pre-canned response
A time-limited economic closure or NPI is created by passing values
to the start_time
and end_time
arguments of
daedalus_npi()
.
For instance, to specify school closures for the U.K. that are active between days 30 and 90 after a pandemic use this code.
npi <- daedalus_npi(
"school_closures", "GBR", "sars_cov_1",
start_time = 30, end_time = 90
)
# see NPI information
npi
#> <daedalus_npi/daedalus_response>
#> NPI strategy: school_closures
#> • Start time (days): 30
#> • End time (days): 90
#> • Openness (mean prop.): 0.93
#> • Maximum duration (days): 365
# run a scenario with the npi
daedalus(
"GBR", "sars_cov_1", npi,
time_end = 100
)
#> <daedalus_output>
#> • Country: United Kingdom
#> • Epidemic: sars_cov_1
#> • Response: school_closures
Bespoke time-limited response
Creating a time-limited NPI using daedalus_npi()
requires:
Passing
NA
as thename
rather than one of the pre-canned NPI strategies found in [daedalus.data::closure_strategy_data], andPassing a vector of the same length as the number of economic sectors (currently 45) to the
openness
argument.
A country and infection are still required as before.
All other rules and requirements are the same as for a pre-canned response; the pre-canned element is the openness coefficients.
Passing a bespoke NPI to [daedalus()] leads to the resulting
<daedalus_output>
object identifying the
response_strategy
as "custom"
.
openness <- rep(0.3, 45)
npi <- daedalus_npi(
NA, "GBR", "sars_cov_1",
openness,
30, 90
)
# see NPI information
npi
#> <daedalus_npi/daedalus_response>
#> NPI strategy: custom
#> • Start time (days): 30
#> • End time (days): 90
#> • Openness (mean prop.): 0.3
#> • Maximum duration (days): 365
# run a scenario with the npi
daedalus(
"GBR", "sars_cov_1", npi,
time_end = 100
)
#> <daedalus_output>
#> • Country: United Kingdom
#> • Epidemic: sars_cov_1
#> • Response: custom
Repeated time-limited response
A time-limited response can be set to trigger and end at multiple time points. This is of most use in real-time pandemic response exercises where participants must make decisions about imposing and lifting restrictions.
Repeated time-limited NPIs are created by passing vectors to
start_time
and end_time
in
daedalus_npi()
. The
element of each vector gives the start and end time of a response.
Note that the launching and ending of a response follows the same rules laid out above.
This example shows a bespoke-coefficient response, but creating repeated time-limited responses using pre-canned coefficients works similarly.
openness <- rep(0.3, 45)
# start at day 30 and 60, three weeks each
npi <- daedalus_npi(
NA, "GBR", "sars_cov_1",
openness,
start_time = c(30, 60),
end_time = c(51, 81)
)
# see NPI information
npi
#> <daedalus_npi/daedalus_response>
#> NPI strategy: custom
#> • Start time (days): 30 and 60
#> • End time (days): 51 and 81
#> • Openness (mean prop.): 0.3
#> • Maximum duration (days): 365
# run a scenario with the npi
output <- daedalus(
"GBR", "sars_cov_1", npi,
time_end = 100
)
# examine event times
output$event_data
#> name time index sign
#> 1 npi_time_on_1 30.00000 2 1
#> 2 npi_time_off_1 51.00000 3 1
#> 3 npi_time_on_2 60.00000 4 1
#> 4 npi_time_off_2 81.00000 5 1
#> 5 npi_state_on 81.41332 6 1
#> 6 hosp_cap_exceeded_state_on 81.41332 9 1
In this example, the response slows the pandemic down such that hospital demand does not exceed capacity until day 81, when the response ends (‘flattening the curve’). When hospital capacity is exceeded, the response re-launches following its state dependency rules.