Description Usage Arguments Details Value Examples
View source: R/fit_user_data_fxns.R
runDRAFT
accepts a user provided incidence dataframe and uses that along with the user provided population and generation time, Tg, (and if relevant the latent period sigma) to fit the incidence data. Additionally, when specified by the user, runDRAFT
will also generate a forecast for the incidence.
Data cadence is arbitrary but at most can be monthly.
We support S-I-R and S-E-I-R models for a single population with a fixed (non-time-dependent) force of infection.
1 2 3 |
inc_data |
Dataframe containing incidence data. Must contain 'date' and 'cases' columns. The 'date' column must either be Date-class or convert to Date-class using as.Date(inc_data$date, format="%Y-%m-%d"). |
out_dir |
Character string containing file path for output images and data files. If not specified, DRAFT will not generate output images or files. |
pop |
Integer population of the region for which incidence is provided |
epi_model |
- integer 1 (SIR), 2 (SEIR), 3 (SIR with behavior terms). Default is 1-SIR. |
Tg |
Numeric, generation time in days. Default is 3 days |
sigma |
inverse of of the latent period in days. Needed only for an SEIR model. Default NULL |
dp |
Proporiton of susceptible contact rate (0-1) following behavior modification. For example: If susceptibles reduce their contacts by 25%, set |
dq |
Proportion of infectious contact rate (0-1) following behavior modification. If infectious cases reduce their contacts by one half, set |
ts |
Date class. Start date of behavior modification. |
dL |
Number of days for behavior modification to completely take effect. |
nMCMC |
Number of steps to take in the Markov Chain Monte Carlo (MCMC) process. Number of steps needed for a good 'fit' will vary from case-to-case, but should never be less than 1e3. It is recommended to start at 1e4 and increase as needed. |
verbose |
This logical flag determines if code updates are printed to console/STDOUT during execution. It is recommended that verbose be set to TRUE for longer runs so the user may monitor progress. |
Data fitting is done using a Markov Chain Monte Carlo (MCMC) procedure. While generally discussed in the context of optimization, this procedure results in a mapping of the objective distribution. Thus the results of runDRAFT() come in the form of a distribution of parameters and the resulting distribution of incidence profiles.
A list with the input and entire output of the run. List entries:
mydata: A data structure containing the input data.
rtn: The best-fit profile.
profile: The full MCMC distribution of incidence profiles as a matrix.
tab: The full MCMC distribution of parameters as a matrix.
Additional output is written to a subdirectory 'user_data_*' within the current working directory. File list:
results-user_data-*.png: This image shows the fit relative to the data as well as critical-parameter distributions.
user_data-incidence.png: Incidence data plot.
mcmc-user_data-*.RData: A list that includes the resulting MCMC parameter distributions.
profiles-user_data-*.RData: A list that includes resulting distribution of incidence profiles.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # See examples vignette for a more in-depth walkthrough.
library(DRAFT)
vignette("DRAFT_examples")
# Run an SEIR model using the incidence file and assuming a
# population of 1 million people.
# The generation time and latent period are set to 2.6 days
# and 3 days respectively
head(incidence_data2)
temp_write = tempdir()
output <- runDRAFT(inc_data=incidence_data2, out_dir=temp_write,
pop = 1e6, epi_model = 2, Tg = 2.6, sigma = 3.)
# Run an SIR model using the incidence file and assuming a
# population of 10,000 people.
# The generation time is set to 3 days. (No need to define
# a latent period.)
head(incidence_data1)
output <- runDRAFT(inc_data=incidence_data2, out_dir=temp_write,
pop = 1e5, epi_model = 1, Tg = 3.)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.