This document contains a series of examples using the runDRAFT() function. The objective of these examples is to demonstrate the requied format of input incidence data and show how varying input parameters activates different models and forecasts.

Example 1

This example fits an SIR model to weekly 2017-2018 San Diego County laboratory-confirmed cases of influenza.

library(DRAFT)
# San Diego 2017-2018 data is included in the package as 
# 'incidence_data1'
head(incidence_data1)
#>         date cases
#> 1 2017-07-08    17
#> 2 2017-07-15    11
#> 3 2017-07-22    11
#> 4 2017-07-29    29
#> 5 2017-08-05    18
#> 6 2017-08-12    11

# we will fit data to an SIR model (no behavior terms).
# 1-SIR, 2-SEIR, 3-behavior SIR 
epi_model = 1
# the population is about 3 million
pop = 3e6
# Set disease generation time in days
Tg = 2.6
# latent period in days - needed only for SEIR model 
# (epi_model = 2)
sigma = NULL
# Parameters for behavior modification model only
dp = dq = ts = dL = NULL
# designate an output directory path.
write_dir = tempdir()

To run DRAFT, execute the following line in an R console. It will take a minute or two to execute the MCMC fitting procedure. The function will create a subdirectory of the current working directory and save the resulting .RData and .png files there. For more details see the runDRAFT help page ?runDRAFT.

results <- runDRAFT(inc_data=incidence_data1, out_dir=write_dir, epi_model=epi_model, pop=pop, Tg=Tg, dp=dp, dq=dq, ts=ts, dL=dL, verbose=T)
# view results in directory
paste0(write_dir, "/user_data_", Sys.Date(), "_Tg_", Tg, "/")
#> [1] "/var/folders/wf/6wl91mws1hs0r6zq5p8jsclm0000gn/T//RtmpXHxjDl/user_data_2019-08-02_Tg_2.6/"

     

The first png generated is simply user-provided data. In this case, that is weekly San Diego County influenza data for the 2017-2018 season. San Diego County 2017-2018 weekly influenza

     

The second png is a results plot. Here data is plotted in black, the model best fit (most likely) in green, and the model mean fit in blue. Additionally, a subset of MCMC profiles are plotted in red. The resulting red shading helps to visualize the probability density of the MCMC chain. In the histograms below we see the MCMC chain parameter distributions for basic reproduction number \(R_0\) and percent clinical \(p_C\). \(p_C\) is defined as the percent of infectious that visit a clinic, but in this case also scales the population to the effective population served by reporting clinics. For this reason, \(p_C\) values may be lower than expected.

Results plot from example 1

   

Example 2

We now do a fit to the data and then generate a forecast for the following weeks. The data is similar to example 1, but with 2013-2014 San Diego County laboratory-confirmed cases of influenza.

# San Diego 2013-2014 data is included in the package as 
# 'incidence_data2'
head(incidence_data2)
#>         date cases
#> 1 2013-07-20     0
#> 2 2013-07-27     1
#> 3 2013-08-03     0
#> 4 2013-08-10     3
#> 5 2013-08-17     1
#> 6 2013-08-24     0

# notice the additional dates at the end of the dataframe with 
# cases=NA.  DRAFT will use the non-NA points to fit a model 
# and then run the model forward to create a forecast for all 
# NA entries.
incidence_data2[28:41, ]
#>          date cases
#> 28 2014-01-25   609
#> 29 2014-02-01   468
#> 30 2014-02-08   297
#> 31 2014-02-15    NA
#> 32 2014-02-22    NA
#> 33 2014-03-01    NA
#> 34 2014-03-08    NA
#> 35 2014-03-15    NA
#> 36 2014-03-22    NA
#> 37 2014-03-29    NA
#> 38 2014-04-05    NA
#> 39 2014-04-12    NA
#> 40 2014-04-19    NA
#> 41 2014-04-26    NA

# we will fit data to an SIR model (no behavior terms).
# 1-SIR, 2-SEIR, 3-behavior SIR 
epi_model = 1
# the population is about 3 million
pop = 3e6
# Set disease generation time in days
Tg = 2.6
# latent period in days - needed only for SEIR model, 
# epi_model = 2
sigma = NULL
# Parameters for behavior modification model only
dp = dq = ts = dL = NULL
# designate an output directory
write_dir = tempdir()

To run DRAFT, execute the following line in an R console. It will take a minute or two to execute the MCMC fitting procedure. The function will create a subdirectory of the current working directory and save the resulting .RData and .png files there. For more details see the runDRAFT help page ?runDRAFT.

results <- runDRAFT(inc_data=incidence_data2, out_dir=write_dir, epi_model=epi_model, pop=pop, Tg=Tg, dp=dp, dq=dq, ts=ts, dL=dL)
# view results in subdirectory
paste0(write_dir, "/user_data_", Sys.Date(), "_Tg_", Tg, "/")
#> [1] "/var/folders/wf/6wl91mws1hs0r6zq5p8jsclm0000gn/T//RtmpXHxjDl/user_data_2019-08-02_Tg_2.6/"

     

San Diego County 2013-2014 weekly influenza

     

In this example, we have a forecast in addition to model fit. Purple shading denotes future/forecast weeks and includes the mean and best profile forecasts.

Results plot from example 2

   

Example 3

This example fits an SIR model with behavior modification to 2014 Ebola data from Liberia.

# Liberia 2014 data is included in the DRAFT package 
#as 'incidence_data3'. 
head(incidence_data3)
#>         date cases
#> 1 2014-03-16     1
#> 2 2014-03-23     1
#> 3 2014-03-30     2
#> 4 2014-04-06     0
#> 5 2014-04-13     0
#> 6 2014-04-20     0

# No weeks are specified for forecasting
tail(incidence_data3)
#>          date cases
#> 49 2015-02-15     1
#> 50 2015-02-22     0
#> 51 2015-03-01     1
#> 52 2015-03-08     0
#> 53 2015-03-15     1
#> 54 2015-03-22     0

# we will fit data to an SIR model with behavior terms.
# 1-SIR, 2-SEIR, 3-behavior SIR 
epi_model = 3
# the population is about 4 million
pop = 4035777
# Set disease generation time in days
Tg = 12
# latent period in days - needed only for SEIR model
sigma = NULL
# Setting the contact rate modifications for Susceptible 
# and Infected to NULL will cause these parameters to be 
# fit.
dp = dq = NULL
# Behavior modifications are known to have commenced at 
# the end of July 2014.
ts = as.Date("2014-07-30")
# It took approximately 20 days for the changes to fully 
# take hold.
dL = 20
# designate an output directory
write_dir = tempdir()

To run DRAFT, execute the following line in an R console. It will take a minute or two to execute the MCMC fitting procedure. The function will create a subdirectory of the current working directory and save the resulting .RData and .png files there. For more details see the runDRAFT help page ?runDRAFT.

results <- runDRAFT(inc_data=incidence_data3, out_dir=write_dir, epi_model=epi_model, pop=pop, Tg=Tg, dp=dp, dq=dq, ts=ts, dL=dL)
# view results in subdirectory
paste0(write_dir, "/user_data_", Sys.Date(), "_Tg_", Tg, "/")
#> [1] "/var/folders/wf/6wl91mws1hs0r6zq5p8jsclm0000gn/T//RtmpXHxjDl/user_data_2019-08-02_Tg_12/"

     

Liberia 2014 ebola data

     

In this example we specified when behavior changes were initiated and how long they took to take full effect. Then the model fit the effectiveness of the behavior changes. This plot shows the data (black) and resulting fit (blue, green, magenta) as well as fractional contact rates for Infectious (yellow/orange) and Suseptibles (red). In the histograms below we see the MCMC chain parameter distributions for basic reproduction number \(R_0\), Susceptible fractional contact rate \(p\), and Infectious fractional contact rate \(q\).