diff --git a/articles/getting-started.html b/articles/getting-started.html index 95d1bf1e..6cdeb3d4 100644 --- a/articles/getting-started.html +++ b/articles/getting-started.html @@ -79,7 +79,7 @@

Derek

George Vega Yon

-

2023-09-01

+

2023-09-05

Source: vignettes/getting-started.Rmd
getting-started.Rmd
@@ -188,8 +188,8 @@

Setup and running the model#> Number of entities : 0 #> Days (duration) : 50 (of 50) #> Number of viruses : 1 -#> Last run elapsed t : 392.00ms -#> Last run speed : 6.37 million agents x day / second +#> Last run elapsed t : 524.00ms +#> Last run speed : 4.77 million agents x day / second #> Rewiring : off #> #> Global actions: diff --git a/articles/run-multiple.html b/articles/run-multiple.html index 1e97cc63..f893da8b 100644 --- a/articles/run-multiple.html +++ b/articles/run-multiple.html @@ -79,7 +79,7 @@

Derek

George Vega Yon

-

2023-09-01

+

2023-09-05

Source:
vignettes/run-multiple.Rmd
run-multiple.Rmd
@@ -130,8 +130,8 @@

Generating a Saver# Generating a saver saver <- make_saver("total_hist", "reproductive") # Running and printing -run_multiple(model_seirconn, ndays = 50, nsims = 50, saver = saver, nthread = 2) -#> Starting multiple runs (50) using 2 thread(s) +run_multiple(model_seirconn, ndays = 50, nsims = 50, saver = saver, nthread = 1) +#> Starting multiple runs (50) using 1 thread(s) #> _________________________________________________________________________ #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. @@ -152,12 +152,12 @@

Generating a Saver#> 6 1 1 1 Exposed 1 head(ans$reproductive) #> sim_num virus_id virus source source_exposure_date rt -#> 1 1 0 COVID-19 422 50 0 -#> 2 1 0 COVID-19 424 50 0 -#> 3 1 0 COVID-19 446 50 0 -#> 4 1 0 COVID-19 504 50 0 -#> 5 1 0 COVID-19 533 50 0 -#> 6 1 0 COVID-19 585 50 0 +#> 1 1 0 COVID-19 654 50 0 +#> 2 1 0 COVID-19 1009 50 0 +#> 3 1 0 COVID-19 4332 44 1 +#> 4 1 0 COVID-19 5268 44 0 +#> 5 1 0 COVID-19 4382 47 6 +#> 6 1 0 COVID-19 7376 44 0

Plotting diff --git a/articles/run-multiple_files/figure-html/plotting seirconn epicurves-1.png b/articles/run-multiple_files/figure-html/plotting seirconn epicurves-1.png index b6961ec4..7a12f566 100644 Binary files a/articles/run-multiple_files/figure-html/plotting seirconn epicurves-1.png and b/articles/run-multiple_files/figure-html/plotting seirconn epicurves-1.png differ diff --git a/articles/run-multiple_files/figure-html/reproductive number plot-1.png b/articles/run-multiple_files/figure-html/reproductive number plot-1.png index 7239b4d2..4cc9feec 100644 Binary files a/articles/run-multiple_files/figure-html/reproductive number plot-1.png and b/articles/run-multiple_files/figure-html/reproductive number plot-1.png differ diff --git a/pkgdown.yml b/pkgdown.yml index 57ed3f1d..f8fb4227 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -5,5 +5,5 @@ articles: getting-started: getting-started.html implementation: implementation.html run-multiple: run-multiple.html -last_built: 2023-09-01T13:14Z +last_built: 2023-09-05T21:18Z diff --git a/reference/run_multiple.html b/reference/run_multiple.html index d6a08b41..75a36cfc 100644 --- a/reference/run_multiple.html +++ b/reference/run_multiple.html @@ -152,8 +152,8 @@

Examplessaver <- make_saver("total_hist", "reproductive") # Running and printing -run_multiple(model_sir, ndays = 100, nsims = 50, saver = saver, nthread = 2) -#> Starting multiple runs (50) using 2 thread(s) +run_multiple(model_sir, ndays = 100, nsims = 50, saver = saver, nthread = 1) +#> Starting multiple runs (50) using 1 thread(s) #> _________________________________________________________________________ #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. diff --git a/search.json b/search.json index b164a1d1..15c7ca8f 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":[]},{"path":"/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement derekmeyer37@gmail.com. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired Mozilla’s code conduct enforcement ladder. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 George G. Vega Yon Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":[]},{"path":"/articles/getting-started.html","id":"setup-and-running-the-model","dir":"Articles","previous_headings":"Example 1: Simulating an SIR model","what":"Setup and running the model","title":"Getting started with epiworldR","text":"example implements social network parameters listed within ModelSIRCONN function. virus name specified (COVID-19), 50000 agents initialized, virus prevalence 0.001 declared, agent contact two others (contact_rate), transmission rate given agent 0.3, recovery rate set \\(\\frac{1}{3}\\). create model epiworldR, simply use ModelSIRCONN function. , example take basic features epiworldR. Printing model shows us information. Nevertheless, can extract detailed information using summary method. First, name model, population size, number entities (think public spaces agents can make social contact one another), duration days, number viruses, amount time last replicate took run (last run elapsed t), rewiring status (). model also includes list global actions (interventions) called model run. Next, see list viruses used model. case, COVID-19 virus used. Note epiworldR can include one virus model. Tool(s) lists agents’ tools fight virus. Examples may include masking, vaccines, social distancing, etc. model, tools specified. Lastly, model parameters listed. execute model, use run function SIR model object, number simulation days, optional seed reproducibility. Next, print results simulated model using model_sir. two additional sections included summary running model. First, see distribution population time 50. section describes flow agents state (SIR) 50 days. example, ’ll see number agents susceptible state decreased 49,995 3,364, number agents infected state increased 5 0, recovered agents increased 46,636 50 days. counts states change based model parameters simulation run-time. transmission probabilities section outputs 3x3 matrix describes probability moving one state another. example, susceptible row, agent 0.95 probability remaining susceptible state 0.05 probability moving susceptible state infected state. Notice chance skipping states. words, agent can’t jump susceptible state recovered state; agent must pass infected state progress recovered state. logic applies moving backward; agent become susceptible infection.","code":"library(epiworldR) model_sir <- ModelSIRCONN( name = \"COVID-19\", n = 50000, prevalence = 0.0001, contact_rate = 2, transmission_rate = 0.5, recovery_rate = 1/3 ) # Printing the model model_sir #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 50000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. The model hasn't been run yet. summary(model_sir) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Removed (SIR) (connected) #> Population size : 50000 #> Agents' data : (none) #> Number of entities : 0 #> Days (duration) : 0 (of 0) #> Number of viruses : 1 #> Last run elapsed t : - #> Rewiring : off #> #> Global actions: #> (none) #> #> Virus(es): #> - COVID-19 (baseline prevalence: 0.01%) #> #> Tool(s): #> (none) #> #> Model parameters: #> - Contact rate : 2.0000 #> - Recovery rate : 0.3333 #> - Transmission rate : 0.5000 run(model_sir, ndays = 50, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. summary(model_sir) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Removed (SIR) (connected) #> Population size : 50000 #> Agents' data : (none) #> Number of entities : 0 #> Days (duration) : 50 (of 50) #> Number of viruses : 1 #> Last run elapsed t : 392.00ms #> Last run speed : 6.37 million agents x day / second #> Rewiring : off #> #> Global actions: #> (none) #> #> Virus(es): #> - COVID-19 (baseline prevalence: 0.01%) #> #> Tool(s): #> (none) #> #> Model parameters: #> - Contact rate : 2.0000 #> - Recovery rate : 0.3333 #> - Transmission rate : 0.5000 #> #> Distribution of the population at time 50: #> - (0) Susceptible : 49995 -> 3364 #> - (1) Infected : 5 -> 0 #> - (2) Recovered : 0 -> 46636 #> #> Transition Probabilities: #> - Susceptible 0.95 0.05 0.00 #> - Infected 0.00 0.64 0.36 #> - Recovered 0.00 0.00 1.00"},{"path":[]},{"path":"/articles/getting-started.html","id":"extracting-information","dir":"Articles","previous_headings":"Example 1: Simulating an SIR model","what":"Extracting information","title":"Getting started with epiworldR","text":"running epiworldR model, list functions can called using epiworld model object. demonstrate, start basic plot get_hist_total functions. evident plot, SIR model constructed epiworldR displays changes susceptible, infected, recovered case counts time (days). Notice certain amount time, curves flatten. , table representation plot printed, complete state within SIR model, date, agent counts. essential statistic epidemiological models reproductive number: epiworldR method plot reproductive number automatically. function takes average values table date repeats data accounted . Another typical piece information daily incidence. number new cases per day. epiworldR, can get incidence looking daily transitions states. Although function get_hist_transition_matrix provides desired data, function plot_incidence nice wrapper visualizing data:","code":"methods(class = \"epiworld_model\") #> [1] add_tool_n add_tool #> [3] add_virus_n add_virus #> [5] agents_from_edgelist agents_smallworld #> [7] get_hist_tool get_hist_total #> [9] get_hist_transition_matrix get_hist_virus #> [11] get_n_replicates get_n_tools #> [13] get_n_viruses get_name #> [15] get_ndays get_param #> [17] get_reproductive_number get_states #> [19] get_today_total get_transition_probability #> [21] get_transmissions print #> [23] queuing_off queuing_on #> [25] run_multiple run #> [27] set_name set_param #> [29] size summary #> [31] verbose_off verbose_on #> see '?methods' for accessing help and source code plot(model_sir) head(get_hist_total(model_sir)) #> date state counts #> 1 0 Susceptible 49995 #> 2 0 Infected 5 #> 3 0 Recovered 0 #> 4 1 Susceptible 49991 #> 5 1 Infected 9 #> 6 1 Recovered 0 repnum <- get_reproductive_number(model_sir) head(repnum) #> virus_id virus source source_exposure_date rt #> 1 0 COVID-19 23811 44 0 #> 2 0 COVID-19 38232 42 1 #> 3 0 COVID-19 19769 41 1 #> 4 0 COVID-19 28486 40 0 #> 5 0 COVID-19 6422 39 0 #> 6 0 COVID-19 7907 39 0 x <- plot(repnum, type = \"b\") subset(x, date == 10) # Reproductive number on day 10 #> virus_id virus date avg n sd lb ub #> 11 0 COVID-19 10 2.450464 646 2.263946 0 7.875 plot_incidence(model_sir)"},{"path":"/articles/getting-started.html","id":"adding-more-virusesviruses","dir":"Articles","previous_headings":"Example 1: Simulating an SIR model","what":"Adding more viruses/viruses","title":"Getting started with epiworldR","text":"epiworldR supports multi-virus models. code gives instructions implement . Using virus function, give name new virus/virus corresponding probability infecting given agent. example, prob_infecting set 1.0, making highly contagious. officially add new virus model, use add_virus function calling original epiworldR model object, new virus, new virus’ prevalence (set 0.01 example). running updated model new virus included 50 days, output describes simulation. confirm flu included, notice presence “Flu” Virus(es) section output. output interpretable specified previous sections. Plotting previous model (including flu) yields following. Notice presence two reproductive numbers plotted time. Variant 0 refers COVID-19, virus 1 refers flu.","code":"# Building the virus flu <- virus(name = \"Flu\", prob_infecting = .3) # Adding the virus to the model add_virus(model_sir, flu, .0001) run(model_sir, ndays = 50, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. model_sir #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 50000 agents, 2 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 3264 Susceptible, 4 Infected, and 46732 Recovered. repnum2 <- get_reproductive_number(model_sir) op <- par(mfrow = c(2,1)) plot(model_sir) plot(repnum2, type=\"b\") par(op)"},{"path":"/articles/getting-started.html","id":"tools","dir":"Articles","previous_headings":"Example 1: Simulating an SIR model","what":"Tools","title":"Getting started with epiworldR","text":"Now, implementation tools combat viruses viruses model demonstrated. First, sake simplicity, remove flu virus SIR model object (keep mind index flu virus model object 1). Next, provide parameters new tool using tool function. parameters include name tool, reduction probabilities SIR model parameters, increased probability recovery option. order add tool SIR model, use add_tool function SIR model object, new tool, prevalence tool. example, assume 85% population received vaccination.","code":"# Removing the flu virus from the model rm_virus(model_sir, 1) vaccine <- tool( name = \"Vaccine\", susceptibility_reduction = .9, transmission_reduction = .5, recovery_enhancer = .5, death_reduction = .9 ) add_tool(model_sir, vaccine, 0.5) run(model_sir, ndays = 50, seed = 1231) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. repnum3 <- get_reproductive_number(model_sir) op <- par(mfrow = c(2,1)) plot_incidence(model_sir) plot(repnum3, type=\"b\") par(op)"},{"path":"/articles/implementation.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Implementation details of epiworldR","text":"following vignette provides detailed information implementation epiworldR. package wrapper C++ package epiworld, framework building agent-based models.1","code":""},{"path":"/articles/implementation.html","id":"general-flow-of-the-models","dir":"Articles","previous_headings":"","what":"General flow of the models","title":"Implementation details of epiworldR","text":"core function epiworldR run() function. function executes model saves results database part underlying C++ object. package implements discrete-time ABM, meaning model executed discrete steps (e.g., days). run() function executes following steps: model reset(), involves: () resetting agents, available, restoring population backup2, (b) resetting database, (c) distributing viruses tools, (d) setting initial state agents. steps fixing current_date = 0. model’s state recorded database, current_date incremented 1. resetting model, start iterative process repeating following steps: state agent updated. States updated according corresponding update_state function. Since model discrete-time, state changes stored promises, meaning agents’ states updated immediately. Instead, state updated end updates. done avoid updating state agent using updated state update state another agent. example, agent \\(\\) infects agent \\(j\\), agent \\(j\\) able infect agent \\(\\) step. update schedule laid , changes made effective, , instance, individuals became infected update start next step infected state. Global actions executed. also change agents’ states, just like previous step, changes stored promises made effective actions evaluated. model’s state recorded database, current_date incremented 1. model checks whether simulation stop. simulation stop, model stops. Otherwise, model goes back step . steps included epiworld epiworldR network rewiring mutation viruses. implemented future versions epiworldR.","code":""},{"path":[]},{"path":"/articles/implementation.html","id":"transmission-probability","dir":"Articles","previous_headings":"Computing probabilities","what":"Transmission probability","title":"Implementation details of epiworldR","text":"Generally, epiworldR assumes step simulation, susceptible agents can acquire disease one infected agent. probability transmission \\(\\) \\(j\\) given following formula: \\[ P(\\j| \\mbox{one}) = \\frac{p_{ij} \\times \\prod_{k\\neq }\\left(1 - p_{kj}\\right)}{\\prod_k\\left(1 - p_{kj}\\right) + \\sum_k p_{kj} \\times \\prod_{l\\neq k}\\left(1 - p_{lj}\\right)} \\] adjusted probabilities \\(p_{ij}\\) computed function \\(\\), \\(j\\), virus. following section describes probabilities computed.","code":""},{"path":"/articles/implementation.html","id":"adjusted-probabilities","dir":"Articles","previous_headings":"Computing probabilities","what":"Adjusted probabilities","title":"Implementation details of epiworldR","text":"Viruses tools provide way adjust agents move states. Viruses epiworldR contain various baseline probabilities used across models, including transmission, recovery, death. hand, tools alter probabilities reducing/increasing . Furthermore, tools alter agents’ susceptibility, infectiousness, recovery, death probabilities. Currently, tools alter probabilities constant factor, \\[ p_{ij} = p_{v} \\times \\left(1 - factor_{host}\\right) \\times \\left(1 - factor_{target}\\right) \\] \\(p_{v}\\) raw transmission probability virus \\(v\\), \\(factor_{t}\\) increasing/reducing factors tools process. example, p_v 0.9, host wearing mask, \\(factor_{\\mbox{mask host}} = 0.3\\) target vaccinated, \\(factor_{\\mbox{vaccinated target}} = 0.5\\), adjusted probability \\(p_{ij}\\) \\(0.9 \\times (1 - 0.3) \\times (1 - 0.5) = 0.27\\). agents one tool, factors combined follows: \\[ factor_{agent} = 1 - \\prod_{t\\tools_{agent}}\\left(1 - factor_{t}\\right) \\] Therefore, example, vaccinated agent wearing mask factor \\(1 - (1 - 0.30) \\times (1 - 0.5) = 0.65\\). adjusted probabilities principle also applies recovery rates SIR SEIR models.","code":""},{"path":"/articles/implementation.html","id":"transmission-in-connected-modelsmodels","dir":"Articles","previous_headings":"Computing probabilities","what":"Transmission in connected models3","title":"Implementation details of epiworldR","text":"“connected” models provide version agents live fully connected network. means agent can infect agent, making version similar typical compartmental models. models, transmission probability depends contact rate. susceptible agent, transmission process simulated follows: number contacts \\(c\\) drawn binomial distribution parameters \\(n\\) \\(p\\), \\(n\\) number agents \\(p =\\)contact_rate\\(/ n\\). , \\(c\\) agents randomly selected population. Transmission can occur agents susceptible agent. probability transmission \\(c\\) agents calculated described previous section.","code":""},{"path":"/articles/run-multiple.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Run Multiple","text":"purpose “run_multiple” function run specified number simulations using model object. , function makes possible compare model results across several separate repeated simulations.","code":""},{"path":[]},{"path":"/articles/run-multiple.html","id":"setup-and-running-model","dir":"Articles","previous_headings":"Example: Simulating a SEIRCONN Model 50 Times","what":"Setup and Running Model","title":"Run Multiple","text":"use “run_multiple” function epiworld, create epimodel choice; case, example uses SEIRCONN model COVID-19, 100000 people, initial prevalence 0.0001 (0.01%), contact rate 2, probability transmission 0.5, total 7 incubation days, probability recovery \\(\\frac{1}{3}\\).","code":"library(epiworldR) model_seirconn <- ModelSEIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.0001, contact_rate = 2, transmission_rate = 0.5, incubation_days = 7, recovery_rate = 1/3 )"},{"path":"/articles/run-multiple.html","id":"generating-a-saver","dir":"Articles","previous_headings":"Example: Simulating a SEIRCONN Model 50 Times","what":"Generating a Saver","title":"Run Multiple","text":"Next, generate saver purpose extracting “total_hist” “reproductive” information model object. Now, use “run_multiple” function model object, number desired days run simulation, number simulations run, number threads parallel computing. Using “run_multiple_get_results” function, extract results model object simulated 50 times comparison across simulations.","code":"# Generating a saver saver <- make_saver(\"total_hist\", \"reproductive\") # Running and printing run_multiple(model_seirconn, ndays = 50, nsims = 50, saver = saver, nthread = 2) #> Starting multiple runs (50) using 2 thread(s) #> _________________________________________________________________________ #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Retrieving the results ans <- run_multiple_get_results(model_seirconn) head(ans$total_hist) #> sim_num date nviruses state counts #> 1 1 0 1 Susceptible 9999 #> 2 1 0 1 Exposed 1 #> 3 1 0 1 Infected 0 #> 4 1 0 1 Recovered 0 #> 5 1 1 1 Susceptible 9999 #> 6 1 1 1 Exposed 1 head(ans$reproductive) #> sim_num virus_id virus source source_exposure_date rt #> 1 1 0 COVID-19 422 50 0 #> 2 1 0 COVID-19 424 50 0 #> 3 1 0 COVID-19 446 50 0 #> 4 1 0 COVID-19 504 50 0 #> 5 1 0 COVID-19 533 50 0 #> 6 1 0 COVID-19 585 50 0"},{"path":"/articles/run-multiple.html","id":"plotting","dir":"Articles","previous_headings":"Example: Simulating a SEIRCONN Model 50 Times","what":"Plotting","title":"Run Multiple","text":"plot epicurves reproductive numbers time using boxplots, extract results model object using “run_multiple_get_results”. example, dates filtered less equal 20 observe epicurves first 20 days. Notice boxplot table represents observed values 50 simulations date. view plot reproductive number 50 days 50 simulations, store reproductive results new object using “run_multiple_get_results”, plot using “boxplot” function. Notice source exposure date displays boxplot representing distribution reproductive numbers across 50 simulations. expected, reproductive number average, decreases time.","code":"seirconn_50 <- run_multiple_get_results(model_seirconn)$total_hist seirconn_50 <- seirconn_50[seirconn_50$date <= 20,] plot(seirconn_50) seirconn_50_r <- run_multiple_get_results(model_seirconn)$reproductive plot(seirconn_50_r) # boxplot(rt ~ source_exposure_date, data = seirconn_50_r, # main = \"Reproductive Number\", # xlab = \"Source Exposure Date\", # ylab = \"rt\", # border = \"black\", # las = 2)"},{"path":"/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Derek Meyer. Author, maintainer. George Vega Yon. Author. Susan Holmes. Reviewer. JOSS reviewer Abinash Satapathy. Reviewer. JOSS reviewer Carinogurjao. Reviewer. Centers Disease Control Prevention. Funder. Award number 1U01CK000585; 75D30121F00003","code":""},{"path":"/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Meyer D, Vega Yon G (2023). epiworldR: Fast Agent-Based Epi Models. https://github.com/UofUEpiBio/epiworldR, https://uofuepibio.github.io/epiworldR/, https://uofuepibio.github.io/epiworldR-workshop/.","code":"@Manual{, title = {epiworldR: Fast Agent-Based Epi Models}, author = {Derek Meyer and George {Vega Yon}}, year = {2023}, note = {https://github.com/UofUEpiBio/epiworldR, https://uofuepibio.github.io/epiworldR/, https://uofuepibio.github.io/epiworldR-workshop/}, }"},{"path":"/index.html","id":"versions","dir":"","previous_headings":"","what":"Versions","title":"Fast Agent-Based Epi Models","text":"virtual INSNA Sunbelt 2023 session can found : https://github.com/UofUEpiBio/epiworldR-workshop/tree/sunbelt2023-virtual -person INSNA Sunbelt 2023 session can found : https://github.com/UofUEpiBio/epiworldR-workshop/tree/sunbetl2023-inperson","code":""},{"path":"/index.html","id":"epiworldr","dir":"","previous_headings":"","what":"Fast Agent-Based Epi Models","title":"Fast Agent-Based Epi Models","text":"R package wrapper C++ library epiworld. provides general framework modeling disease transmission using agent-based models. main features include: Fast simulation average 30 million agents/day per second. One model can include multiple diseases. Policies (tools) can multiple user-defined. Transmission can function agents’ features. ---box parallelization multiple simulations. package’s description: flexible framework Agent-Based Models (ABM), epiworldR package provides methods prototyping disease outbreaks transmission models using C++ backend, making fast. supports multiple epidemiological models, including Susceptible-Infected-Susceptible (SIS), Susceptible-Infected-Removed (SIR), Susceptible-Exposed-Infected-Removed (SEIR), others, involving arbitrary mitigation policies multiple-disease models. Users can specify infectiousness/susceptibility rates function agents’ features, providing great complexity model dynamics. Furthermore, epiworldR ideal simulation studies featuring large populations.","code":""},{"path":"/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Fast Agent-Based Epi Models","text":"can install development version epiworldR GitHub : CRAN","code":"devtools::install_github(\"UofUEpiBio/epiworldR\") install.packages(\"epiworldR\")"},{"path":"/index.html","id":"examples","dir":"","previous_headings":"","what":"Examples","title":"Fast Agent-Based Epi Models","text":"R package includes several popular epidemiological models including SIS, SIR, SEIR using either fully connected graph (similar compartmental model) user-defined network. examples:","code":""},{"path":"/index.html","id":"sir-model-using-a-random-graph","dir":"","previous_headings":"","what":"SIR model using a random graph","title":"Fast Agent-Based Epi Models","text":"Susceptible-Infected-Recovered model features population 100,000 agents simulated small-world network. agent connected ten agents. One percent population virus, 70% chance transmission. Infected individuals recover 0.3 rate: Visualizing outputs","code":"library(epiworldR) # Creating a SIR model sir <- ModelSIR( name = \"COVID-19\", prevalence = .01, transmission_rate = .7, recovery = .3 ) |> # Adding a Small world population agents_smallworld(n = 100000, k = 10, d = FALSE, p = .01) |> # Running the model for 50 days run(ndays = 50, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. sir #> ________________________________________________________________________________ #> Susceptible-Infected-Recovered (SIR) #> It features 100000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 822 Susceptible, 415 Infected, and 98763 Recovered. summary(sir) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Recovered (SIR) #> Population size : 100000 #> Agents' data : (none) #> Number of entities : 0 #> Days (duration) : 50 (of 50) #> Number of viruses : 1 #> Last run elapsed t : 193.00ms #> Last run speed : 25.77 million agents x day / second #> Rewiring : off #> #> Global actions: #> (none) #> #> Virus(es): #> - COVID-19 (baseline prevalence: 1.00%) #> #> Tool(s): #> (none) #> #> Model parameters: #> - Recovery rate : 0.3000 #> - Transmission rate : 0.7000 #> #> Distribution of the population at time 50: #> - (0) Susceptible : 99000 -> 822 #> - (1) Infected : 1000 -> 415 #> - (2) Recovered : 0 -> 98763 #> #> Transition Probabilities: #> - Susceptible 0.91 0.09 0.00 #> - Infected 0.00 0.70 0.30 #> - Recovered 0.00 0.00 1.00 plot(sir)"},{"path":"/index.html","id":"seir-model-with-a-fully-connected-graph","dir":"","previous_headings":"","what":"SEIR model with a fully connected graph","title":"Fast Agent-Based Epi Models","text":"SEIR model similar SIR model includes exposed state. , simulate population 10,000 agents 0.01 prevalence, 0.6 transmission rate, 0.5 recovery rate, 7 days-incubation period. population fully connected, meaning agents can transmit disease agent: Computing key statistics","code":"model_seirconn <- ModelSEIRCONN( name = \"COVID-19\", prevalence = 0.01, n = 10000, contact_rate = 4, incubation_days = 7, transmission_rate = 0.6, recovery_rate = 0.5 ) |> add_virus(virus(\"COVID-19\", 0.01, 0.6, 0.5, 7), .5) set.seed(132) run(model_seirconn, ndays = 100) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seirconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed (SEIR) (connected) #> It features 10000 agents, 2 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 608 Susceptible, 4 Exposed, 2 Infected, and 9386 Recovered. plot(model_seirconn) repnum <- get_reproductive_number(model_seirconn) head(plot(repnum)) #> virus_id virus date avg n sd lb ub #> 1 0 COVID-19 0 2.858974 78 2.592318 1 7.30 #> 2 0 COVID-19 2 1.964286 28 1.914509 0 5.65 #> 3 0 COVID-19 3 2.761905 21 2.321740 0 7.00 #> 4 0 COVID-19 4 2.000000 33 1.887459 0 6.40 #> 5 0 COVID-19 5 1.864865 37 2.225636 0 9.10 #> 6 0 COVID-19 6 2.104167 48 2.667692 0 10.65 plot_incidence(model_seirconn) head(plot_generation_time(model_seirconn)) #> date avg n sd ci_lower ci_upper virus virus_id #> 1 2 5.714286 21 4.681270 2 17.00 COVID-19 0 #> 2 3 7.444444 18 4.501271 2 15.45 COVID-19 0 #> 3 4 7.192308 26 5.578668 2 20.75 COVID-19 0 #> 4 5 7.111111 27 4.236593 2 15.70 COVID-19 0 #> 5 6 7.575000 40 7.249713 2 30.20 COVID-19 0 #> 6 7 6.303030 33 4.531038 2 18.00 COVID-19 0"},{"path":"/index.html","id":"sir-logit","dir":"","previous_headings":"","what":"SIR Logit","title":"Fast Agent-Based Epi Models","text":"model provides complex transmission recovery pattern based agents’ features. , can reflect co-morbidities change probability infection recovery. , simulate population including dataset two features: intercept binary variable Female. probability infection recovery functions intercept Female variables. following code simulates population 100,000 agents small-world network. agent connected eight agents. One percent population virus, 80% chance transmission. Infected individuals recover 0.3 rate:","code":"# Simulating a population of 100,000 agents set.seed(2223) n <- 100000 # Agents' features X <- cbind( Intercept = 1, Female = sample.int(2, n, replace = TRUE) - 1 ) coef_infect <- c(.1, -2, 2) coef_recover <- rnorm(2) # Creating the model model_logit <- ModelSIRLogit( \"covid2\", data = X, coefs_infect = coef_infect, coefs_recover = coef_recover, coef_infect_cols = 1L:ncol(X), coef_recover_cols = 1L:ncol(X), prob_infection = .8, recovery_rate = .3, prevalence = .01 ) # Adding a small-world population agents_smallworld(model_logit, n, 8, FALSE, .01) # Running the model run(model_logit, 50) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. plot(model_logit) # Females are supposed to be more likely to become infected rn <- get_reproductive_number(model_logit) (table( X[, \"Female\"], (1:n %in% rn$source) ) |> prop.table())[,2] #> 0 1 #> 0.12984 0.14201 # Looking into the agents get_agents(model_logit) #> Agents from the model \"Susceptible-Infected-Removed (SIR) (logit)\": #> Agent: 0, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 1, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 2, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 3, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 4, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 5, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 6, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 7, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 8, state: Susceptible (0), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 9, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> ... 99990 more agents ..."},{"path":"/index.html","id":"transmission-network","dir":"","previous_headings":"","what":"Transmission network","title":"Fast Agent-Based Epi Models","text":"example shows can draw transmission network simulation. following code simulates population 500 agents small-world network. agent connected ten agents. One percent population virus, 50% chance transmission. Infected individuals recover 0.5 rate:","code":"# Creating a SIR model sir <- ModelSIR( name = \"COVID-19\", prevalence = .01, transmission_rate = .5, recovery = .5 ) |> # Adding a Small world population agents_smallworld(n = 500, k = 10, d = FALSE, p = .01) |> # Running the model for 50 days run(ndays = 50, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. # Transmission network net <- get_transmissions(sir) # Plotting library(netplot) #> Loading required package: grid library(igraph) #> #> Attaching package: 'igraph' #> The following object is masked from 'package:netplot': #> #> ego #> The following objects are masked from 'package:stats': #> #> decompose, spectrum #> The following object is masked from 'package:base': #> #> union x <- graph_from_edgelist(as.matrix(net[,2:3]) + 1) nplot(x, edge.curvature = 0, edge.color = \"gray\", skip.vertex=TRUE)"},{"path":"/index.html","id":"multiple-simulations","dir":"","previous_headings":"","what":"Multiple simulations","title":"Fast Agent-Based Epi Models","text":"epiworldR supports running multiple simulations using run_multiple function. following code simulates 50 SIR models 1000 agents . agent connected ten agents. One percent population virus, 90% chance transmission. Infected individuals recover 0.1 rate. results saved data.frame: # Existing Alternatives Several alternatives epiworldR exist provide researchers range options, unique features strengths, enabling exploration analysis infectious disease dynamics agent-based modeling. manually curated table existing alternatives including ABM [@ABM], abmR [@abmR], cystiSim [@cystiSim], villager [@villager], RNetLogo [@RNetLogo].","code":"model_sir <- ModelSIRCONN( name = \"COVID-19\", prevalence = 0.01, n = 1000, contact_rate = 2, transmission_rate = 0.9, recovery_rate = 0.1 ) # Generating a saver saver <- make_saver(\"total_hist\", \"reproductive\") # Running and printing # Notice the use of nthread = 2 to run the simulations in parallel run_multiple(model_sir, ndays = 100, nsims = 50, saver = saver, nthread = 2) #> Starting multiple runs (50) using 2 thread(s) #> _________________________________________________________________________ #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Retrieving the results ans <- run_multiple_get_results(model_sir) head(ans$total_hist) #> sim_num date nviruses state counts #> 1 1 0 1 Susceptible 990 #> 2 1 0 1 Infected 10 #> 3 1 0 1 Recovered 0 #> 4 1 1 1 Susceptible 974 #> 5 1 1 1 Infected 25 #> 6 1 1 1 Recovered 1 head(ans$reproductive) #> sim_num virus_id virus source source_exposure_date rt #> 1 1 0 COVID-19 767 11 0 #> 2 1 0 COVID-19 835 10 0 #> 3 1 0 COVID-19 466 9 0 #> 4 1 0 COVID-19 612 9 0 #> 5 1 0 COVID-19 793 9 0 #> 6 1 0 COVID-19 20 8 0 plot(ans$reproductive)"},{"path":"/index.html","id":"other-abm-r-packages","dir":"","previous_headings":"","what":"Other ABM R packages","title":"Fast Agent-Based Epi Models","text":"may want check R packages agent-based modeling: ABM, abmR, cystiSim, villager, RNetLogo.","code":""},{"path":"/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Fast Agent-Based Epi Models","text":"Please note epiworldR project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"/paper.html","id":null,"dir":"","previous_headings":"","what":"Introduction","title":"Introduction","text":"Agent-based modeling (ABM) emerged powerful computational approach studying complex systems across various fields, including social sciences epidemiology. simulating interactions behaviors individual entities, known agents, ABM provides unique lens researchers can analyze understand emergent properties dynamics systems. epiworldR package provides flexible framework ABM implementation methods prototyping disease outbreaks transmission models using C++ backend. supports multiple epidemiological models, including Susceptible-Infected-Susceptible (SIS), Susceptible-Infected-Removed (SIR), Susceptible-Exposed-Infected-Removed (SEIR), others, involving arbitrary mitigation policies multiple-disease models. Users can specify transmission/susceptibility rates function agents’ features, providing great complexity model dynamics.","code":""},{"path":"/paper.html","id":"key-features","dir":"","previous_headings":"","what":"Key Features","title":"Introduction","text":"Built robust foundation C++, package combines efficient computation flexibility R, providing seamless user experience several standout features: Multiple Viruses - feature allows researchers simulate analyze dynamics various infectious diseases simultaneously. Multiple Tools - capability enables users design model objects may reflect real-world interventions. Examples include vaccines, mask wearing protocols, social distancing, much . Multiple Runs - epiworldR ability run simulations multiple times, providing complete picture simulation results behaviors. Global Actions - Similar adding multiple tools, global actions allow users implement interventions policies global scale point simulation, mimicking real-world scenarios aiding assessment impact. Built-Epidemiological Models - feature ensures researchers access well-established widely recognized frameworks, making easier compare benchmark results. Included popular epidemiological models : SIR, SIS, SEIR, SIR connected, SIS connected, SEIR connected, . extensive range features, epiworldR empowers researchers practitioners field epidemiology conduct thorough analyses, make informed decisions, contribute advancement public health.","code":""},{"path":"/paper.html","id":"existing-alternatives","dir":"","previous_headings":"","what":"Existing Alternatives","title":"Introduction","text":"Several alternatives epiworldR exist provide researchers range options, unique features strengths, enabling exploration analysis infectious disease dynamics agent-based modeling. manually curated table existing alternatives including ABM [@ABM], abmR [@abmR], cystiSim [@cystiSim], villager [@villager], RNetLogo [@RNetLogo].","code":""},{"path":"/paper.html","id":"statement-of-need","dir":"","previous_headings":"","what":"Statement of Need","title":"Introduction","text":"epiworldR package addresses need sophisticated epidemiological research offering user-friendly agent-based modeling (ABM) tool simulating analyzing infectious disease dynamics. caters diverse audience researchers, epidemiologists, public health practitioners, social scientists, policymakers, enabling study complex disease spread patterns, evaluate intervention strategies, prepare emerging pathogens. Unlike traditional epidemiological models, epiworldR’s ABM approach captures individual-level behaviors interactions, providing realistic representation disease dynamics. distinction sets apart compartmental models ABM frameworks, making epiworldR valuable accessible tool advancing infectious disease modeling enhancing outbreak preparedness.","code":""},{"path":"/paper.html","id":"conclusion","dir":"","previous_headings":"","what":"Conclusion","title":"Introduction","text":"development epiworldR package ushered new era agent-based modeling field social science epidemiology. harnessing power C++ flexibility R, comprehensive package offers multitude features enhance modeling analysis complex infectious disease dynamics. package’s ability handle multiple viruses tools, diverse set epidemiological models, capability run simulations multiple times, inclusion global actions capability empower researchers explore wide range scenarios make informed decisions regarding public health interventions. epiworldR serves valuable resource social science epidemiological communities, enabling study real-world phenomena, prediction outcomes, policy analysis. field epidemiology continues evolve, epiworldR stands forefront, providing researchers practitioners powerful tool navigate complexities infectious diseases contribute improvement global health outcomes.","code":""},{"path":[]},{"path":"/reference/ModelDiffNet.html","id":null,"dir":"Reference","previous_headings":"","what":"Network Diffusion Model — ModelDiffNet","title":"Network Diffusion Model — ModelDiffNet","text":"network diffusion model simple model assumes probability adoption behavior proportional number adopters network.","code":""},{"path":"/reference/ModelDiffNet.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Network Diffusion Model — ModelDiffNet","text":"","code":"ModelDiffNet( name, prevalence, prob_adopt, normalize_exposure = TRUE, data = matrix(nrow = 0, ncol = 0), data_cols = 1L:ncol(data), params = vector(\"double\") ) # S3 method for epiworld_diffnet plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelDiffNet.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Network Diffusion Model — ModelDiffNet","text":"name Name model. prevalence Prevalence disease. prob_adopt Probability adoption. normalize_exposure Normalize exposure. data Data. data_cols Data columns. params Parameters. x Object class epiworld_diffnet. main Title plot ... Passed graphics::plot.","code":""},{"path":"/reference/ModelDiffNet.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Network Diffusion Model — ModelDiffNet","text":"object class epiworld_diffnet epiworld_model.","code":""},{"path":"/reference/ModelDiffNet.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Network Diffusion Model — ModelDiffNet","text":"Different common epidemiological models, network diffusion model assumes probability adoption behavior proportional number adopters network. model defined following equations: $$ P(adopt) = \\mbox{Logit}^{-1}(prob\\_adopt + params * data + exposure) $$ exposure number adopters agent's network. Another important difference transmission network necesary useful since adoption model particular neighbor.","code":""},{"path":[]},{"path":"/reference/ModelDiffNet.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Network Diffusion Model — ModelDiffNet","text":"","code":"set.seed(2223) n <- 10000 # Generating synthetic data on a matrix with 2 columns. X <- cbind( age = sample(1:100, n, replace = TRUE), female = sample.int(2, n, replace = TRUE) - 1 ) adopt_chatgpt <- ModelDiffNet( \"ChatGPT\", prevalence = .01, prob_adopt = .1, data = X, params = c(1, 4) ) # Simulating a population from smallworld agents_smallworld(adopt_chatgpt, n, 8, FALSE, .01) # Running the model for 50 steps run(adopt_chatgpt, 50) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. # Plotting the model plot(adopt_chatgpt)"},{"path":"/reference/ModelSEIR.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"Susceptible Exposed Infected Recovered model (SEIR)","code":""},{"path":"/reference/ModelSEIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"","code":"ModelSEIR(name, prevalence, transmission_rate, incubation_days, recovery_rate) # S3 method for epiworld_seir plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSEIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"name String. Name virus. prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. incubation_days Numeric scalar greater 0. Average number incubation days. recovery_rate Numeric scalar 0 1. Rate recovery_rate virus. x Object class SEIR. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSEIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"ModelSEIRfunction returns model class epiworld_model. plot function returns plot SEIR model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSEIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"","code":"model_seir <- ModelSEIR(name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1, incubation_days = 4) # Adding a small world population agents_smallworld( model_seir, n = 1000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_seir, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seir #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed (SEIR) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 0 Susceptible, 0 Exposed, 7 Infected, and 993 Removed. plot(model_seir, main = \"SEIR Model\")"},{"path":"/reference/ModelSEIRCONN.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","title":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","text":"SEIR connected model implements model agents connected. equivalent compartmental model (wiki).","code":""},{"path":"/reference/ModelSEIRCONN.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","text":"","code":"ModelSEIRCONN( name, n, prevalence, contact_rate, transmission_rate, incubation_days, recovery_rate ) # S3 method for epiworld_seirconn plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSEIRCONN.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","text":"name String. Name virus. n Number individuals population. prevalence Initial proportion individuals virus. contact_rate Numeric scalar. Average number contacts per step. transmission_rate Numeric scalar 0 1. Probability transmission. incubation_days Numeric scalar greater 0. Average number incubation days. recovery_rate Numeric scalar 0 1. Probability recovery_rate. x Object class SEIRCONN. main Title plot. ... Currently ignore.","code":""},{"path":"/reference/ModelSEIRCONN.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","text":"ModelSEIRCONNfunction returns model class epiworld_model. plot function returns plot SEIRCONN model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSEIRCONN.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","text":"","code":"# An example with COVID-19 model_seirconn <- ModelSEIRCONN( name = \"COVID-19\", prevalence = 0.01, n = 10000, contact_rate = 2, incubation_days = 7, transmission_rate = 0.5, recovery_rate = 0.3 ) # Running and printing run(model_seirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seirconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed (SEIR) (connected) #> It features 10000 agents, 1 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 430 Susceptible, 0 Exposed, 6 Infected, and 9564 Recovered. plot(model_seirconn) # Adding the flu flu <- virus(\"Flu\", .9, 1/7) add_virus(model_seirconn, flu, .001) #' # Running and printing run(model_seirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seirconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed (SEIR) (connected) #> It features 10000 agents, 2 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 3 Susceptible, 0 Exposed, 0 Infected, and 9997 Recovered. plot(model_seirconn)"},{"path":"/reference/ModelSEIRD.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD)","code":""},{"path":"/reference/ModelSEIRD.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"","code":"ModelSEIRD( name, prevalence, transmission_rate, incubation_days, recovery_rate, death_rate ) # S3 method for epiworld_seird plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSEIRD.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"name String. Name virus. prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. incubation_days Numeric scalar greater 0. Average number incubation days. recovery_rate Numeric scalar 0 1. Rate recovery_rate virus. death_rate Numeric scalar 0 1. Rate death virus. x Object class SEIRD. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSEIRD.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"ModelSEIRDfunction returns model class epiworld_model. plot function returns plot SEIRD model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSEIRD.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"","code":"model_seird <- ModelSEIRD(name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1, incubation_days = 4, death_rate = 0.01) # Adding a small world population agents_smallworld( model_seird, n = 100000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_seird, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seird #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed-Deceased (SEIRD) #> It features 100000 agents, 1 virus(es), and 0 tool(s). #> The model has 5 states. #> The final distribution is: 1979 Susceptible, 394 Exposed, 898 Infected, 91290 Removed, and 5439 Deceased. plot(model_seird, main = \"SEIRD Model\")"},{"path":"/reference/ModelSEIRDCONN.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"SEIRD connected model implements model agents connected. equivalent compartmental model (wiki).","code":""},{"path":"/reference/ModelSEIRDCONN.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"","code":"ModelSEIRDCONN( name, n, prevalence, contact_rate, transmission_rate, incubation_days, recovery_rate, death_rate ) # S3 method for epiworld_seirdconn plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSEIRDCONN.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"name String. Name virus. n Number individuals population. prevalence Initial proportion individuals virus. contact_rate Numeric scalar. Average number contacts per step. transmission_rate Numeric scalar 0 1. Probability transmission. incubation_days Numeric scalar greater 0. Average number incubation days. recovery_rate Numeric scalar 0 1. Probability recovery_rate. death_rate Numeric scalar 0 1. Probability death. x Object class SEIRCONN. main Title plot. ... Currently ignore.","code":""},{"path":"/reference/ModelSEIRDCONN.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"ModelSEIRDCONNfunction returns model class epiworld_model. plot function returns plot SEIRDCONN model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSEIRDCONN.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"","code":"# An example with COVID-19 model_seirdconn <- ModelSEIRDCONN( name = \"COVID-19\", prevalence = 0.01, n = 10000, contact_rate = 2, incubation_days = 7, transmission_rate = 0.5, recovery_rate = 0.3, death_rate = 0.01 ) # Running and printing run(model_seirdconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seirdconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed-Deceased (SEIRD) (connected) #> It features 10000 agents, 1 virus(es), and 0 tool(s). #> The model has 5 states. #> The final distribution is: 439 Susceptible, 0 Exposed, 3 Infected, 9326 Removed, and 232 Deceased. plot(model_seirdconn) # Adding the flu flu <- virus(\"Flu\", prob_infecting = .3, recovery_rate = 1/7, prob_death = 0.001) add_virus(model = model_seirdconn, virus = flu, proportion = .001) #' # Running and printing run(model_seirdconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seirdconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed-Deceased (SEIRD) (connected) #> It features 10000 agents, 2 virus(es), and 0 tool(s). #> The model has 5 states. #> The final distribution is: 410 Susceptible, 7 Exposed, 4 Infected, 9384 Removed, and 195 Deceased. plot(model_seirdconn)"},{"path":"/reference/ModelSIR.html","id":null,"dir":"Reference","previous_headings":"","what":"SIR model — ModelSIR","title":"SIR model — ModelSIR","text":"SIR model","code":""},{"path":"/reference/ModelSIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SIR model — ModelSIR","text":"","code":"ModelSIR(name, prevalence, transmission_rate, recovery_rate) # S3 method for epiworld_sir plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SIR model — ModelSIR","text":"name String. Name virus prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. recovery_rate Numeric scalar 0 1. Rate recovery_rate virus. x Object class SIR. main Title plot ... Additional arguments passed graphics::plot.","code":""},{"path":"/reference/ModelSIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SIR model — ModelSIR","text":"ModelSIR function returns model class epiworld_model. plot function returns plot SIR model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SIR model — ModelSIR","text":"","code":"model_sir <- ModelSIR(name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1) # Adding a small world population agents_smallworld( model_sir, n = 1000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_sir, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sir #> ________________________________________________________________________________ #> Susceptible-Infected-Recovered (SIR) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 0 Susceptible, 9 Infected, and 991 Recovered. # Plotting plot(model_sir)"},{"path":"/reference/ModelSIRCONN.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"Susceptible Infected Removed model (SIR connected)","code":""},{"path":"/reference/ModelSIRCONN.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"","code":"ModelSIRCONN( name, n, prevalence, contact_rate, transmission_rate, recovery_rate ) # S3 method for epiworld_sirconn plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIRCONN.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"name String. Name virus n Number individuals population. prevalence Double. Initial proportion individuals virus. contact_rate Numeric scalar. Average number contacts per step. transmission_rate Numeric scalar 0 1. Probability transmission. recovery_rate Numeric scalar 0 1. Probability recovery. x Object class SIRCONN. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSIRCONN.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"ModelSIRCONNfunction returns model class epiworld_model. plot function returns plot SIRCONN model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIRCONN.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"","code":"model_sirconn <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) # Running and printing run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sirconn #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 10000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 2000 Susceptible, 0 Infected, and 8000 Recovered. plot(model_sirconn, main = \"SIRCONN Model\")"},{"path":"/reference/ModelSIRD.html","id":null,"dir":"Reference","previous_headings":"","what":"SIRD model — ModelSIRD","title":"SIRD model — ModelSIRD","text":"SIRD model","code":""},{"path":"/reference/ModelSIRD.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SIRD model — ModelSIRD","text":"","code":"ModelSIRD(name, prevalence, transmission_rate, recovery_rate, death_rate) # S3 method for epiworld_sird plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIRD.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SIRD model — ModelSIRD","text":"name String. Name virus prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. recovery_rate Numeric scalar 0 1. Rate recovery_rate virus. death_rate Numeric scalar 0 1. Rate death virus. x Object class SIR. main Title plot ... Additional arguments passed graphics::plot.","code":""},{"path":"/reference/ModelSIRD.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SIRD model — ModelSIRD","text":"ModelSIRD function returns model class epiworld_model. plot function returns plot SIRD model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIRD.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SIRD model — ModelSIRD","text":"","code":"model_sird <- ModelSIRD( name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1, death_rate = 0.01 ) # Adding a small world population agents_smallworld( model_sird, n = 1000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_sird, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sird #> ________________________________________________________________________________ #> Susceptible-Infected-Recovered-Deceased (SIRD) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 0 Susceptible, 5 Infected, 912 Recovered, and 83 Deceased. # Plotting plot(model_sird)"},{"path":"/reference/ModelSIRDCONN.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"Susceptible Infected Removed Deceased model (SIRD connected)","code":""},{"path":"/reference/ModelSIRDCONN.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"","code":"ModelSIRDCONN( name, n, prevalence, contact_rate, transmission_rate, recovery_rate, death_rate ) # S3 method for epiworld_sirdconn plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIRDCONN.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"name String. Name virus n Number individuals population. prevalence Double. Initial proportion individuals virus. contact_rate Numeric scalar. Average number contacts per step. transmission_rate Numeric scalar 0 1. Probability transmission. recovery_rate Numeric scalar 0 1. Probability recovery. death_rate Numeric scalar 0 1. Probability death. x Object class SIRDCONN. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSIRDCONN.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"ModelSIRDCONNfunction returns model class epiworld_model. plot function returns plot SIRDCONN model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIRDCONN.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"","code":"model_sirdconn <- ModelSIRDCONN( name = \"COVID-19\", n = 100000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.5, death_rate = 0.1 ) # Running and printing run(model_sirdconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sirdconn #> ________________________________________________________________________________ #> Susceptible-Infected-Removed-Deceased (SIRD) (connected) #> It features 100000 agents, 1 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 3778 Susceptible, 0 Infected, 86521 Recovered, and 9701 Deceased. plot(model_sirdconn, main = \"SIRDCONN Model\")"},{"path":"/reference/ModelSIRLogit.html","id":null,"dir":"Reference","previous_headings":"","what":"SIR Logistic model — ModelSIRLogit","title":"SIR Logistic model — ModelSIRLogit","text":"SIR Logistic model","code":""},{"path":"/reference/ModelSIRLogit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SIR Logistic model — ModelSIRLogit","text":"","code":"ModelSIRLogit( vname, data, coefs_infect, coefs_recover, coef_infect_cols, coef_recover_cols, prob_infection, recovery_rate, prevalence )"},{"path":"/reference/ModelSIRLogit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SIR Logistic model — ModelSIRLogit","text":"vname Name virus. data numeric matrix n rows. coefs_infect Numeric vector. Coefficients associated infect. coefs_recover Numeric vector. Coefficients associated recover. coef_infect_cols Integer vector. Columns coeficient. coef_recover_cols Integer vector. Columns coeficient. prob_infection Numeric scalar. Baseline probability infection. recovery_rate Numeric scalar. Baseline probability recovery. prevalence Numeric scalar. Prevalence (initial state) proportion.","code":""},{"path":"/reference/ModelSIRLogit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SIR Logistic model — ModelSIRLogit","text":"ModelSIRLogit function returns model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIRLogit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SIR Logistic model — ModelSIRLogit","text":"","code":"set.seed(2223) n <- 100000 # Creating the data to use for the \"ModelSIRLogit\" function. It contains # information on the sex of each agent and will be used to determine # differences in disease progression between males and females. Note that # the number of rows in these data are identical to n (100000). X <- cbind( Intercept = 1, Female = sample.int(2, n, replace = TRUE) - 1 ) # Declare coefficients for each sex regarding transmission_rate and recovery. coef_infect <- c(.1, -2, 2) coef_recover <- rnorm(2) # Feed all above information into the \"ModelSIRLogit\" function. model_logit <- ModelSIRLogit( \"covid2\", data = X, coefs_infect = coef_infect, coefs_recover = coef_recover, coef_infect_cols = 1L:ncol(X), coef_recover_cols = 1L:ncol(X), prob_infection = .8, recovery_rate = .3, prevalence = .01 ) agents_smallworld(model_logit, n, 8, FALSE, .01) run(model_logit, 50) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. plot(model_logit) # Females are supposed to be more likely to become infected. rn <- get_reproductive_number(model_logit) # Probability of infection for males and females. (table( X[, \"Female\"], (1:n %in% rn$source) ) |> prop.table())[,2] #> 0 1 #> 0.12984 0.14201 # Looking into the individual agents. get_agents(model_logit) #> Agents from the model \"Susceptible-Infected-Removed (SIR) (logit)\": #> Agent: 0, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 1, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 2, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 3, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 4, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 5, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 6, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 7, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 8, state: Susceptible (0), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 9, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> ... 99990 more agents ..."},{"path":"/reference/ModelSIS.html","id":null,"dir":"Reference","previous_headings":"","what":"SIS model — ModelSIS","title":"SIS model — ModelSIS","text":"Susceptible-Infected-Susceptible model (SIS) (wiki)","code":""},{"path":"/reference/ModelSIS.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SIS model — ModelSIS","text":"","code":"ModelSIS(name, prevalence, transmission_rate, recovery_rate) # S3 method for epiworld_sis plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIS.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SIS model — ModelSIS","text":"name String. Name virus. prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. recovery_rate Numeric scalar 0 1. Rate recovery virus. x Object class SIS. main Title plot. ... Currently ignore.","code":""},{"path":"/reference/ModelSIS.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SIS model — ModelSIS","text":"ModelSIS function returns model class epiworld_model. plot function returns plot SIS model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIS.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SIS model — ModelSIS","text":"","code":"model_sis <- ModelSIS(name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1) # Adding a small world population agents_smallworld( model_sis, n = 1000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_sis, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sis #> ________________________________________________________________________________ #> Susceptible-Infected-Susceptible (SIS) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 2 states. #> The final distribution is: 100 Susceptible, and 900 Infected. # Plotting plot(model_sis, main = \"SIS Model\")"},{"path":"/reference/ModelSISD.html","id":null,"dir":"Reference","previous_headings":"","what":"SISD model — ModelSISD","title":"SISD model — ModelSISD","text":"Susceptible-Infected-Susceptible-Deceased model (SISD) (wiki)","code":""},{"path":"/reference/ModelSISD.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SISD model — ModelSISD","text":"","code":"ModelSISD(name, prevalence, transmission_rate, recovery_rate, death_rate) # S3 method for epiworld_sisd plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSISD.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SISD model — ModelSISD","text":"name String. Name virus. prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. recovery_rate Numeric scalar 0 1. Rate recovery virus. death_rate Numeric scalar 0 1. Rate death virus. x Object class SISD. main Title plot. ... Currently ignore.","code":""},{"path":"/reference/ModelSISD.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SISD model — ModelSISD","text":"ModelSISD function returns model class epiworld_model. plot function returns plot SISD model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSISD.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SISD model — ModelSISD","text":"","code":"model_sisd <- ModelSISD( name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1, death_rate = 0.01 ) # Adding a small world population agents_smallworld( model_sisd, n = 1000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_sisd, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sisd #> ________________________________________________________________________________ #> Susceptible-Infected-Susceptible-Deceased (SISD) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 52 Susceptible, 490 Infected, and 458 Deceased. # Plotting plot(model_sisd, main = \"SISD Model\")"},{"path":"/reference/ModelSURV.html","id":null,"dir":"Reference","previous_headings":"","what":"SURV model — ModelSURV","title":"SURV model — ModelSURV","text":"SURV model","code":""},{"path":"/reference/ModelSURV.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SURV model — ModelSURV","text":"","code":"ModelSURV( name, prevalence, efficacy_vax, latent_period, infect_period, prob_symptoms, prop_vaccinated, prop_vax_redux_transm, prop_vax_redux_infect, surveillance_prob, transmission_rate, prob_death, prob_noreinfect ) # S3 method for epiworld_surv plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSURV.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SURV model — ModelSURV","text":"name String. Name virus. prevalence Initial number individuals virus. efficacy_vax Double. Efficacy vaccine. (1 - P(acquire disease)). latent_period Double. Shape parameter 'Gamma(latent_period, 1)' distribution. coincides expected number latent days. infect_period Double. Shape parameter 'Gamma(infected_period, 1)' distribution. coincides expected number infectious days. prob_symptoms Double. Probability generating symptoms. prop_vaccinated Double. Probability vaccination. Coincides initial prevalence vaccinated individuals. prop_vax_redux_transm Double. Factor vaccine reduces transmissibility. prop_vax_redux_infect Double. Factor vaccine reduces chances becoming infected. surveillance_prob Double. Probability testing agent. transmission_rate Double. Raw transmission probability. prob_death Double. Raw probability death symptomatic individuals. prob_noreinfect Double. Probability re-infection. x Object class SURV. main Title plot. ... Currently ignore.","code":""},{"path":"/reference/ModelSURV.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SURV model — ModelSURV","text":"ModelSURVfunction returns model class epiworld_model. plot function returns plot SURV model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSURV.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SURV model — ModelSURV","text":"","code":"model_surv <- ModelSURV( name = \"COVID-19\", prevalence = 20, efficacy_vax = 0.6, latent_period = 4, infect_period = 5, prob_symptoms = 0.5, prop_vaccinated = 0.7, prop_vax_redux_transm = 0.8, prop_vax_redux_infect = 0.95, surveillance_prob = 0.1, transmission_rate = 0.2, prob_death = 0.001, prob_noreinfect = 0.5 ) # Adding a small world population agents_smallworld( model_surv, n = 10000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_surv, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_surv #> ________________________________________________________________________________ #> Surveillance #> It features 10000 agents, 1 virus(es), and 1 tool(s). #> The model has 8 states. #> The final distribution is: 9978 Susceptible, 0 Latent, 0 Symptomatic, 0 Symptomatic isolated, 0 Asymptomatic, 0 Asymptomatic isolated, 22 Recovered, and 0 Removed. # Plotting plot(model_surv, main = \"SURV Model\")"},{"path":"/reference/agents_smallworld.html","id":null,"dir":"Reference","previous_headings":"","what":"Load agents to a model — agents_smallworld","title":"Load agents to a model — agents_smallworld","text":"functions provide access network model. network represented edgelist. agents_smallworld function generates small world network Watts-Strogatz algorithm. agents_from_edgelist function loads network edgelist. get_network function returns edgelist network.","code":""},{"path":"/reference/agents_smallworld.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load agents to a model — agents_smallworld","text":"","code":"agents_smallworld(model, n, k, d, p) agents_from_edgelist(model, source, target, size, directed) get_network(model) get_agents_states(model) add_virus_agent(agent, model, virus, state_new = -99, queue = -99) add_tool_agent(agent, model, tool, state_new = -99, queue = -99) has_virus(agent, virus) has_tool(agent, tool) change_state(agent, model, state_new, queue = -99) get_agents_tools(model) get_agents_viruses(model)"},{"path":"/reference/agents_smallworld.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load agents to a model — agents_smallworld","text":"model Model object class epiworld_model. n, size Number individuals population. k Number ties small world network. d, directed Logical scalar. Whether graph directed . p Probability rewiring. source, target Integer vectors describing source target edgelist. agent Agent object class epiworld_agent. virus Virus object class epiworld_virus. state_new Integer scalar. New state agent action executed. queue Integer scalar. Change queuing system action executed. tool Tool object class epiworld_tool.","code":""},{"path":"/reference/agents_smallworld.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load agents to a model — agents_smallworld","text":"'agents_smallworld' function returns model agents loaded. agents_from_edgelist function returns empty model class epiworld_model. get_network function returns data frame two columns (source target) describing edgelist network. get_agents_states returns character vector states agents end simulation. function add_virus_agent adds virus agent returns agent invisibly. function add_tool_agent adds tool agent returns agent invisibly. functions has_virus has_tool return logical scalar indicating whether agent virus/tool . get_agents_tools returns list class epiworld_agents_tools epiworld_tools (list lists). get_agents_viruses returns list class epiworld_agents_viruses epiworld_viruses (list lists).","code":""},{"path":"/reference/agents_smallworld.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Load agents to a model — agents_smallworld","text":"new_state queue parameters optional. provided, agent updated default values virus/tool.","code":""},{"path":"/reference/agents_smallworld.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Load agents to a model — agents_smallworld","text":"","code":"# Initializing SIR model with agents_smallworld sir <- ModelSIR(name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1) agents_smallworld( sir, n = 1000, k = 5, d = FALSE, p = .01 ) run(sir, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. sir #> ________________________________________________________________________________ #> Susceptible-Infected-Recovered (SIR) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 0 Susceptible, 9 Infected, and 991 Recovered. # We can also retrieve the network net <- get_network(sir) head(net) #> from to #> 1 0 1 #> 2 0 2 #> 3 0 998 #> 4 0 999 #> 5 1 2 #> 6 1 3 # Simulating a bernoulli graph set.seed(333) n <- 1000 g <- matrix(runif(n ^ 2) < .01, nrow = n) diag(g) <- FALSE el <- which(g, arr.ind = TRUE) - 1L # Generating an empty model sir <- ModelSIR(\"COVID-19\", .01, .8, .3) agents_from_edgelist( sir, source = el[,1], target = el[,2], size = n, directed = TRUE ) # Running the simulation run(sir, 50) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. plot(sir)"},{"path":"/reference/epiworld-data.html","id":null,"dir":"Reference","previous_headings":"","what":"Accessing the database of epiworld — epiworld-data","title":"Accessing the database of epiworld — epiworld-data","text":"Models epiworld stored database. database can accessed using functions described manual page. elements database : transition matrix, incidence matrix, reproductive number, generation time, daily incidence virus tool level.","code":""},{"path":"/reference/epiworld-data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Accessing the database of epiworld — epiworld-data","text":"","code":"get_hist_total(x) get_today_total(x) get_hist_virus(x) get_hist_tool(x) get_transition_probability(x) get_reproductive_number(x) # S3 method for epiworld_repnum plot( x, y = NULL, ylab = \"Average Rep. Number\", xlab = \"Day (step)\", main = \"Reproductive Number\", type = \"b\", plot = TRUE, ... ) plot_reproductive_number(x, ...) get_hist_transition_matrix(x, skip_zeros = FALSE) # S3 method for epiworld_hist_transition as.array(x, ...) plot_incidence(x, ...) # S3 method for epiworld_hist_transition plot( x, type = \"b\", xlab = \"Day (step)\", ylab = \"Counts\", main = \"Daily incidence\", plot = TRUE, ... ) get_transmissions(x) get_generation_time(x) # S3 method for epiworld_generation_time plot( x, type = \"b\", xlab = \"Day (step)\", ylab = \"Avg. Generation Time\", main = \"Generation Time\", plot = TRUE, ... ) plot_generation_time(x, ...)"},{"path":"/reference/epiworld-data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Accessing the database of epiworld — epiworld-data","text":"x object class epiworld_sir, epiworld_seir, etc. model. y Ignored. ylab, xlab, main, type parameters passed graphics::plot() plot Logical scalar. TRUE (default), function desired statistic. ... case plot methods, arguments passed graphics::plot. skip_zeros Logical scalar. FALSE return entries transition matrix.","code":""},{"path":"/reference/epiworld-data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Accessing the database of epiworld — epiworld-data","text":"get_hist_total function returns object class epiworld_hist_total. get_today_total function returns named vector total number individuals state end simulation. get_hist_virus function returns object class epiworld_hist_virus. get_hist_tool function returns object epiworld_hist_virus. get_transition_probability function returns object class matrix. get_reproductive_number function returns object class epiworld_repnum. plot function returns plot reproductive number time. get_hist_transition_matrix returns data.frame four columns: \"state_from\", \"state_to\", \"date\", \"counts.\" .array method epiworld_hist_transition objects turns data.frame returned get_hist_transition_matrix array nstates x nstates x (ndays + 1) entries, first entry initial state. plot_incidence function returns plot originating object get_hist_transition_matrix. plot function returns plot originates epiworld_hist_transition object. function get_transmissions returns data.frame following columns: date, source, target, virus_id, virus, source_exposure_date. function get_generation_time returns data.frame following columns: \"agent\", \"virus_id\", \"virus\", \"date\", \"gentime\". function plot_generation_time wrapper plot get_generation_time.","code":""},{"path":"/reference/epiworld-data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Accessing the database of epiworld — epiworld-data","text":"plot_reproductive_number function wrapper around get_reproductive_number plots result. plot_incidence function wrapper get_hist_transition_matrix plot method. plot method epiworld_hist_transition class plots daily incidence state. function returns data frame used plotting.","code":""},{"path":[]},{"path":"/reference/epiworld-data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Accessing the database of epiworld — epiworld-data","text":"","code":"# SEIR Connected seirconn <- ModelSEIRCONN( name = \"Disease\", n = 10000, prevalence = 0.1, contact_rate = 2.0, transmission_rate = 0.8, incubation_days = 7.0, recovery_rate = 0.3 ) # Running the simulation for 50 steps (days) set.seed(937) run(seirconn, 50) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. # Retrieving the transition probability get_transition_probability(seirconn) #> Susceptible Exposed Infected Recovered #> Susceptible 0.9001378 0.09986219 0.0000000 0.0000000 #> Exposed 0.0000000 0.85468656 0.1453134 0.0000000 #> Infected 0.0000000 0.00000000 0.7024578 0.2975422 #> Recovered 0.0000000 0.00000000 0.0000000 1.0000000 # Retrieving date, state, and counts dataframe including any added tools get_hist_tool(seirconn) #> [1] date tool_id tool state counts #> <0 rows> (or 0-length row.names) # Retrieving overall date, state, and counts dataframe head(get_hist_total(seirconn)) #> date state counts #> 1 0 Susceptible 9000 #> 2 0 Exposed 1000 #> 3 0 Infected 0 #> 4 0 Recovered 0 #> 5 1 Susceptible 9000 #> 6 1 Exposed 859 # Retrieving date, state, and counts dataframe by variant head(get_hist_virus(seirconn)) #> date virus_id virus state counts #> 1 0 0 Disease Susceptible 0 #> 2 0 0 Disease Exposed 1000 #> 3 0 0 Disease Infected 0 #> 4 0 0 Disease Recovered 0 #> 5 1 0 Disease Susceptible 0 #> 6 1 0 Disease Exposed 859 # Retrieving (and plotting) the reproductive number rp <- get_reproductive_number(seirconn) plot(rp) # Also equivalent to plot_reproductive_number(seirconn) # We can go further and get all the history t_hist <- get_hist_transition_matrix(seirconn) head(t_hist) #> state_from state_to date counts #> 1 Susceptible Susceptible 0 9000 #> 2 Exposed Susceptible 0 0 #> 3 Infected Susceptible 0 0 #> 4 Recovered Susceptible 0 0 #> 5 Susceptible Exposed 0 1000 #> 6 Exposed Exposed 0 0 # And turn it into an array as.array(t_hist)[,,1:3] #> , , 0 #> #> Susceptible Exposed Infected Recovered #> Susceptible 9000 1000 0 0 #> Exposed 0 0 0 0 #> Infected 0 0 0 0 #> Recovered 0 0 0 0 #> #> , , 1 #> #> Susceptible Exposed Infected Recovered #> Susceptible 9000 0 0 0 #> Exposed 0 859 141 0 #> Infected 0 0 0 0 #> Recovered 0 0 0 0 #> #> , , 2 #> #> Susceptible Exposed Infected Recovered #> Susceptible 8805 195 0 0 #> Exposed 0 753 106 0 #> Infected 0 0 95 46 #> Recovered 0 0 0 0 #> # We cam also get (and plot) the incidence, as well as # the generation time inci <- plot_incidence(seirconn) gent <- plot_generation_time(seirconn)"},{"path":"/reference/epiworld-methods.html","id":null,"dir":"Reference","previous_headings":"","what":"Methods for epiworldR objects — epiworld-methods","title":"Methods for epiworldR objects — epiworld-methods","text":"functions described section methods objects class epiworld_model. Besides printing plotting, methods provide access manipulate model parameters, getting information model running simulation.","code":""},{"path":"/reference/epiworld-methods.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Methods for epiworldR objects — epiworld-methods","text":"","code":"queuing_on(x) queuing_off(x) verbose_off(x) verbose_on(x) run(model, ndays, seed = sample.int(10000, 1)) # S3 method for epiworld_model summary(object, ...) get_states(x) get_param(x, pname) set_param(x, pname, pval) set_name(x, mname) get_name(x) get_n_viruses(x) get_n_tools(x) get_ndays(x) get_n_replicates(x) size(x) set_agents_data(model, data) get_agents_data_ncols(model) get_virus(model, virus_pos) get_tool(model, tool_pos)"},{"path":"/reference/epiworld-methods.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Methods for epiworldR objects — epiworld-methods","text":"x object class epiworld_model. model Model object. ndays Number days (steps) simulation. seed Seed set initializing random number generator. object Object class epiworld_model. ... Additional arguments. pname String. Name parameter. pval Numeric. Value parameter. mname String. Name model. data numeric matrix. virus_pos Integer. Relative location (starting 0) virus model tool_pos Integer. Relative location (starting 0) tool model","code":""},{"path":"/reference/epiworld-methods.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Methods for epiworldR objects — epiworld-methods","text":"verbose_on verbose_off functions return model, however verbose_off returns model progress bar. run function returns simulated model class epiworld_model. summary function prints detailed view model, returns model invisibly. get_states function returns unique states found model. get_param function returns selected parameter model object class epiworld_model. set_param function return value instead alters parameter value. set_name function return value instead alters object epiworld_model. get_name returns name model. get_n_viruses returns number viruses model. get_n_tools returns number tools model. get_ndays returns number days model. get_n_replicates returns number replicates model. size.epiworld_model returns number agents model. 'set_agents_data' function returns object class DataFrame. 'get_agents_data_ncols' returns number columns model dataframe. 'get_virus' returns virus. get_tool returns tool.","code":""},{"path":"/reference/epiworld-methods.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Methods for epiworldR objects — epiworld-methods","text":"verbose_on verbose_off functions activate deactivate printing progress screen, respectively. functions return model (x) invisibly.","code":""},{"path":"/reference/epiworld-methods.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Methods for epiworldR objects — epiworld-methods","text":"","code":"model_sirconn <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) # Queuing - If you wish to implement the queuing function, declare whether # you would like it \"on\" or \"off\", if any. queuing_on(model_sirconn) #> Warning: SIR Connected models do not have queue. queuing_off(model_sirconn) run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Verbose - \"on\" prints the progress bar on the screen while \"off\" # deactivates the progress bar. Declare which function you want to implement, # if any. verbose_on(model_sirconn) verbose_off(model_sirconn) run(model_sirconn, ndays = 100, seed = 1912) get_states(model_sirconn) # Returns all unique states found within the model. #> [1] \"Susceptible\" \"Infected\" \"Recovered\" get_param(model_sirconn, 'Contact rate') # Returns the value of the selected #> [1] 5 # parameter within the model object. # In order to view the parameters, # run the model object and find the # \"Model parameters\" section. set_param(model_sirconn, 'Contact rate', 2) # Allows for adjustment of model # parameters within the model # object. In this example, the # Contact rate parameter is # changed to 2. You can now rerun # the model to observe any # differences. set_name(model_sirconn, 'My Epi-Model') # This function allows for setting # a name for the model. Running the # model object, the name of the model # is now reflected next to \"Name of # the model\". get_name(model_sirconn) # Returns the set name of the model. #> [1] \"My Epi-Model\" get_n_viruses(model_sirconn) # Returns the number of viruses in the model. #> [1] 1 # In this case, there is only one virus: # \"COVID-19\". get_n_tools(model_sirconn) # Returns the number of tools in the model. In #> [1] 0 # this case, there are zero tools. get_ndays(model_sirconn) # Returns the length of the simulation in days. This #> [1] 100 # will match \"ndays\" within the \"run\" function. get_n_replicates(model_sirconn) # Returns the number of replicates of the #> [1] 2 # model. size(model_sirconn) # Returns the population size in the model. In this case, #> [1] 10000 # there are 10,000 agents in the model. # Set Agents Data # First, your data matrix must have the same number of rows as agents in the # model. Below is a generated matrix which will be passed into the # \"set_agents_data\" function. data <- matrix(data=runif(20000, min=0, max=100), nrow=10000, ncol=2) set_agents_data(model_sirconn, data) get_agents_data_ncols(model_sirconn) # Returns number of columns #> [1] 2 get_virus(model_sirconn, 0) # Returns information about the first virus in #> Virus : COVID-19 #> Id : 0 #> state_init : 1 #> state_post : 2 #> state_removed : 2 #> queue_init : 2 #> queue_post : -2 #> queue_removed : -99 # the model (index begins at 0). add_tool(model_sirconn, tool(\"Vaccine\", .9, .9, .5, 1), proportion = .5) get_tool(model_sirconn, 0) # Returns information about the first tool in the #> Tool : Vaccine #> Id : 0 #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 # model. In this case, there are no tools so an # error message will occur."},{"path":"/reference/epiworldR-package.html","id":null,"dir":"Reference","previous_headings":"","what":"epiworldR — epiworldR-package","title":"epiworldR — epiworldR-package","text":"flexible framework Agent-Based Models (ABM), 'epiworldR' package provides methods prototyping disease outbreaks transmission models using 'C++' backend, making fast. supports multiple epidemiological models, including Susceptible-Infected-Susceptible (SIS), Susceptible-Infected-Removed (SIR), Susceptible-Exposed-Infected-Removed (SEIR), others, involving arbitrary mitigation policies multiple-disease models. Users can specify infectiousness/susceptibility rates function agents' features, providing great complexity model dynamics. Furthermore, 'epiworldR' ideal simulation studies featuring large populations.","code":""},{"path":[]},{"path":"/reference/epiworldR-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"epiworldR — epiworldR-package","text":"Maintainer: Derek Meyer derekmeyer37@gmail.com Authors: George Vega Yon g.vegayon@gmail.com (ORCID) contributors: Centers Disease Control Prevention (Award number 1U01CK000585; 75D30121F00003) [funder]","code":""},{"path":"/reference/get_agents.html","id":null,"dir":"Reference","previous_headings":"","what":"Agents in epiworldR — get_agents","title":"Agents in epiworldR — get_agents","text":"functions provide read-access agents model. get_agents function returns object class epiworld_agents contains information agents model. get_agent function returns information single agent. get_state function returns state single agent.","code":""},{"path":"/reference/get_agents.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Agents in epiworldR — get_agents","text":"","code":"get_agents(model) # S3 method for epiworld_agents [(x, i) # S3 method for epiworld_agent print(x, compressed = FALSE, ...) # S3 method for epiworld_agents print(x, compressed = TRUE, max_print = 10, ...) get_state(x)"},{"path":"/reference/get_agents.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Agents in epiworldR — get_agents","text":"model object class epiworld_model. x object class epiworld_agents Index (id) agent (0 n-1) compressed Logical scalar. FALSE, prints detailed information agent. ... Ignored max_print Integer scalar. Maximum number agents print.","code":""},{"path":"/reference/get_agents.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Agents in epiworldR — get_agents","text":"get_agents function returns object class epiworld_agents. [ method returns object class epiworld_agent. print function returns information individual agent class epiworld_agent. get_state function returns state epiworld_agents object.","code":""},{"path":[]},{"path":"/reference/get_agents.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Agents in epiworldR — get_agents","text":"","code":"model_sirconn <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. x <- get_agents(model_sirconn) # Storing all agent information into object of # class epiworld_agents print(x, compressed = FALSE, max_print = 5) # Displaying detailed information of #> Agents from the model \"Susceptible-Infected-Removed (SIR) (connected)\": #> Information about agent id 0 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 1 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 2 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 3 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 4 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 #> ... 9995 more agents ... # the first 5 agents using # compressed=F. Using compressed=T # results in less-detailed # information about each agent. x[0] # Print information about the first agent. Substitute the agent of #> Information about agent id 0 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 # interest's position where '0' is."},{"path":"/reference/global-actions.html","id":null,"dir":"Reference","previous_headings":"","what":"Global Actions — global-actions","title":"Global Actions — global-actions","text":"Global actions functions executed time step simulation. useful implementing interventions, vaccination, isolation, social distancing means tools.","code":""},{"path":"/reference/global-actions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Global Actions — global-actions","text":"","code":"globalaction_tool(tool, prob, name = get_name_tool(tool), day = -99) globalaction_tool_logit( tool, vars, coefs, name = get_name_tool(tool), day = -99 ) globalaction_set_params( param, value, name = paste0(\"Set \", param, \" to \", value), day = -99 ) globalaction_fun(fun, name = deparse(substitute(fun)), day = -99) add_global_action(model, action)"},{"path":"/reference/global-actions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Global Actions — global-actions","text":"tool object class tool. prob Numeric scalar. probability 0 1. name Character scalar. name action. day Integer. day (step) action executed (see details). vars Integer vector. position variables model. coefs Numeric vector. coefficients logistic regression. param Character scalar. name parameter set. value Numeric scalar. value parameter. fun Function. function executed. model object class epiworld_model. action global action.","code":""},{"path":"/reference/global-actions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Global Actions — global-actions","text":"globalaction_set_params function returns object class epiworld_globalaction_set_param epiworld_globalaction. globalaction_tool returns object class epiworld_globalaction_tool epiworld_globalaction. globalaction_tool_logit returns object class epiworld_globalaction_tool_logit epiworld_globalaction. function add_global_action returns model added action.","code":""},{"path":"/reference/global-actions.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Global Actions — global-actions","text":"function globalaction_tool_logit allows specify logistic regression model probability using tool. model specified vector coefficients coefs vector variables vars. vars integer vector indicating position variables model. function globalaction_set_param allows set parameter model. parameter specified name param value value. function globalaction_fun allows specify function executed given day. function object must receive object class epiworld_model argument. function add_global_action adds global action model. model checks actions executed time step. added action matches current time step, action executed. day negative, action executed time step. day positive, action executed specified time step.","code":""},{"path":[]},{"path":"/reference/global-actions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Global Actions — global-actions","text":"","code":"# Simple model model_sirconn <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) # Creating a tool epitool <- tool( name = \"Vaccine\", susceptibility_reduction = .9, transmission_reduction = .5, recovery_enhancer = .5, death_reduction = .9 ) # Adding a global action vaccine_day_20 <- globalaction_tool(epitool, .2, day = 20) add_global_action(model_sirconn, vaccine_day_20) # Running and printing run(model_sirconn, ndays = 40, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. model_sirconn #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 10000 agents, 1 virus(es), and 1 tool(s). #> The model has 3 states. #> The final distribution is: 2000 Susceptible, 0 Infected, and 8000 Recovered. plot_incidence(model_sirconn) # Example 2: Changing the contact rate ------------------------------------- model_sirconn2 <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) closure_day_10 <- globalaction_set_params(\"Contact rate\", 0, day = 10) add_global_action(model_sirconn2, closure_day_10) # Running and printing run(model_sirconn2, ndays = 40, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. model_sirconn2 #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 10000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 2127 Susceptible, 0 Infected, and 7873 Recovered. plot_incidence(model_sirconn2) # Example using `globalaction_fun` to record the state of the # agents at each time step. # We start by creating an SIR connected model model <- ModelSIRCONN( name = \"SIR with Global Saver\", n = 1000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.3 ) # We create the object where the history of the agents will be stored agents_history <- NULL # This function prints the total number of agents in each state # and stores the history of the agents in the object `agents_history` hist_saver <- function(m) { message(\"Today's totals are: \", paste(get_today_total(m), collapse = \", \")) # We use the `<<-` operator to assign the value to the global variable # `agents_history` (see ?\"<<-\") agents_history <<- cbind( agents_history, get_agents_states(m) ) }"},{"path":"/reference/run_multiple.html","id":null,"dir":"Reference","previous_headings":"","what":"Run multiple simulations at once — run_multiple","title":"Run multiple simulations at once — run_multiple","text":"run_multiple function allows running multiple simulations . available, users can take advantage parallel computing speed process.","code":""},{"path":"/reference/run_multiple.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Run multiple simulations at once — run_multiple","text":"","code":"run_multiple( m, ndays, nsims, seed = sample.int(10000, 1), saver = make_saver(), reset = TRUE, verbose = TRUE, nthreads = 1L ) run_multiple_get_results(m) make_saver(..., fn = \"\")"},{"path":"/reference/run_multiple.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Run multiple simulations at once — run_multiple","text":"m, ndays, seed See run. nsims Integer. Number replicats saver object class epiworld_saver. reset TRUE (default,) resets simulation. verbose TRUE (default,) prints progress bar. nthreads Integer. Number threads (parallel computing.) ... List strings (characters) specifying save (see details). fn file name pattern.","code":""},{"path":"/reference/run_multiple.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Run multiple simulations at once — run_multiple","text":"case make_saver, list class epiworld_saver. run_multiple function runs specified number simulations returns model object class epiworld_model. run_multiple_get_results function returns named list data specified make_saver.","code":""},{"path":"/reference/run_multiple.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Run multiple simulations at once — run_multiple","text":"Currently, following elements can saved: total_hist History model (total numbers per time). virus_info Information viruses. virus_hist Changes viruses. tool_info Information tools. tool_hist Changes tools. transmission Transmission events. transition Transition matrices. reproductive Reproductive number. generation Estimation generation time.","code":""},{"path":"/reference/run_multiple.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Run multiple simulations at once — run_multiple","text":"","code":"model_sir <- ModelSIRCONN( name = \"COVID-19\", prevalence = 0.01, n = 1000, contact_rate = 2, transmission_rate = 0.9, recovery_rate = 0.1 ) # Generating a saver saver <- make_saver(\"total_hist\", \"reproductive\") # Running and printing run_multiple(model_sir, ndays = 100, nsims = 50, saver = saver, nthread = 2) #> Starting multiple runs (50) using 2 thread(s) #> _________________________________________________________________________ #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Retrieving the results ans <- run_multiple_get_results(model_sir) head(ans$total_hist) #> sim_num date nviruses state counts #> 1 1 0 1 Susceptible 990 #> 2 1 0 1 Infected 10 #> 3 1 0 1 Recovered 0 #> 4 1 1 1 Susceptible 974 #> 5 1 1 1 Infected 26 #> 6 1 1 1 Recovered 0 head(ans$reproductive) #> sim_num virus_id virus source source_exposure_date rt #> 1 1 0 COVID-19 175 10 0 #> 2 1 0 COVID-19 672 10 0 #> 3 1 0 COVID-19 718 10 0 #> 4 1 0 COVID-19 210 9 0 #> 5 1 0 COVID-19 448 8 0 #> 6 1 0 COVID-19 592 8 0 # Plotting multi_sir <- run_multiple_get_results(model_sir)$total_hist multi_sir <- multi_sir[multi_sir$date <= 20,] plot(multi_sir)"},{"path":"/reference/tool.html","id":null,"dir":"Reference","previous_headings":"","what":"Tools in epiworld — tool","title":"Tools in epiworld — tool","text":"Tools functions affect agents react virus. can used simulate effects vaccination, isolation, social distancing.","code":""},{"path":"/reference/tool.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tools in epiworld — tool","text":"","code":"tool( name, susceptibility_reduction, transmission_reduction, recovery_enhancer, death_reduction ) set_name_tool(tool, name) get_name_tool(tool) add_tool(model, tool, proportion) add_tool_n(model, tool, n) rm_tool(model, tool_pos) rm_tool(model, tool_pos) tool_fun_logit(vars, coefs, model) set_susceptibility_reduction(tool, prob) set_susceptibility_reduction_ptr(tool, model, param) set_susceptibility_reduction_fun(tool, model, tfun) set_transmission_reduction(tool, prob) set_transmission_reduction_ptr(tool, model, param) set_transmission_reduction_fun(tool, model, tfun) set_recovery_enhancer(tool, prob) set_recovery_enhancer_ptr(tool, model, param) set_recovery_enhancer_fun(tool, model, tfun) set_death_reduction(tool, prob) set_death_reduction_ptr(tool, model, param) set_death_reduction_fun(tool, model, tfun) # S3 method for epiworld_agents_tools print(x, max_print = 10, ...)"},{"path":"/reference/tool.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tools in epiworld — tool","text":"name Name tool susceptibility_reduction Numeric. Proportion reduces susceptibility. transmission_reduction Numeric. Proportion reduces transmission. recovery_enhancer Numeric. Proportion improves recovery. death_reduction Numeric. Proportion reduces probability death.e tool object class epiworld_tool model Model proportion case add_tool, proportion, otherwise, integer. n positive integer. Number agents initially tool. tool_pos Positive integer. Index tool's position model. vars Integer vector. Indices (starting 0) positions variables used compute logit probability. coefs Numeric vector. length vars, vector coefficients associated logit probability. prob Numeric scalar. probability (zero one). param Character scalar. Name parameter featured model added tool (see details). tfun object class epiworld_tool_fun. x object class epiworld_agents_tools. max_print Numeric scalar. Maximum number tools print. ... Currently ignored.","code":""},{"path":"/reference/tool.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tools in epiworld — tool","text":"tool function creates tool class epiworld_tool. set_name_tool function assigns name tool class epiworld_tool returns tool. get_name_tool function returns name tool class epiworld_tool. add_tool_n function adds specified tool model class epiworld_model specified count n. rm_tool function removes specified tool model. set_susceptibility_reduction function assigns probability reduction specified tool class epiworld_tool. set_transmission_reduction function assigns probability reduction specified tool class epiworld_tool. set_recovery_enhancer function assigns probability increase specified tool class epiworld_tool. set_death_reduction function assigns probability decrease specified tool class epiworld_tool.","code":""},{"path":"/reference/tool.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tools in epiworld — tool","text":"name epiworld_tool object can manipulated functions set_name_tool() get_name_tool(). add_tool function adds specified tool model class epiworld_model specified proportion. case set_susceptibility_reduction_ptr, set_transmission_reduction_ptr, set_recovery_enhancer, set_death_reduction_ptr, corresponding parameters passed pointer tool. implication using pointers values read directly model object, changes reflected.","code":""},{"path":"/reference/tool.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tools in epiworld — tool","text":"","code":"# Simple model model_sirconn <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) # Running and printing run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. plot(model_sirconn) epitool <- tool( name = \"Vaccine\", susceptibility_reduction = .9, transmission_reduction = .5, recovery_enhancer = .5, death_reduction = .9 ) epitool #> Tool : Vaccine #> Id : (empty) #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 set_name_tool(epitool, 'Pfizer') # Assigning name to the tool get_name_tool(epitool) # Returning the name of the tool #> [1] \"Pfizer\" add_tool(model_sirconn, epitool, .5) run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sirconn #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 10000 agents, 1 virus(es), and 1 tool(s). #> The model has 3 states. #> The final distribution is: 8344 Susceptible, 0 Infected, and 1656 Recovered. plot(model_sirconn) # To declare a certain number of individuals with the tool rm_tool(model_sirconn, 0) # Removing epitool from the model add_tool_n(model_sirconn, epitool, 5500) run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Adjusting probabilities due to tool set_susceptibility_reduction(epitool, 0.1) # Susceptibility reduction #> Tool : Pfizer #> Id : 0 #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 set_transmission_reduction(epitool, 0.2) # Transmission reduction #> Tool : Pfizer #> Id : 0 #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 set_recovery_enhancer(epitool, 0.15) # Probability increase of recovery #> Tool : Pfizer #> Id : 0 #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 set_death_reduction(epitool, 0.05) # Probability reduction of death #> Tool : Pfizer #> Id : 0 #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 run(model_sirconn, ndays = 100, seed = 1912) # Run model to view changes #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Using the logit function -------------- sir <- ModelSIR( name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1 ) # Adding a small world population agents_smallworld( sir, n = 10000, k = 5, d = FALSE, p = .01 ) # Creating a tool mask_wearing <- tool( name = \"Mask\", susceptibility_reduction = 0.0, transmission_reduction = 0.3, # Only transmission recovery_enhancer = 0.0, death_reduction = 0.0 ) add_tool(sir, mask_wearing, .5) run(sir, ndays = 50, seed = 11) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. hist_0 <- get_hist_total(sir) # And adding features dat <- cbind( female = sample.int(2, 10000, replace = TRUE) - 1, x = rnorm(10000) ) set_agents_data(sir, dat) # Creating the logit function tfun <- tool_fun_logit( vars = c(0L, 1L), coefs = c(-1, 1), model = sir ) # The infection prob is lower hist(plogis(dat %*% rbind(.5,1))) tfun # printing #> An epiworld_tool_function object. #> (model: Susceptible-Infected-Recovered (SIR)) #> This function was built using -tool_fun_logit()-. and it features the following coefficients: #> 0: -1.00 #> 1: 1.00 set_susceptibility_reduction_fun( tool = get_tool(sir, 0), model = sir, tfun = tfun ) run(sir, ndays = 50, seed = 11) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. hist_1 <- get_hist_total(sir) op <- par(mfrow = c(1, 2)) plot(hist_0); abline(v = 30) plot(hist_1); abline(v = 30) par(op)"},{"path":"/reference/virus.html","id":null,"dir":"Reference","previous_headings":"","what":"Virus design — virus","title":"Virus design — virus","text":"Viruses can considered anything can transmitted (e.g., diseases, well ideas.) models epiworldR can feature multiple viruses.","code":""},{"path":"/reference/virus.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Virus design — virus","text":"","code":"virus( name, prob_infecting, recovery_rate = 0.5, prob_death = 0, post_immunity = -1, incubation = 7 ) set_name_virus(virus, name) get_name_virus(virus) add_virus(model, virus, proportion) add_virus_n(model, virus, n) virus_set_state(virus, init, end, removed) rm_virus(model, virus_pos) virus_fun_logit(vars, coefs, model) set_prob_infecting(virus, prob) set_prob_infecting_ptr(virus, model, param) set_prob_infecting_fun(virus, model, vfun) set_prob_recovery(virus, prob) set_prob_recovery_ptr(virus, model, param) set_prob_recovery_fun(virus, model, vfun) set_prob_death(virus, prob) set_prob_death_ptr(virus, model, param) set_prob_death_fun(virus, model, vfun) set_incubation(virus, incubation) set_incubation_ptr(virus, model, param) set_incubation_fun(virus, model, vfun) # S3 method for epiworld_agents_viruses print(x, max_print = 10, ...)"},{"path":"/reference/virus.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Virus design — virus","text":"name virus prob_infecting Numeric scalar. Probability infection (transmission). recovery_rate Numeric scalar. Probability recovery. prob_death Numeric scalar. Probability death. post_immunity Numeric scalar. Post immunity (prob re-infection). incubation Numeric scalar. Incubation period (days) virus. virus object class epiworld_virus model object class epiworld_model. proportion case add_virus, proportion, otherwise, integer. n positive integer. Initial count agents virus. init, end, removed states acquiring virus, removing virus, removing agent result virus, respectively. virus_pos Positive integer. Index virus's position model. vars Integer vector. Indices (starting 0) positions variables used compute logit probability. coefs Numeric vector. length vars, vector coefficients associated logit probability. prob Numeric scalar. probability (zero one). param Character scalar. Name parameter featured model added virus (see details). vfun object class epiworld_virus_fun. x object class epiworld_agents_viruses. max_print Numeric scalar. Maximum number viruses print. ... Currently ignored.","code":""},{"path":"/reference/virus.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Virus design — virus","text":"set_name_virus function return value, merely assigns name virus choice. get_name_virus function returns name virus class epiworld_virus. add_virus function return value, instead adds virus choice model object class epiworld_model. add_virus_n function return value, instead adds specified number agents virus choice model object class epiworld_model. virus_set_state function return value assigns epidemiological properties specified virus class epiworld_virus. rm_virus function return value, instead removes specified virus model class epiworld_model. set_prob_infecting function return value, instead assigns probability infection specified virus class epiworld_virus. set_prob_recovery function return value, instead assigns probability recovery specified virus class epiworld_virus. set_prob_death function return value, instead assigns probability death specified virus class epiworld_virus. set_incubation function return value, instead assigns incubation period specified virus class epiworld_virus.","code":""},{"path":"/reference/virus.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Virus design — virus","text":"virus() function can used initialize virus. Virus features can modified using functions set_prob_*. function virus_fun_logit() creates \"virus function\" can evaluated transmission, recovery, death. name sugests, computes probabilities using logit function (see examples). name epiworld_virus object can manipulated functions set_name_virus() get_name_virus(). case set_prob_infecting_ptr, set_prob_recovery_ptr, set_prob_death_ptr, corresponding parameters passed pointer virus. implication using pointers values read directly model object, changes reflected.","code":""},{"path":"/reference/virus.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Virus design — virus","text":"","code":"mseirconn <- ModelSEIRCONN( name = \"COVID-19\", prevalence = 0.01, n = 10000, contact_rate = 4, incubation_days = 7, transmission_rate = 0.5, recovery_rate = 0.99 ) delta <- virus(\"Delta Variant\", 0, .5, .2, .01) # Adding virus and setting/getting virus name add_virus(mseirconn, delta, .3) set_name_virus(delta, \"COVID-19 Strain\") get_name_virus(delta) #> [1] \"COVID-19 Strain\" run(mseirconn, ndays = 100, seed = 992) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. mseirconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed (SEIR) (connected) #> It features 10000 agents, 2 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 3774 Susceptible, 102 Exposed, 18 Infected, and 6106 Recovered. rm_virus(mseirconn, 0) # Removing the first virus from the model object add_virus_n(mseirconn, delta, 100) # Setting initial count of delta virus # to n = 100 # Setting parameters for the delta virus manually set_prob_infecting(delta, 0.5) set_prob_recovery(delta, 0.9) set_prob_death(delta, 0.01) run(mseirconn, ndays = 100, seed = 992) # Run the model to observe changes #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # If the states were (for example): # 1: Infected # 2: Recovered # 3: Dead delta2 <- virus(\"Delta Variant 2\", 0, .5, .2, .01) virus_set_state(delta2, 1, 2, 3) # Using the logit function -------------- sir <- ModelSIR( name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery = 0.1 ) # Adding a small world population agents_smallworld( sir, n = 10000, k = 5, d = FALSE, p = .01 ) run(sir, ndays = 50, seed = 11) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. plot(sir) # And adding features dat <- cbind( female = sample.int(2, 10000, replace = TRUE) - 1, x = rnorm(10000) ) set_agents_data(sir, dat) # Creating the logit function vfun <- virus_fun_logit( vars = c(0L, 1L), coefs = c(-1, 1), model = sir ) # The infection prob is lower hist(plogis(dat %*% rbind(-1,1))) vfun # printing #> An epiworld_virus_function object. #> (model: Susceptible-Infected-Recovered (SIR)) #> This function was built using -virus_fun_logit()-. and it features the following coefficients: #> 0: -1.00 #> 1: 1.00 set_prob_infecting_fun( virus = get_virus(sir, 0), model = sir, vfun = vfun ) run(sir, ndays = 50, seed = 11) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. plot(sir)"},{"path":"/news/index.html","id":"epiworldr-00-3","dir":"Changelog","previous_headings":"","what":"epiworldR 0.0-3","title":"epiworldR 0.0-3","text":"Added following models: ModelSEIRD, ModelSEIRDCONN, ModelSIRD, ModelSIRDCONN, ModelSISD. Fixed bug reported issue 6.","code":""},{"path":"/news/index.html","id":"epiworldr-00-2","dir":"Changelog","previous_headings":"","what":"epiworldR 0.0-2","title":"epiworldR 0.0-2","text":"CRAN release: 2023-06-21 Added NEWS.md file track changes package. Fixed bug reported CRAN reference nullptr. Renamed arguments across Models favor consistency. Figures now show virus/tool name instead id. Fixed bug run_multiple added tests (C++). Redid autoconf Makevars using RcppArmadillo template checking OpenMP.","code":""}] +[{"path":[]},{"path":"/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement derekmeyer37@gmail.com. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired Mozilla’s code conduct enforcement ladder. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 George G. Vega Yon Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":[]},{"path":"/articles/getting-started.html","id":"setup-and-running-the-model","dir":"Articles","previous_headings":"Example 1: Simulating an SIR model","what":"Setup and running the model","title":"Getting started with epiworldR","text":"example implements social network parameters listed within ModelSIRCONN function. virus name specified (COVID-19), 50000 agents initialized, virus prevalence 0.001 declared, agent contact two others (contact_rate), transmission rate given agent 0.3, recovery rate set \\(\\frac{1}{3}\\). create model epiworldR, simply use ModelSIRCONN function. , example take basic features epiworldR. Printing model shows us information. Nevertheless, can extract detailed information using summary method. First, name model, population size, number entities (think public spaces agents can make social contact one another), duration days, number viruses, amount time last replicate took run (last run elapsed t), rewiring status (). model also includes list global actions (interventions) called model run. Next, see list viruses used model. case, COVID-19 virus used. Note epiworldR can include one virus model. Tool(s) lists agents’ tools fight virus. Examples may include masking, vaccines, social distancing, etc. model, tools specified. Lastly, model parameters listed. execute model, use run function SIR model object, number simulation days, optional seed reproducibility. Next, print results simulated model using model_sir. two additional sections included summary running model. First, see distribution population time 50. section describes flow agents state (SIR) 50 days. example, ’ll see number agents susceptible state decreased 49,995 3,364, number agents infected state increased 5 0, recovered agents increased 46,636 50 days. counts states change based model parameters simulation run-time. transmission probabilities section outputs 3x3 matrix describes probability moving one state another. example, susceptible row, agent 0.95 probability remaining susceptible state 0.05 probability moving susceptible state infected state. Notice chance skipping states. words, agent can’t jump susceptible state recovered state; agent must pass infected state progress recovered state. logic applies moving backward; agent become susceptible infection.","code":"library(epiworldR) model_sir <- ModelSIRCONN( name = \"COVID-19\", n = 50000, prevalence = 0.0001, contact_rate = 2, transmission_rate = 0.5, recovery_rate = 1/3 ) # Printing the model model_sir #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 50000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. The model hasn't been run yet. summary(model_sir) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Removed (SIR) (connected) #> Population size : 50000 #> Agents' data : (none) #> Number of entities : 0 #> Days (duration) : 0 (of 0) #> Number of viruses : 1 #> Last run elapsed t : - #> Rewiring : off #> #> Global actions: #> (none) #> #> Virus(es): #> - COVID-19 (baseline prevalence: 0.01%) #> #> Tool(s): #> (none) #> #> Model parameters: #> - Contact rate : 2.0000 #> - Recovery rate : 0.3333 #> - Transmission rate : 0.5000 run(model_sir, ndays = 50, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. summary(model_sir) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Removed (SIR) (connected) #> Population size : 50000 #> Agents' data : (none) #> Number of entities : 0 #> Days (duration) : 50 (of 50) #> Number of viruses : 1 #> Last run elapsed t : 524.00ms #> Last run speed : 4.77 million agents x day / second #> Rewiring : off #> #> Global actions: #> (none) #> #> Virus(es): #> - COVID-19 (baseline prevalence: 0.01%) #> #> Tool(s): #> (none) #> #> Model parameters: #> - Contact rate : 2.0000 #> - Recovery rate : 0.3333 #> - Transmission rate : 0.5000 #> #> Distribution of the population at time 50: #> - (0) Susceptible : 49995 -> 3364 #> - (1) Infected : 5 -> 0 #> - (2) Recovered : 0 -> 46636 #> #> Transition Probabilities: #> - Susceptible 0.95 0.05 0.00 #> - Infected 0.00 0.64 0.36 #> - Recovered 0.00 0.00 1.00"},{"path":[]},{"path":"/articles/getting-started.html","id":"extracting-information","dir":"Articles","previous_headings":"Example 1: Simulating an SIR model","what":"Extracting information","title":"Getting started with epiworldR","text":"running epiworldR model, list functions can called using epiworld model object. demonstrate, start basic plot get_hist_total functions. evident plot, SIR model constructed epiworldR displays changes susceptible, infected, recovered case counts time (days). Notice certain amount time, curves flatten. , table representation plot printed, complete state within SIR model, date, agent counts. essential statistic epidemiological models reproductive number: epiworldR method plot reproductive number automatically. function takes average values table date repeats data accounted . Another typical piece information daily incidence. number new cases per day. epiworldR, can get incidence looking daily transitions states. Although function get_hist_transition_matrix provides desired data, function plot_incidence nice wrapper visualizing data:","code":"methods(class = \"epiworld_model\") #> [1] add_tool_n add_tool #> [3] add_virus_n add_virus #> [5] agents_from_edgelist agents_smallworld #> [7] get_hist_tool get_hist_total #> [9] get_hist_transition_matrix get_hist_virus #> [11] get_n_replicates get_n_tools #> [13] get_n_viruses get_name #> [15] get_ndays get_param #> [17] get_reproductive_number get_states #> [19] get_today_total get_transition_probability #> [21] get_transmissions print #> [23] queuing_off queuing_on #> [25] run_multiple run #> [27] set_name set_param #> [29] size summary #> [31] verbose_off verbose_on #> see '?methods' for accessing help and source code plot(model_sir) head(get_hist_total(model_sir)) #> date state counts #> 1 0 Susceptible 49995 #> 2 0 Infected 5 #> 3 0 Recovered 0 #> 4 1 Susceptible 49991 #> 5 1 Infected 9 #> 6 1 Recovered 0 repnum <- get_reproductive_number(model_sir) head(repnum) #> virus_id virus source source_exposure_date rt #> 1 0 COVID-19 23811 44 0 #> 2 0 COVID-19 38232 42 1 #> 3 0 COVID-19 19769 41 1 #> 4 0 COVID-19 28486 40 0 #> 5 0 COVID-19 6422 39 0 #> 6 0 COVID-19 7907 39 0 x <- plot(repnum, type = \"b\") subset(x, date == 10) # Reproductive number on day 10 #> virus_id virus date avg n sd lb ub #> 11 0 COVID-19 10 2.450464 646 2.263946 0 7.875 plot_incidence(model_sir)"},{"path":"/articles/getting-started.html","id":"adding-more-virusesviruses","dir":"Articles","previous_headings":"Example 1: Simulating an SIR model","what":"Adding more viruses/viruses","title":"Getting started with epiworldR","text":"epiworldR supports multi-virus models. code gives instructions implement . Using virus function, give name new virus/virus corresponding probability infecting given agent. example, prob_infecting set 1.0, making highly contagious. officially add new virus model, use add_virus function calling original epiworldR model object, new virus, new virus’ prevalence (set 0.01 example). running updated model new virus included 50 days, output describes simulation. confirm flu included, notice presence “Flu” Virus(es) section output. output interpretable specified previous sections. Plotting previous model (including flu) yields following. Notice presence two reproductive numbers plotted time. Variant 0 refers COVID-19, virus 1 refers flu.","code":"# Building the virus flu <- virus(name = \"Flu\", prob_infecting = .3) # Adding the virus to the model add_virus(model_sir, flu, .0001) run(model_sir, ndays = 50, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. model_sir #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 50000 agents, 2 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 3264 Susceptible, 4 Infected, and 46732 Recovered. repnum2 <- get_reproductive_number(model_sir) op <- par(mfrow = c(2,1)) plot(model_sir) plot(repnum2, type=\"b\") par(op)"},{"path":"/articles/getting-started.html","id":"tools","dir":"Articles","previous_headings":"Example 1: Simulating an SIR model","what":"Tools","title":"Getting started with epiworldR","text":"Now, implementation tools combat viruses viruses model demonstrated. First, sake simplicity, remove flu virus SIR model object (keep mind index flu virus model object 1). Next, provide parameters new tool using tool function. parameters include name tool, reduction probabilities SIR model parameters, increased probability recovery option. order add tool SIR model, use add_tool function SIR model object, new tool, prevalence tool. example, assume 85% population received vaccination.","code":"# Removing the flu virus from the model rm_virus(model_sir, 1) vaccine <- tool( name = \"Vaccine\", susceptibility_reduction = .9, transmission_reduction = .5, recovery_enhancer = .5, death_reduction = .9 ) add_tool(model_sir, vaccine, 0.5) run(model_sir, ndays = 50, seed = 1231) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. repnum3 <- get_reproductive_number(model_sir) op <- par(mfrow = c(2,1)) plot_incidence(model_sir) plot(repnum3, type=\"b\") par(op)"},{"path":"/articles/implementation.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Implementation details of epiworldR","text":"following vignette provides detailed information implementation epiworldR. package wrapper C++ package epiworld, framework building agent-based models.1","code":""},{"path":"/articles/implementation.html","id":"general-flow-of-the-models","dir":"Articles","previous_headings":"","what":"General flow of the models","title":"Implementation details of epiworldR","text":"core function epiworldR run() function. function executes model saves results database part underlying C++ object. package implements discrete-time ABM, meaning model executed discrete steps (e.g., days). run() function executes following steps: model reset(), involves: () resetting agents, available, restoring population backup2, (b) resetting database, (c) distributing viruses tools, (d) setting initial state agents. steps fixing current_date = 0. model’s state recorded database, current_date incremented 1. resetting model, start iterative process repeating following steps: state agent updated. States updated according corresponding update_state function. Since model discrete-time, state changes stored promises, meaning agents’ states updated immediately. Instead, state updated end updates. done avoid updating state agent using updated state update state another agent. example, agent \\(\\) infects agent \\(j\\), agent \\(j\\) able infect agent \\(\\) step. update schedule laid , changes made effective, , instance, individuals became infected update start next step infected state. Global actions executed. also change agents’ states, just like previous step, changes stored promises made effective actions evaluated. model’s state recorded database, current_date incremented 1. model checks whether simulation stop. simulation stop, model stops. Otherwise, model goes back step . steps included epiworld epiworldR network rewiring mutation viruses. implemented future versions epiworldR.","code":""},{"path":[]},{"path":"/articles/implementation.html","id":"transmission-probability","dir":"Articles","previous_headings":"Computing probabilities","what":"Transmission probability","title":"Implementation details of epiworldR","text":"Generally, epiworldR assumes step simulation, susceptible agents can acquire disease one infected agent. probability transmission \\(\\) \\(j\\) given following formula: \\[ P(\\j| \\mbox{one}) = \\frac{p_{ij} \\times \\prod_{k\\neq }\\left(1 - p_{kj}\\right)}{\\prod_k\\left(1 - p_{kj}\\right) + \\sum_k p_{kj} \\times \\prod_{l\\neq k}\\left(1 - p_{lj}\\right)} \\] adjusted probabilities \\(p_{ij}\\) computed function \\(\\), \\(j\\), virus. following section describes probabilities computed.","code":""},{"path":"/articles/implementation.html","id":"adjusted-probabilities","dir":"Articles","previous_headings":"Computing probabilities","what":"Adjusted probabilities","title":"Implementation details of epiworldR","text":"Viruses tools provide way adjust agents move states. Viruses epiworldR contain various baseline probabilities used across models, including transmission, recovery, death. hand, tools alter probabilities reducing/increasing . Furthermore, tools alter agents’ susceptibility, infectiousness, recovery, death probabilities. Currently, tools alter probabilities constant factor, \\[ p_{ij} = p_{v} \\times \\left(1 - factor_{host}\\right) \\times \\left(1 - factor_{target}\\right) \\] \\(p_{v}\\) raw transmission probability virus \\(v\\), \\(factor_{t}\\) increasing/reducing factors tools process. example, p_v 0.9, host wearing mask, \\(factor_{\\mbox{mask host}} = 0.3\\) target vaccinated, \\(factor_{\\mbox{vaccinated target}} = 0.5\\), adjusted probability \\(p_{ij}\\) \\(0.9 \\times (1 - 0.3) \\times (1 - 0.5) = 0.27\\). agents one tool, factors combined follows: \\[ factor_{agent} = 1 - \\prod_{t\\tools_{agent}}\\left(1 - factor_{t}\\right) \\] Therefore, example, vaccinated agent wearing mask factor \\(1 - (1 - 0.30) \\times (1 - 0.5) = 0.65\\). adjusted probabilities principle also applies recovery rates SIR SEIR models.","code":""},{"path":"/articles/implementation.html","id":"transmission-in-connected-modelsmodels","dir":"Articles","previous_headings":"Computing probabilities","what":"Transmission in connected models3","title":"Implementation details of epiworldR","text":"“connected” models provide version agents live fully connected network. means agent can infect agent, making version similar typical compartmental models. models, transmission probability depends contact rate. susceptible agent, transmission process simulated follows: number contacts \\(c\\) drawn binomial distribution parameters \\(n\\) \\(p\\), \\(n\\) number agents \\(p =\\)contact_rate\\(/ n\\). , \\(c\\) agents randomly selected population. Transmission can occur agents susceptible agent. probability transmission \\(c\\) agents calculated described previous section.","code":""},{"path":"/articles/run-multiple.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Run Multiple","text":"purpose “run_multiple” function run specified number simulations using model object. , function makes possible compare model results across several separate repeated simulations.","code":""},{"path":[]},{"path":"/articles/run-multiple.html","id":"setup-and-running-model","dir":"Articles","previous_headings":"Example: Simulating a SEIRCONN Model 50 Times","what":"Setup and Running Model","title":"Run Multiple","text":"use “run_multiple” function epiworld, create epimodel choice; case, example uses SEIRCONN model COVID-19, 100000 people, initial prevalence 0.0001 (0.01%), contact rate 2, probability transmission 0.5, total 7 incubation days, probability recovery \\(\\frac{1}{3}\\).","code":"library(epiworldR) model_seirconn <- ModelSEIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.0001, contact_rate = 2, transmission_rate = 0.5, incubation_days = 7, recovery_rate = 1/3 )"},{"path":"/articles/run-multiple.html","id":"generating-a-saver","dir":"Articles","previous_headings":"Example: Simulating a SEIRCONN Model 50 Times","what":"Generating a Saver","title":"Run Multiple","text":"Next, generate saver purpose extracting “total_hist” “reproductive” information model object. Now, use “run_multiple” function model object, number desired days run simulation, number simulations run, number threads parallel computing. Using “run_multiple_get_results” function, extract results model object simulated 50 times comparison across simulations.","code":"# Generating a saver saver <- make_saver(\"total_hist\", \"reproductive\") # Running and printing run_multiple(model_seirconn, ndays = 50, nsims = 50, saver = saver, nthread = 1) #> Starting multiple runs (50) using 1 thread(s) #> _________________________________________________________________________ #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Retrieving the results ans <- run_multiple_get_results(model_seirconn) head(ans$total_hist) #> sim_num date nviruses state counts #> 1 1 0 1 Susceptible 9999 #> 2 1 0 1 Exposed 1 #> 3 1 0 1 Infected 0 #> 4 1 0 1 Recovered 0 #> 5 1 1 1 Susceptible 9999 #> 6 1 1 1 Exposed 1 head(ans$reproductive) #> sim_num virus_id virus source source_exposure_date rt #> 1 1 0 COVID-19 654 50 0 #> 2 1 0 COVID-19 1009 50 0 #> 3 1 0 COVID-19 4332 44 1 #> 4 1 0 COVID-19 5268 44 0 #> 5 1 0 COVID-19 4382 47 6 #> 6 1 0 COVID-19 7376 44 0"},{"path":"/articles/run-multiple.html","id":"plotting","dir":"Articles","previous_headings":"Example: Simulating a SEIRCONN Model 50 Times","what":"Plotting","title":"Run Multiple","text":"plot epicurves reproductive numbers time using boxplots, extract results model object using “run_multiple_get_results”. example, dates filtered less equal 20 observe epicurves first 20 days. Notice boxplot table represents observed values 50 simulations date. view plot reproductive number 50 days 50 simulations, store reproductive results new object using “run_multiple_get_results”, plot using “boxplot” function. Notice source exposure date displays boxplot representing distribution reproductive numbers across 50 simulations. expected, reproductive number average, decreases time.","code":"seirconn_50 <- run_multiple_get_results(model_seirconn)$total_hist seirconn_50 <- seirconn_50[seirconn_50$date <= 20,] plot(seirconn_50) seirconn_50_r <- run_multiple_get_results(model_seirconn)$reproductive plot(seirconn_50_r) # boxplot(rt ~ source_exposure_date, data = seirconn_50_r, # main = \"Reproductive Number\", # xlab = \"Source Exposure Date\", # ylab = \"rt\", # border = \"black\", # las = 2)"},{"path":"/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Derek Meyer. Author, maintainer. George Vega Yon. Author. Susan Holmes. Reviewer. JOSS reviewer Abinash Satapathy. Reviewer. JOSS reviewer Carinogurjao. Reviewer. Centers Disease Control Prevention. Funder. Award number 1U01CK000585; 75D30121F00003","code":""},{"path":"/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Meyer D, Vega Yon G (2023). epiworldR: Fast Agent-Based Epi Models. https://github.com/UofUEpiBio/epiworldR, https://uofuepibio.github.io/epiworldR/, https://uofuepibio.github.io/epiworldR-workshop/.","code":"@Manual{, title = {epiworldR: Fast Agent-Based Epi Models}, author = {Derek Meyer and George {Vega Yon}}, year = {2023}, note = {https://github.com/UofUEpiBio/epiworldR, https://uofuepibio.github.io/epiworldR/, https://uofuepibio.github.io/epiworldR-workshop/}, }"},{"path":"/index.html","id":"versions","dir":"","previous_headings":"","what":"Versions","title":"Fast Agent-Based Epi Models","text":"virtual INSNA Sunbelt 2023 session can found : https://github.com/UofUEpiBio/epiworldR-workshop/tree/sunbelt2023-virtual -person INSNA Sunbelt 2023 session can found : https://github.com/UofUEpiBio/epiworldR-workshop/tree/sunbetl2023-inperson","code":""},{"path":"/index.html","id":"epiworldr","dir":"","previous_headings":"","what":"Fast Agent-Based Epi Models","title":"Fast Agent-Based Epi Models","text":"R package wrapper C++ library epiworld. provides general framework modeling disease transmission using agent-based models. main features include: Fast simulation average 30 million agents/day per second. One model can include multiple diseases. Policies (tools) can multiple user-defined. Transmission can function agents’ features. ---box parallelization multiple simulations. package’s description: flexible framework Agent-Based Models (ABM), epiworldR package provides methods prototyping disease outbreaks transmission models using C++ backend, making fast. supports multiple epidemiological models, including Susceptible-Infected-Susceptible (SIS), Susceptible-Infected-Removed (SIR), Susceptible-Exposed-Infected-Removed (SEIR), others, involving arbitrary mitigation policies multiple-disease models. Users can specify infectiousness/susceptibility rates function agents’ features, providing great complexity model dynamics. Furthermore, epiworldR ideal simulation studies featuring large populations.","code":""},{"path":"/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Fast Agent-Based Epi Models","text":"can install development version epiworldR GitHub : CRAN","code":"devtools::install_github(\"UofUEpiBio/epiworldR\") install.packages(\"epiworldR\")"},{"path":"/index.html","id":"examples","dir":"","previous_headings":"","what":"Examples","title":"Fast Agent-Based Epi Models","text":"R package includes several popular epidemiological models including SIS, SIR, SEIR using either fully connected graph (similar compartmental model) user-defined network. examples:","code":""},{"path":"/index.html","id":"sir-model-using-a-random-graph","dir":"","previous_headings":"","what":"SIR model using a random graph","title":"Fast Agent-Based Epi Models","text":"Susceptible-Infected-Recovered model features population 100,000 agents simulated small-world network. agent connected ten agents. One percent population virus, 70% chance transmission. Infected individuals recover 0.3 rate: Visualizing outputs","code":"library(epiworldR) # Creating a SIR model sir <- ModelSIR( name = \"COVID-19\", prevalence = .01, transmission_rate = .7, recovery = .3 ) |> # Adding a Small world population agents_smallworld(n = 100000, k = 10, d = FALSE, p = .01) |> # Running the model for 50 days run(ndays = 50, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. sir #> ________________________________________________________________________________ #> Susceptible-Infected-Recovered (SIR) #> It features 100000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 822 Susceptible, 415 Infected, and 98763 Recovered. summary(sir) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Recovered (SIR) #> Population size : 100000 #> Agents' data : (none) #> Number of entities : 0 #> Days (duration) : 50 (of 50) #> Number of viruses : 1 #> Last run elapsed t : 193.00ms #> Last run speed : 25.77 million agents x day / second #> Rewiring : off #> #> Global actions: #> (none) #> #> Virus(es): #> - COVID-19 (baseline prevalence: 1.00%) #> #> Tool(s): #> (none) #> #> Model parameters: #> - Recovery rate : 0.3000 #> - Transmission rate : 0.7000 #> #> Distribution of the population at time 50: #> - (0) Susceptible : 99000 -> 822 #> - (1) Infected : 1000 -> 415 #> - (2) Recovered : 0 -> 98763 #> #> Transition Probabilities: #> - Susceptible 0.91 0.09 0.00 #> - Infected 0.00 0.70 0.30 #> - Recovered 0.00 0.00 1.00 plot(sir)"},{"path":"/index.html","id":"seir-model-with-a-fully-connected-graph","dir":"","previous_headings":"","what":"SEIR model with a fully connected graph","title":"Fast Agent-Based Epi Models","text":"SEIR model similar SIR model includes exposed state. , simulate population 10,000 agents 0.01 prevalence, 0.6 transmission rate, 0.5 recovery rate, 7 days-incubation period. population fully connected, meaning agents can transmit disease agent: Computing key statistics","code":"model_seirconn <- ModelSEIRCONN( name = \"COVID-19\", prevalence = 0.01, n = 10000, contact_rate = 4, incubation_days = 7, transmission_rate = 0.6, recovery_rate = 0.5 ) |> add_virus(virus(\"COVID-19\", 0.01, 0.6, 0.5, 7), .5) set.seed(132) run(model_seirconn, ndays = 100) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seirconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed (SEIR) (connected) #> It features 10000 agents, 2 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 608 Susceptible, 4 Exposed, 2 Infected, and 9386 Recovered. plot(model_seirconn) repnum <- get_reproductive_number(model_seirconn) head(plot(repnum)) #> virus_id virus date avg n sd lb ub #> 1 0 COVID-19 0 2.858974 78 2.592318 1 7.30 #> 2 0 COVID-19 2 1.964286 28 1.914509 0 5.65 #> 3 0 COVID-19 3 2.761905 21 2.321740 0 7.00 #> 4 0 COVID-19 4 2.000000 33 1.887459 0 6.40 #> 5 0 COVID-19 5 1.864865 37 2.225636 0 9.10 #> 6 0 COVID-19 6 2.104167 48 2.667692 0 10.65 plot_incidence(model_seirconn) head(plot_generation_time(model_seirconn)) #> date avg n sd ci_lower ci_upper virus virus_id #> 1 2 5.714286 21 4.681270 2 17.00 COVID-19 0 #> 2 3 7.444444 18 4.501271 2 15.45 COVID-19 0 #> 3 4 7.192308 26 5.578668 2 20.75 COVID-19 0 #> 4 5 7.111111 27 4.236593 2 15.70 COVID-19 0 #> 5 6 7.575000 40 7.249713 2 30.20 COVID-19 0 #> 6 7 6.303030 33 4.531038 2 18.00 COVID-19 0"},{"path":"/index.html","id":"sir-logit","dir":"","previous_headings":"","what":"SIR Logit","title":"Fast Agent-Based Epi Models","text":"model provides complex transmission recovery pattern based agents’ features. , can reflect co-morbidities change probability infection recovery. , simulate population including dataset two features: intercept binary variable Female. probability infection recovery functions intercept Female variables. following code simulates population 100,000 agents small-world network. agent connected eight agents. One percent population virus, 80% chance transmission. Infected individuals recover 0.3 rate:","code":"# Simulating a population of 100,000 agents set.seed(2223) n <- 100000 # Agents' features X <- cbind( Intercept = 1, Female = sample.int(2, n, replace = TRUE) - 1 ) coef_infect <- c(.1, -2, 2) coef_recover <- rnorm(2) # Creating the model model_logit <- ModelSIRLogit( \"covid2\", data = X, coefs_infect = coef_infect, coefs_recover = coef_recover, coef_infect_cols = 1L:ncol(X), coef_recover_cols = 1L:ncol(X), prob_infection = .8, recovery_rate = .3, prevalence = .01 ) # Adding a small-world population agents_smallworld(model_logit, n, 8, FALSE, .01) # Running the model run(model_logit, 50) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. plot(model_logit) # Females are supposed to be more likely to become infected rn <- get_reproductive_number(model_logit) (table( X[, \"Female\"], (1:n %in% rn$source) ) |> prop.table())[,2] #> 0 1 #> 0.12984 0.14201 # Looking into the agents get_agents(model_logit) #> Agents from the model \"Susceptible-Infected-Removed (SIR) (logit)\": #> Agent: 0, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 1, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 2, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 3, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 4, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 5, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 6, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 7, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 8, state: Susceptible (0), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 9, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> ... 99990 more agents ..."},{"path":"/index.html","id":"transmission-network","dir":"","previous_headings":"","what":"Transmission network","title":"Fast Agent-Based Epi Models","text":"example shows can draw transmission network simulation. following code simulates population 500 agents small-world network. agent connected ten agents. One percent population virus, 50% chance transmission. Infected individuals recover 0.5 rate:","code":"# Creating a SIR model sir <- ModelSIR( name = \"COVID-19\", prevalence = .01, transmission_rate = .5, recovery = .5 ) |> # Adding a Small world population agents_smallworld(n = 500, k = 10, d = FALSE, p = .01) |> # Running the model for 50 days run(ndays = 50, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. # Transmission network net <- get_transmissions(sir) # Plotting library(netplot) #> Loading required package: grid library(igraph) #> #> Attaching package: 'igraph' #> The following object is masked from 'package:netplot': #> #> ego #> The following objects are masked from 'package:stats': #> #> decompose, spectrum #> The following object is masked from 'package:base': #> #> union x <- graph_from_edgelist(as.matrix(net[,2:3]) + 1) nplot(x, edge.curvature = 0, edge.color = \"gray\", skip.vertex=TRUE)"},{"path":"/index.html","id":"multiple-simulations","dir":"","previous_headings":"","what":"Multiple simulations","title":"Fast Agent-Based Epi Models","text":"epiworldR supports running multiple simulations using run_multiple function. following code simulates 50 SIR models 1000 agents . agent connected ten agents. One percent population virus, 90% chance transmission. Infected individuals recover 0.1 rate. results saved data.frame: # Existing Alternatives Several alternatives epiworldR exist provide researchers range options, unique features strengths, enabling exploration analysis infectious disease dynamics agent-based modeling. manually curated table existing alternatives including ABM [@ABM], abmR [@abmR], cystiSim [@cystiSim], villager [@villager], RNetLogo [@RNetLogo].","code":"model_sir <- ModelSIRCONN( name = \"COVID-19\", prevalence = 0.01, n = 1000, contact_rate = 2, transmission_rate = 0.9, recovery_rate = 0.1 ) # Generating a saver saver <- make_saver(\"total_hist\", \"reproductive\") # Running and printing # Notice the use of nthread = 2 to run the simulations in parallel run_multiple(model_sir, ndays = 100, nsims = 50, saver = saver, nthread = 2) #> Starting multiple runs (50) using 2 thread(s) #> _________________________________________________________________________ #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Retrieving the results ans <- run_multiple_get_results(model_sir) head(ans$total_hist) #> sim_num date nviruses state counts #> 1 1 0 1 Susceptible 990 #> 2 1 0 1 Infected 10 #> 3 1 0 1 Recovered 0 #> 4 1 1 1 Susceptible 974 #> 5 1 1 1 Infected 25 #> 6 1 1 1 Recovered 1 head(ans$reproductive) #> sim_num virus_id virus source source_exposure_date rt #> 1 1 0 COVID-19 767 11 0 #> 2 1 0 COVID-19 835 10 0 #> 3 1 0 COVID-19 466 9 0 #> 4 1 0 COVID-19 612 9 0 #> 5 1 0 COVID-19 793 9 0 #> 6 1 0 COVID-19 20 8 0 plot(ans$reproductive)"},{"path":"/index.html","id":"other-abm-r-packages","dir":"","previous_headings":"","what":"Other ABM R packages","title":"Fast Agent-Based Epi Models","text":"may want check R packages agent-based modeling: ABM, abmR, cystiSim, villager, RNetLogo.","code":""},{"path":"/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Fast Agent-Based Epi Models","text":"Please note epiworldR project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"/paper.html","id":null,"dir":"","previous_headings":"","what":"Introduction","title":"Introduction","text":"Agent-based modeling (ABM) emerged powerful computational approach studying complex systems across various fields, including social sciences epidemiology. simulating interactions behaviors individual entities, known agents, ABM provides unique lens researchers can analyze understand emergent properties dynamics systems. epiworldR package provides flexible framework ABM implementation methods prototyping disease outbreaks transmission models using C++ backend. supports multiple epidemiological models, including Susceptible-Infected-Susceptible (SIS), Susceptible-Infected-Removed (SIR), Susceptible-Exposed-Infected-Removed (SEIR), others, involving arbitrary mitigation policies multiple-disease models. Users can specify transmission/susceptibility rates function agents’ features, providing great complexity model dynamics.","code":""},{"path":"/paper.html","id":"key-features","dir":"","previous_headings":"","what":"Key Features","title":"Introduction","text":"Built robust foundation C++, package combines efficient computation flexibility R, providing seamless user experience several standout features: Multiple Viruses - feature allows researchers simulate analyze dynamics various infectious diseases simultaneously. Multiple Tools - capability enables users design model objects may reflect real-world interventions. Examples include vaccines, mask wearing protocols, social distancing, much . Multiple Runs - epiworldR ability run simulations multiple times, providing complete picture simulation results behaviors. Global Actions - Similar adding multiple tools, global actions allow users implement interventions policies global scale point simulation, mimicking real-world scenarios aiding assessment impact. Built-Epidemiological Models - feature ensures researchers access well-established widely recognized frameworks, making easier compare benchmark results. Included popular epidemiological models : SIR, SIS, SEIR, SIR connected, SIS connected, SEIR connected, . extensive range features, epiworldR empowers researchers practitioners field epidemiology conduct thorough analyses, make informed decisions, contribute advancement public health.","code":""},{"path":"/paper.html","id":"existing-alternatives","dir":"","previous_headings":"","what":"Existing Alternatives","title":"Introduction","text":"Several alternatives epiworldR exist provide researchers range options, unique features strengths, enabling exploration analysis infectious disease dynamics agent-based modeling. manually curated table existing alternatives including ABM [@ABM], abmR [@abmR], cystiSim [@cystiSim], villager [@villager], RNetLogo [@RNetLogo].","code":""},{"path":"/paper.html","id":"statement-of-need","dir":"","previous_headings":"","what":"Statement of Need","title":"Introduction","text":"epiworldR package addresses need sophisticated epidemiological research offering user-friendly agent-based modeling (ABM) tool simulating analyzing infectious disease dynamics. caters diverse audience researchers, epidemiologists, public health practitioners, social scientists, policymakers, enabling study complex disease spread patterns, evaluate intervention strategies, prepare emerging pathogens. Unlike traditional epidemiological models, epiworldR’s ABM approach captures individual-level behaviors interactions, providing realistic representation disease dynamics. distinction sets apart compartmental models ABM frameworks, making epiworldR valuable accessible tool advancing infectious disease modeling enhancing outbreak preparedness.","code":""},{"path":"/paper.html","id":"conclusion","dir":"","previous_headings":"","what":"Conclusion","title":"Introduction","text":"development epiworldR package ushered new era agent-based modeling field social science epidemiology. harnessing power C++ flexibility R, comprehensive package offers multitude features enhance modeling analysis complex infectious disease dynamics. package’s ability handle multiple viruses tools, diverse set epidemiological models, capability run simulations multiple times, inclusion global actions capability empower researchers explore wide range scenarios make informed decisions regarding public health interventions. epiworldR serves valuable resource social science epidemiological communities, enabling study real-world phenomena, prediction outcomes, policy analysis. field epidemiology continues evolve, epiworldR stands forefront, providing researchers practitioners powerful tool navigate complexities infectious diseases contribute improvement global health outcomes.","code":""},{"path":[]},{"path":"/reference/ModelDiffNet.html","id":null,"dir":"Reference","previous_headings":"","what":"Network Diffusion Model — ModelDiffNet","title":"Network Diffusion Model — ModelDiffNet","text":"network diffusion model simple model assumes probability adoption behavior proportional number adopters network.","code":""},{"path":"/reference/ModelDiffNet.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Network Diffusion Model — ModelDiffNet","text":"","code":"ModelDiffNet( name, prevalence, prob_adopt, normalize_exposure = TRUE, data = matrix(nrow = 0, ncol = 0), data_cols = 1L:ncol(data), params = vector(\"double\") ) # S3 method for epiworld_diffnet plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelDiffNet.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Network Diffusion Model — ModelDiffNet","text":"name Name model. prevalence Prevalence disease. prob_adopt Probability adoption. normalize_exposure Normalize exposure. data Data. data_cols Data columns. params Parameters. x Object class epiworld_diffnet. main Title plot ... Passed graphics::plot.","code":""},{"path":"/reference/ModelDiffNet.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Network Diffusion Model — ModelDiffNet","text":"object class epiworld_diffnet epiworld_model.","code":""},{"path":"/reference/ModelDiffNet.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Network Diffusion Model — ModelDiffNet","text":"Different common epidemiological models, network diffusion model assumes probability adoption behavior proportional number adopters network. model defined following equations: $$ P(adopt) = \\mbox{Logit}^{-1}(prob\\_adopt + params * data + exposure) $$ exposure number adopters agent's network. Another important difference transmission network necesary useful since adoption model particular neighbor.","code":""},{"path":[]},{"path":"/reference/ModelDiffNet.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Network Diffusion Model — ModelDiffNet","text":"","code":"set.seed(2223) n <- 10000 # Generating synthetic data on a matrix with 2 columns. X <- cbind( age = sample(1:100, n, replace = TRUE), female = sample.int(2, n, replace = TRUE) - 1 ) adopt_chatgpt <- ModelDiffNet( \"ChatGPT\", prevalence = .01, prob_adopt = .1, data = X, params = c(1, 4) ) # Simulating a population from smallworld agents_smallworld(adopt_chatgpt, n, 8, FALSE, .01) # Running the model for 50 steps run(adopt_chatgpt, 50) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. # Plotting the model plot(adopt_chatgpt)"},{"path":"/reference/ModelSEIR.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"Susceptible Exposed Infected Recovered model (SEIR)","code":""},{"path":"/reference/ModelSEIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"","code":"ModelSEIR(name, prevalence, transmission_rate, incubation_days, recovery_rate) # S3 method for epiworld_seir plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSEIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"name String. Name virus. prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. incubation_days Numeric scalar greater 0. Average number incubation days. recovery_rate Numeric scalar 0 1. Rate recovery_rate virus. x Object class SEIR. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSEIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"ModelSEIRfunction returns model class epiworld_model. plot function returns plot SEIR model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSEIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"","code":"model_seir <- ModelSEIR(name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1, incubation_days = 4) # Adding a small world population agents_smallworld( model_seir, n = 1000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_seir, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seir #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed (SEIR) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 0 Susceptible, 0 Exposed, 7 Infected, and 993 Removed. plot(model_seir, main = \"SEIR Model\")"},{"path":"/reference/ModelSEIRCONN.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","title":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","text":"SEIR connected model implements model agents connected. equivalent compartmental model (wiki).","code":""},{"path":"/reference/ModelSEIRCONN.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","text":"","code":"ModelSEIRCONN( name, n, prevalence, contact_rate, transmission_rate, incubation_days, recovery_rate ) # S3 method for epiworld_seirconn plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSEIRCONN.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","text":"name String. Name virus. n Number individuals population. prevalence Initial proportion individuals virus. contact_rate Numeric scalar. Average number contacts per step. transmission_rate Numeric scalar 0 1. Probability transmission. incubation_days Numeric scalar greater 0. Average number incubation days. recovery_rate Numeric scalar 0 1. Probability recovery_rate. x Object class SEIRCONN. main Title plot. ... Currently ignore.","code":""},{"path":"/reference/ModelSEIRCONN.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","text":"ModelSEIRCONNfunction returns model class epiworld_model. plot function returns plot SEIRCONN model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSEIRCONN.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Exposed Infected Removed model (SEIR connected) — ModelSEIRCONN","text":"","code":"# An example with COVID-19 model_seirconn <- ModelSEIRCONN( name = \"COVID-19\", prevalence = 0.01, n = 10000, contact_rate = 2, incubation_days = 7, transmission_rate = 0.5, recovery_rate = 0.3 ) # Running and printing run(model_seirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seirconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed (SEIR) (connected) #> It features 10000 agents, 1 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 430 Susceptible, 0 Exposed, 6 Infected, and 9564 Recovered. plot(model_seirconn) # Adding the flu flu <- virus(\"Flu\", .9, 1/7) add_virus(model_seirconn, flu, .001) #' # Running and printing run(model_seirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seirconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed (SEIR) (connected) #> It features 10000 agents, 2 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 3 Susceptible, 0 Exposed, 0 Infected, and 9997 Recovered. plot(model_seirconn)"},{"path":"/reference/ModelSEIRD.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD)","code":""},{"path":"/reference/ModelSEIRD.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"","code":"ModelSEIRD( name, prevalence, transmission_rate, incubation_days, recovery_rate, death_rate ) # S3 method for epiworld_seird plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSEIRD.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"name String. Name virus. prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. incubation_days Numeric scalar greater 0. Average number incubation days. recovery_rate Numeric scalar 0 1. Rate recovery_rate virus. death_rate Numeric scalar 0 1. Rate death virus. x Object class SEIRD. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSEIRD.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"ModelSEIRDfunction returns model class epiworld_model. plot function returns plot SEIRD model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSEIRD.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"","code":"model_seird <- ModelSEIRD(name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1, incubation_days = 4, death_rate = 0.01) # Adding a small world population agents_smallworld( model_seird, n = 100000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_seird, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seird #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed-Deceased (SEIRD) #> It features 100000 agents, 1 virus(es), and 0 tool(s). #> The model has 5 states. #> The final distribution is: 1979 Susceptible, 394 Exposed, 898 Infected, 91290 Removed, and 5439 Deceased. plot(model_seird, main = \"SEIRD Model\")"},{"path":"/reference/ModelSEIRDCONN.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"SEIRD connected model implements model agents connected. equivalent compartmental model (wiki).","code":""},{"path":"/reference/ModelSEIRDCONN.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"","code":"ModelSEIRDCONN( name, n, prevalence, contact_rate, transmission_rate, incubation_days, recovery_rate, death_rate ) # S3 method for epiworld_seirdconn plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSEIRDCONN.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"name String. Name virus. n Number individuals population. prevalence Initial proportion individuals virus. contact_rate Numeric scalar. Average number contacts per step. transmission_rate Numeric scalar 0 1. Probability transmission. incubation_days Numeric scalar greater 0. Average number incubation days. recovery_rate Numeric scalar 0 1. Probability recovery_rate. death_rate Numeric scalar 0 1. Probability death. x Object class SEIRCONN. main Title plot. ... Currently ignore.","code":""},{"path":"/reference/ModelSEIRDCONN.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"ModelSEIRDCONNfunction returns model class epiworld_model. plot function returns plot SEIRDCONN model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSEIRDCONN.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"","code":"# An example with COVID-19 model_seirdconn <- ModelSEIRDCONN( name = \"COVID-19\", prevalence = 0.01, n = 10000, contact_rate = 2, incubation_days = 7, transmission_rate = 0.5, recovery_rate = 0.3, death_rate = 0.01 ) # Running and printing run(model_seirdconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seirdconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed-Deceased (SEIRD) (connected) #> It features 10000 agents, 1 virus(es), and 0 tool(s). #> The model has 5 states. #> The final distribution is: 439 Susceptible, 0 Exposed, 3 Infected, 9326 Removed, and 232 Deceased. plot(model_seirdconn) # Adding the flu flu <- virus(\"Flu\", prob_infecting = .3, recovery_rate = 1/7, prob_death = 0.001) add_virus(model = model_seirdconn, virus = flu, proportion = .001) #' # Running and printing run(model_seirdconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_seirdconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed-Deceased (SEIRD) (connected) #> It features 10000 agents, 2 virus(es), and 0 tool(s). #> The model has 5 states. #> The final distribution is: 410 Susceptible, 7 Exposed, 4 Infected, 9384 Removed, and 195 Deceased. plot(model_seirdconn)"},{"path":"/reference/ModelSIR.html","id":null,"dir":"Reference","previous_headings":"","what":"SIR model — ModelSIR","title":"SIR model — ModelSIR","text":"SIR model","code":""},{"path":"/reference/ModelSIR.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SIR model — ModelSIR","text":"","code":"ModelSIR(name, prevalence, transmission_rate, recovery_rate) # S3 method for epiworld_sir plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIR.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SIR model — ModelSIR","text":"name String. Name virus prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. recovery_rate Numeric scalar 0 1. Rate recovery_rate virus. x Object class SIR. main Title plot ... Additional arguments passed graphics::plot.","code":""},{"path":"/reference/ModelSIR.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SIR model — ModelSIR","text":"ModelSIR function returns model class epiworld_model. plot function returns plot SIR model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIR.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SIR model — ModelSIR","text":"","code":"model_sir <- ModelSIR(name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1) # Adding a small world population agents_smallworld( model_sir, n = 1000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_sir, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sir #> ________________________________________________________________________________ #> Susceptible-Infected-Recovered (SIR) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 0 Susceptible, 9 Infected, and 991 Recovered. # Plotting plot(model_sir)"},{"path":"/reference/ModelSIRCONN.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"Susceptible Infected Removed model (SIR connected)","code":""},{"path":"/reference/ModelSIRCONN.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"","code":"ModelSIRCONN( name, n, prevalence, contact_rate, transmission_rate, recovery_rate ) # S3 method for epiworld_sirconn plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIRCONN.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"name String. Name virus n Number individuals population. prevalence Double. Initial proportion individuals virus. contact_rate Numeric scalar. Average number contacts per step. transmission_rate Numeric scalar 0 1. Probability transmission. recovery_rate Numeric scalar 0 1. Probability recovery. x Object class SIRCONN. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSIRCONN.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"ModelSIRCONNfunction returns model class epiworld_model. plot function returns plot SIRCONN model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIRCONN.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"","code":"model_sirconn <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) # Running and printing run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sirconn #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 10000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 2000 Susceptible, 0 Infected, and 8000 Recovered. plot(model_sirconn, main = \"SIRCONN Model\")"},{"path":"/reference/ModelSIRD.html","id":null,"dir":"Reference","previous_headings":"","what":"SIRD model — ModelSIRD","title":"SIRD model — ModelSIRD","text":"SIRD model","code":""},{"path":"/reference/ModelSIRD.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SIRD model — ModelSIRD","text":"","code":"ModelSIRD(name, prevalence, transmission_rate, recovery_rate, death_rate) # S3 method for epiworld_sird plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIRD.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SIRD model — ModelSIRD","text":"name String. Name virus prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. recovery_rate Numeric scalar 0 1. Rate recovery_rate virus. death_rate Numeric scalar 0 1. Rate death virus. x Object class SIR. main Title plot ... Additional arguments passed graphics::plot.","code":""},{"path":"/reference/ModelSIRD.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SIRD model — ModelSIRD","text":"ModelSIRD function returns model class epiworld_model. plot function returns plot SIRD model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIRD.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SIRD model — ModelSIRD","text":"","code":"model_sird <- ModelSIRD( name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1, death_rate = 0.01 ) # Adding a small world population agents_smallworld( model_sird, n = 1000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_sird, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sird #> ________________________________________________________________________________ #> Susceptible-Infected-Recovered-Deceased (SIRD) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 0 Susceptible, 5 Infected, 912 Recovered, and 83 Deceased. # Plotting plot(model_sird)"},{"path":"/reference/ModelSIRDCONN.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"Susceptible Infected Removed Deceased model (SIRD connected)","code":""},{"path":"/reference/ModelSIRDCONN.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"","code":"ModelSIRDCONN( name, n, prevalence, contact_rate, transmission_rate, recovery_rate, death_rate ) # S3 method for epiworld_sirdconn plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIRDCONN.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"name String. Name virus n Number individuals population. prevalence Double. Initial proportion individuals virus. contact_rate Numeric scalar. Average number contacts per step. transmission_rate Numeric scalar 0 1. Probability transmission. recovery_rate Numeric scalar 0 1. Probability recovery. death_rate Numeric scalar 0 1. Probability death. x Object class SIRDCONN. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSIRDCONN.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"ModelSIRDCONNfunction returns model class epiworld_model. plot function returns plot SIRDCONN model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIRDCONN.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"","code":"model_sirdconn <- ModelSIRDCONN( name = \"COVID-19\", n = 100000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.5, death_rate = 0.1 ) # Running and printing run(model_sirdconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sirdconn #> ________________________________________________________________________________ #> Susceptible-Infected-Removed-Deceased (SIRD) (connected) #> It features 100000 agents, 1 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 3778 Susceptible, 0 Infected, 86521 Recovered, and 9701 Deceased. plot(model_sirdconn, main = \"SIRDCONN Model\")"},{"path":"/reference/ModelSIRLogit.html","id":null,"dir":"Reference","previous_headings":"","what":"SIR Logistic model — ModelSIRLogit","title":"SIR Logistic model — ModelSIRLogit","text":"SIR Logistic model","code":""},{"path":"/reference/ModelSIRLogit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SIR Logistic model — ModelSIRLogit","text":"","code":"ModelSIRLogit( vname, data, coefs_infect, coefs_recover, coef_infect_cols, coef_recover_cols, prob_infection, recovery_rate, prevalence )"},{"path":"/reference/ModelSIRLogit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SIR Logistic model — ModelSIRLogit","text":"vname Name virus. data numeric matrix n rows. coefs_infect Numeric vector. Coefficients associated infect. coefs_recover Numeric vector. Coefficients associated recover. coef_infect_cols Integer vector. Columns coeficient. coef_recover_cols Integer vector. Columns coeficient. prob_infection Numeric scalar. Baseline probability infection. recovery_rate Numeric scalar. Baseline probability recovery. prevalence Numeric scalar. Prevalence (initial state) proportion.","code":""},{"path":"/reference/ModelSIRLogit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SIR Logistic model — ModelSIRLogit","text":"ModelSIRLogit function returns model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIRLogit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SIR Logistic model — ModelSIRLogit","text":"","code":"set.seed(2223) n <- 100000 # Creating the data to use for the \"ModelSIRLogit\" function. It contains # information on the sex of each agent and will be used to determine # differences in disease progression between males and females. Note that # the number of rows in these data are identical to n (100000). X <- cbind( Intercept = 1, Female = sample.int(2, n, replace = TRUE) - 1 ) # Declare coefficients for each sex regarding transmission_rate and recovery. coef_infect <- c(.1, -2, 2) coef_recover <- rnorm(2) # Feed all above information into the \"ModelSIRLogit\" function. model_logit <- ModelSIRLogit( \"covid2\", data = X, coefs_infect = coef_infect, coefs_recover = coef_recover, coef_infect_cols = 1L:ncol(X), coef_recover_cols = 1L:ncol(X), prob_infection = .8, recovery_rate = .3, prevalence = .01 ) agents_smallworld(model_logit, n, 8, FALSE, .01) run(model_logit, 50) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. plot(model_logit) # Females are supposed to be more likely to become infected. rn <- get_reproductive_number(model_logit) # Probability of infection for males and females. (table( X[, \"Female\"], (1:n %in% rn$source) ) |> prop.table())[,2] #> 0 1 #> 0.12984 0.14201 # Looking into the individual agents. get_agents(model_logit) #> Agents from the model \"Susceptible-Infected-Removed (SIR) (logit)\": #> Agent: 0, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 1, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 2, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 3, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 4, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 5, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 6, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 7, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 8, state: Susceptible (0), Nvirus: 0, NTools: 0, NNeigh: 8 #> Agent: 9, state: Recovered (2), Nvirus: 0, NTools: 0, NNeigh: 8 #> ... 99990 more agents ..."},{"path":"/reference/ModelSIS.html","id":null,"dir":"Reference","previous_headings":"","what":"SIS model — ModelSIS","title":"SIS model — ModelSIS","text":"Susceptible-Infected-Susceptible model (SIS) (wiki)","code":""},{"path":"/reference/ModelSIS.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SIS model — ModelSIS","text":"","code":"ModelSIS(name, prevalence, transmission_rate, recovery_rate) # S3 method for epiworld_sis plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIS.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SIS model — ModelSIS","text":"name String. Name virus. prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. recovery_rate Numeric scalar 0 1. Rate recovery virus. x Object class SIS. main Title plot. ... Currently ignore.","code":""},{"path":"/reference/ModelSIS.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SIS model — ModelSIS","text":"ModelSIS function returns model class epiworld_model. plot function returns plot SIS model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSIS.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SIS model — ModelSIS","text":"","code":"model_sis <- ModelSIS(name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1) # Adding a small world population agents_smallworld( model_sis, n = 1000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_sis, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sis #> ________________________________________________________________________________ #> Susceptible-Infected-Susceptible (SIS) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 2 states. #> The final distribution is: 100 Susceptible, and 900 Infected. # Plotting plot(model_sis, main = \"SIS Model\")"},{"path":"/reference/ModelSISD.html","id":null,"dir":"Reference","previous_headings":"","what":"SISD model — ModelSISD","title":"SISD model — ModelSISD","text":"Susceptible-Infected-Susceptible-Deceased model (SISD) (wiki)","code":""},{"path":"/reference/ModelSISD.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SISD model — ModelSISD","text":"","code":"ModelSISD(name, prevalence, transmission_rate, recovery_rate, death_rate) # S3 method for epiworld_sisd plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSISD.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SISD model — ModelSISD","text":"name String. Name virus. prevalence Double. Initial proportion individuals virus. transmission_rate Numeric scalar 0 1. Virus's rate infection. recovery_rate Numeric scalar 0 1. Rate recovery virus. death_rate Numeric scalar 0 1. Rate death virus. x Object class SISD. main Title plot. ... Currently ignore.","code":""},{"path":"/reference/ModelSISD.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SISD model — ModelSISD","text":"ModelSISD function returns model class epiworld_model. plot function returns plot SISD model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSISD.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SISD model — ModelSISD","text":"","code":"model_sisd <- ModelSISD( name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1, death_rate = 0.01 ) # Adding a small world population agents_smallworld( model_sisd, n = 1000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_sisd, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sisd #> ________________________________________________________________________________ #> Susceptible-Infected-Susceptible-Deceased (SISD) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 52 Susceptible, 490 Infected, and 458 Deceased. # Plotting plot(model_sisd, main = \"SISD Model\")"},{"path":"/reference/ModelSURV.html","id":null,"dir":"Reference","previous_headings":"","what":"SURV model — ModelSURV","title":"SURV model — ModelSURV","text":"SURV model","code":""},{"path":"/reference/ModelSURV.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"SURV model — ModelSURV","text":"","code":"ModelSURV( name, prevalence, efficacy_vax, latent_period, infect_period, prob_symptoms, prop_vaccinated, prop_vax_redux_transm, prop_vax_redux_infect, surveillance_prob, transmission_rate, prob_death, prob_noreinfect ) # S3 method for epiworld_surv plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSURV.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"SURV model — ModelSURV","text":"name String. Name virus. prevalence Initial number individuals virus. efficacy_vax Double. Efficacy vaccine. (1 - P(acquire disease)). latent_period Double. Shape parameter 'Gamma(latent_period, 1)' distribution. coincides expected number latent days. infect_period Double. Shape parameter 'Gamma(infected_period, 1)' distribution. coincides expected number infectious days. prob_symptoms Double. Probability generating symptoms. prop_vaccinated Double. Probability vaccination. Coincides initial prevalence vaccinated individuals. prop_vax_redux_transm Double. Factor vaccine reduces transmissibility. prop_vax_redux_infect Double. Factor vaccine reduces chances becoming infected. surveillance_prob Double. Probability testing agent. transmission_rate Double. Raw transmission probability. prob_death Double. Raw probability death symptomatic individuals. prob_noreinfect Double. Probability re-infection. x Object class SURV. main Title plot. ... Currently ignore.","code":""},{"path":"/reference/ModelSURV.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"SURV model — ModelSURV","text":"ModelSURVfunction returns model class epiworld_model. plot function returns plot SURV model class epiworld_model.","code":""},{"path":[]},{"path":"/reference/ModelSURV.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"SURV model — ModelSURV","text":"","code":"model_surv <- ModelSURV( name = \"COVID-19\", prevalence = 20, efficacy_vax = 0.6, latent_period = 4, infect_period = 5, prob_symptoms = 0.5, prop_vaccinated = 0.7, prop_vax_redux_transm = 0.8, prop_vax_redux_infect = 0.95, surveillance_prob = 0.1, transmission_rate = 0.2, prob_death = 0.001, prob_noreinfect = 0.5 ) # Adding a small world population agents_smallworld( model_surv, n = 10000, k = 5, d = FALSE, p = .01 ) # Running and printing run(model_surv, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_surv #> ________________________________________________________________________________ #> Surveillance #> It features 10000 agents, 1 virus(es), and 1 tool(s). #> The model has 8 states. #> The final distribution is: 9978 Susceptible, 0 Latent, 0 Symptomatic, 0 Symptomatic isolated, 0 Asymptomatic, 0 Asymptomatic isolated, 22 Recovered, and 0 Removed. # Plotting plot(model_surv, main = \"SURV Model\")"},{"path":"/reference/agents_smallworld.html","id":null,"dir":"Reference","previous_headings":"","what":"Load agents to a model — agents_smallworld","title":"Load agents to a model — agents_smallworld","text":"functions provide access network model. network represented edgelist. agents_smallworld function generates small world network Watts-Strogatz algorithm. agents_from_edgelist function loads network edgelist. get_network function returns edgelist network.","code":""},{"path":"/reference/agents_smallworld.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load agents to a model — agents_smallworld","text":"","code":"agents_smallworld(model, n, k, d, p) agents_from_edgelist(model, source, target, size, directed) get_network(model) get_agents_states(model) add_virus_agent(agent, model, virus, state_new = -99, queue = -99) add_tool_agent(agent, model, tool, state_new = -99, queue = -99) has_virus(agent, virus) has_tool(agent, tool) change_state(agent, model, state_new, queue = -99) get_agents_tools(model) get_agents_viruses(model)"},{"path":"/reference/agents_smallworld.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load agents to a model — agents_smallworld","text":"model Model object class epiworld_model. n, size Number individuals population. k Number ties small world network. d, directed Logical scalar. Whether graph directed . p Probability rewiring. source, target Integer vectors describing source target edgelist. agent Agent object class epiworld_agent. virus Virus object class epiworld_virus. state_new Integer scalar. New state agent action executed. queue Integer scalar. Change queuing system action executed. tool Tool object class epiworld_tool.","code":""},{"path":"/reference/agents_smallworld.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load agents to a model — agents_smallworld","text":"'agents_smallworld' function returns model agents loaded. agents_from_edgelist function returns empty model class epiworld_model. get_network function returns data frame two columns (source target) describing edgelist network. get_agents_states returns character vector states agents end simulation. function add_virus_agent adds virus agent returns agent invisibly. function add_tool_agent adds tool agent returns agent invisibly. functions has_virus has_tool return logical scalar indicating whether agent virus/tool . get_agents_tools returns list class epiworld_agents_tools epiworld_tools (list lists). get_agents_viruses returns list class epiworld_agents_viruses epiworld_viruses (list lists).","code":""},{"path":"/reference/agents_smallworld.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Load agents to a model — agents_smallworld","text":"new_state queue parameters optional. provided, agent updated default values virus/tool.","code":""},{"path":"/reference/agents_smallworld.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Load agents to a model — agents_smallworld","text":"","code":"# Initializing SIR model with agents_smallworld sir <- ModelSIR(name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1) agents_smallworld( sir, n = 1000, k = 5, d = FALSE, p = .01 ) run(sir, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. sir #> ________________________________________________________________________________ #> Susceptible-Infected-Recovered (SIR) #> It features 1000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 0 Susceptible, 9 Infected, and 991 Recovered. # We can also retrieve the network net <- get_network(sir) head(net) #> from to #> 1 0 1 #> 2 0 2 #> 3 0 998 #> 4 0 999 #> 5 1 2 #> 6 1 3 # Simulating a bernoulli graph set.seed(333) n <- 1000 g <- matrix(runif(n ^ 2) < .01, nrow = n) diag(g) <- FALSE el <- which(g, arr.ind = TRUE) - 1L # Generating an empty model sir <- ModelSIR(\"COVID-19\", .01, .8, .3) agents_from_edgelist( sir, source = el[,1], target = el[,2], size = n, directed = TRUE ) # Running the simulation run(sir, 50) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. plot(sir)"},{"path":"/reference/epiworld-data.html","id":null,"dir":"Reference","previous_headings":"","what":"Accessing the database of epiworld — epiworld-data","title":"Accessing the database of epiworld — epiworld-data","text":"Models epiworld stored database. database can accessed using functions described manual page. elements database : transition matrix, incidence matrix, reproductive number, generation time, daily incidence virus tool level.","code":""},{"path":"/reference/epiworld-data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Accessing the database of epiworld — epiworld-data","text":"","code":"get_hist_total(x) get_today_total(x) get_hist_virus(x) get_hist_tool(x) get_transition_probability(x) get_reproductive_number(x) # S3 method for epiworld_repnum plot( x, y = NULL, ylab = \"Average Rep. Number\", xlab = \"Day (step)\", main = \"Reproductive Number\", type = \"b\", plot = TRUE, ... ) plot_reproductive_number(x, ...) get_hist_transition_matrix(x, skip_zeros = FALSE) # S3 method for epiworld_hist_transition as.array(x, ...) plot_incidence(x, ...) # S3 method for epiworld_hist_transition plot( x, type = \"b\", xlab = \"Day (step)\", ylab = \"Counts\", main = \"Daily incidence\", plot = TRUE, ... ) get_transmissions(x) get_generation_time(x) # S3 method for epiworld_generation_time plot( x, type = \"b\", xlab = \"Day (step)\", ylab = \"Avg. Generation Time\", main = \"Generation Time\", plot = TRUE, ... ) plot_generation_time(x, ...)"},{"path":"/reference/epiworld-data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Accessing the database of epiworld — epiworld-data","text":"x object class epiworld_sir, epiworld_seir, etc. model. y Ignored. ylab, xlab, main, type parameters passed graphics::plot() plot Logical scalar. TRUE (default), function desired statistic. ... case plot methods, arguments passed graphics::plot. skip_zeros Logical scalar. FALSE return entries transition matrix.","code":""},{"path":"/reference/epiworld-data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Accessing the database of epiworld — epiworld-data","text":"get_hist_total function returns object class epiworld_hist_total. get_today_total function returns named vector total number individuals state end simulation. get_hist_virus function returns object class epiworld_hist_virus. get_hist_tool function returns object epiworld_hist_virus. get_transition_probability function returns object class matrix. get_reproductive_number function returns object class epiworld_repnum. plot function returns plot reproductive number time. get_hist_transition_matrix returns data.frame four columns: \"state_from\", \"state_to\", \"date\", \"counts.\" .array method epiworld_hist_transition objects turns data.frame returned get_hist_transition_matrix array nstates x nstates x (ndays + 1) entries, first entry initial state. plot_incidence function returns plot originating object get_hist_transition_matrix. plot function returns plot originates epiworld_hist_transition object. function get_transmissions returns data.frame following columns: date, source, target, virus_id, virus, source_exposure_date. function get_generation_time returns data.frame following columns: \"agent\", \"virus_id\", \"virus\", \"date\", \"gentime\". function plot_generation_time wrapper plot get_generation_time.","code":""},{"path":"/reference/epiworld-data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Accessing the database of epiworld — epiworld-data","text":"plot_reproductive_number function wrapper around get_reproductive_number plots result. plot_incidence function wrapper get_hist_transition_matrix plot method. plot method epiworld_hist_transition class plots daily incidence state. function returns data frame used plotting.","code":""},{"path":[]},{"path":"/reference/epiworld-data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Accessing the database of epiworld — epiworld-data","text":"","code":"# SEIR Connected seirconn <- ModelSEIRCONN( name = \"Disease\", n = 10000, prevalence = 0.1, contact_rate = 2.0, transmission_rate = 0.8, incubation_days = 7.0, recovery_rate = 0.3 ) # Running the simulation for 50 steps (days) set.seed(937) run(seirconn, 50) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. # Retrieving the transition probability get_transition_probability(seirconn) #> Susceptible Exposed Infected Recovered #> Susceptible 0.9001378 0.09986219 0.0000000 0.0000000 #> Exposed 0.0000000 0.85468656 0.1453134 0.0000000 #> Infected 0.0000000 0.00000000 0.7024578 0.2975422 #> Recovered 0.0000000 0.00000000 0.0000000 1.0000000 # Retrieving date, state, and counts dataframe including any added tools get_hist_tool(seirconn) #> [1] date tool_id tool state counts #> <0 rows> (or 0-length row.names) # Retrieving overall date, state, and counts dataframe head(get_hist_total(seirconn)) #> date state counts #> 1 0 Susceptible 9000 #> 2 0 Exposed 1000 #> 3 0 Infected 0 #> 4 0 Recovered 0 #> 5 1 Susceptible 9000 #> 6 1 Exposed 859 # Retrieving date, state, and counts dataframe by variant head(get_hist_virus(seirconn)) #> date virus_id virus state counts #> 1 0 0 Disease Susceptible 0 #> 2 0 0 Disease Exposed 1000 #> 3 0 0 Disease Infected 0 #> 4 0 0 Disease Recovered 0 #> 5 1 0 Disease Susceptible 0 #> 6 1 0 Disease Exposed 859 # Retrieving (and plotting) the reproductive number rp <- get_reproductive_number(seirconn) plot(rp) # Also equivalent to plot_reproductive_number(seirconn) # We can go further and get all the history t_hist <- get_hist_transition_matrix(seirconn) head(t_hist) #> state_from state_to date counts #> 1 Susceptible Susceptible 0 9000 #> 2 Exposed Susceptible 0 0 #> 3 Infected Susceptible 0 0 #> 4 Recovered Susceptible 0 0 #> 5 Susceptible Exposed 0 1000 #> 6 Exposed Exposed 0 0 # And turn it into an array as.array(t_hist)[,,1:3] #> , , 0 #> #> Susceptible Exposed Infected Recovered #> Susceptible 9000 1000 0 0 #> Exposed 0 0 0 0 #> Infected 0 0 0 0 #> Recovered 0 0 0 0 #> #> , , 1 #> #> Susceptible Exposed Infected Recovered #> Susceptible 9000 0 0 0 #> Exposed 0 859 141 0 #> Infected 0 0 0 0 #> Recovered 0 0 0 0 #> #> , , 2 #> #> Susceptible Exposed Infected Recovered #> Susceptible 8805 195 0 0 #> Exposed 0 753 106 0 #> Infected 0 0 95 46 #> Recovered 0 0 0 0 #> # We cam also get (and plot) the incidence, as well as # the generation time inci <- plot_incidence(seirconn) gent <- plot_generation_time(seirconn)"},{"path":"/reference/epiworld-methods.html","id":null,"dir":"Reference","previous_headings":"","what":"Methods for epiworldR objects — epiworld-methods","title":"Methods for epiworldR objects — epiworld-methods","text":"functions described section methods objects class epiworld_model. Besides printing plotting, methods provide access manipulate model parameters, getting information model running simulation.","code":""},{"path":"/reference/epiworld-methods.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Methods for epiworldR objects — epiworld-methods","text":"","code":"queuing_on(x) queuing_off(x) verbose_off(x) verbose_on(x) run(model, ndays, seed = sample.int(10000, 1)) # S3 method for epiworld_model summary(object, ...) get_states(x) get_param(x, pname) set_param(x, pname, pval) set_name(x, mname) get_name(x) get_n_viruses(x) get_n_tools(x) get_ndays(x) get_n_replicates(x) size(x) set_agents_data(model, data) get_agents_data_ncols(model) get_virus(model, virus_pos) get_tool(model, tool_pos)"},{"path":"/reference/epiworld-methods.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Methods for epiworldR objects — epiworld-methods","text":"x object class epiworld_model. model Model object. ndays Number days (steps) simulation. seed Seed set initializing random number generator. object Object class epiworld_model. ... Additional arguments. pname String. Name parameter. pval Numeric. Value parameter. mname String. Name model. data numeric matrix. virus_pos Integer. Relative location (starting 0) virus model tool_pos Integer. Relative location (starting 0) tool model","code":""},{"path":"/reference/epiworld-methods.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Methods for epiworldR objects — epiworld-methods","text":"verbose_on verbose_off functions return model, however verbose_off returns model progress bar. run function returns simulated model class epiworld_model. summary function prints detailed view model, returns model invisibly. get_states function returns unique states found model. get_param function returns selected parameter model object class epiworld_model. set_param function return value instead alters parameter value. set_name function return value instead alters object epiworld_model. get_name returns name model. get_n_viruses returns number viruses model. get_n_tools returns number tools model. get_ndays returns number days model. get_n_replicates returns number replicates model. size.epiworld_model returns number agents model. 'set_agents_data' function returns object class DataFrame. 'get_agents_data_ncols' returns number columns model dataframe. 'get_virus' returns virus. get_tool returns tool.","code":""},{"path":"/reference/epiworld-methods.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Methods for epiworldR objects — epiworld-methods","text":"verbose_on verbose_off functions activate deactivate printing progress screen, respectively. functions return model (x) invisibly.","code":""},{"path":"/reference/epiworld-methods.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Methods for epiworldR objects — epiworld-methods","text":"","code":"model_sirconn <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) # Queuing - If you wish to implement the queuing function, declare whether # you would like it \"on\" or \"off\", if any. queuing_on(model_sirconn) #> Warning: SIR Connected models do not have queue. queuing_off(model_sirconn) run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Verbose - \"on\" prints the progress bar on the screen while \"off\" # deactivates the progress bar. Declare which function you want to implement, # if any. verbose_on(model_sirconn) verbose_off(model_sirconn) run(model_sirconn, ndays = 100, seed = 1912) get_states(model_sirconn) # Returns all unique states found within the model. #> [1] \"Susceptible\" \"Infected\" \"Recovered\" get_param(model_sirconn, 'Contact rate') # Returns the value of the selected #> [1] 5 # parameter within the model object. # In order to view the parameters, # run the model object and find the # \"Model parameters\" section. set_param(model_sirconn, 'Contact rate', 2) # Allows for adjustment of model # parameters within the model # object. In this example, the # Contact rate parameter is # changed to 2. You can now rerun # the model to observe any # differences. set_name(model_sirconn, 'My Epi-Model') # This function allows for setting # a name for the model. Running the # model object, the name of the model # is now reflected next to \"Name of # the model\". get_name(model_sirconn) # Returns the set name of the model. #> [1] \"My Epi-Model\" get_n_viruses(model_sirconn) # Returns the number of viruses in the model. #> [1] 1 # In this case, there is only one virus: # \"COVID-19\". get_n_tools(model_sirconn) # Returns the number of tools in the model. In #> [1] 0 # this case, there are zero tools. get_ndays(model_sirconn) # Returns the length of the simulation in days. This #> [1] 100 # will match \"ndays\" within the \"run\" function. get_n_replicates(model_sirconn) # Returns the number of replicates of the #> [1] 2 # model. size(model_sirconn) # Returns the population size in the model. In this case, #> [1] 10000 # there are 10,000 agents in the model. # Set Agents Data # First, your data matrix must have the same number of rows as agents in the # model. Below is a generated matrix which will be passed into the # \"set_agents_data\" function. data <- matrix(data=runif(20000, min=0, max=100), nrow=10000, ncol=2) set_agents_data(model_sirconn, data) get_agents_data_ncols(model_sirconn) # Returns number of columns #> [1] 2 get_virus(model_sirconn, 0) # Returns information about the first virus in #> Virus : COVID-19 #> Id : 0 #> state_init : 1 #> state_post : 2 #> state_removed : 2 #> queue_init : 2 #> queue_post : -2 #> queue_removed : -99 # the model (index begins at 0). add_tool(model_sirconn, tool(\"Vaccine\", .9, .9, .5, 1), proportion = .5) get_tool(model_sirconn, 0) # Returns information about the first tool in the #> Tool : Vaccine #> Id : 0 #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 # model. In this case, there are no tools so an # error message will occur."},{"path":"/reference/epiworldR-package.html","id":null,"dir":"Reference","previous_headings":"","what":"epiworldR — epiworldR-package","title":"epiworldR — epiworldR-package","text":"flexible framework Agent-Based Models (ABM), 'epiworldR' package provides methods prototyping disease outbreaks transmission models using 'C++' backend, making fast. supports multiple epidemiological models, including Susceptible-Infected-Susceptible (SIS), Susceptible-Infected-Removed (SIR), Susceptible-Exposed-Infected-Removed (SEIR), others, involving arbitrary mitigation policies multiple-disease models. Users can specify infectiousness/susceptibility rates function agents' features, providing great complexity model dynamics. Furthermore, 'epiworldR' ideal simulation studies featuring large populations.","code":""},{"path":[]},{"path":"/reference/epiworldR-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"epiworldR — epiworldR-package","text":"Maintainer: Derek Meyer derekmeyer37@gmail.com Authors: George Vega Yon g.vegayon@gmail.com (ORCID) contributors: Centers Disease Control Prevention (Award number 1U01CK000585; 75D30121F00003) [funder]","code":""},{"path":"/reference/get_agents.html","id":null,"dir":"Reference","previous_headings":"","what":"Agents in epiworldR — get_agents","title":"Agents in epiworldR — get_agents","text":"functions provide read-access agents model. get_agents function returns object class epiworld_agents contains information agents model. get_agent function returns information single agent. get_state function returns state single agent.","code":""},{"path":"/reference/get_agents.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Agents in epiworldR — get_agents","text":"","code":"get_agents(model) # S3 method for epiworld_agents [(x, i) # S3 method for epiworld_agent print(x, compressed = FALSE, ...) # S3 method for epiworld_agents print(x, compressed = TRUE, max_print = 10, ...) get_state(x)"},{"path":"/reference/get_agents.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Agents in epiworldR — get_agents","text":"model object class epiworld_model. x object class epiworld_agents Index (id) agent (0 n-1) compressed Logical scalar. FALSE, prints detailed information agent. ... Ignored max_print Integer scalar. Maximum number agents print.","code":""},{"path":"/reference/get_agents.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Agents in epiworldR — get_agents","text":"get_agents function returns object class epiworld_agents. [ method returns object class epiworld_agent. print function returns information individual agent class epiworld_agent. get_state function returns state epiworld_agents object.","code":""},{"path":[]},{"path":"/reference/get_agents.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Agents in epiworldR — get_agents","text":"","code":"model_sirconn <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. x <- get_agents(model_sirconn) # Storing all agent information into object of # class epiworld_agents print(x, compressed = FALSE, max_print = 5) # Displaying detailed information of #> Agents from the model \"Susceptible-Infected-Removed (SIR) (connected)\": #> Information about agent id 0 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 1 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 2 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 3 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 4 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 #> ... 9995 more agents ... # the first 5 agents using # compressed=F. Using compressed=T # results in less-detailed # information about each agent. x[0] # Print information about the first agent. Substitute the agent of #> Information about agent id 0 #> State : Recovered (2) #> Virus count : 0 #> Tool count : 0 #> Neigh. count : 0 # interest's position where '0' is."},{"path":"/reference/global-actions.html","id":null,"dir":"Reference","previous_headings":"","what":"Global Actions — global-actions","title":"Global Actions — global-actions","text":"Global actions functions executed time step simulation. useful implementing interventions, vaccination, isolation, social distancing means tools.","code":""},{"path":"/reference/global-actions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Global Actions — global-actions","text":"","code":"globalaction_tool(tool, prob, name = get_name_tool(tool), day = -99) globalaction_tool_logit( tool, vars, coefs, name = get_name_tool(tool), day = -99 ) globalaction_set_params( param, value, name = paste0(\"Set \", param, \" to \", value), day = -99 ) globalaction_fun(fun, name = deparse(substitute(fun)), day = -99) add_global_action(model, action)"},{"path":"/reference/global-actions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Global Actions — global-actions","text":"tool object class tool. prob Numeric scalar. probability 0 1. name Character scalar. name action. day Integer. day (step) action executed (see details). vars Integer vector. position variables model. coefs Numeric vector. coefficients logistic regression. param Character scalar. name parameter set. value Numeric scalar. value parameter. fun Function. function executed. model object class epiworld_model. action global action.","code":""},{"path":"/reference/global-actions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Global Actions — global-actions","text":"globalaction_set_params function returns object class epiworld_globalaction_set_param epiworld_globalaction. globalaction_tool returns object class epiworld_globalaction_tool epiworld_globalaction. globalaction_tool_logit returns object class epiworld_globalaction_tool_logit epiworld_globalaction. function add_global_action returns model added action.","code":""},{"path":"/reference/global-actions.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Global Actions — global-actions","text":"function globalaction_tool_logit allows specify logistic regression model probability using tool. model specified vector coefficients coefs vector variables vars. vars integer vector indicating position variables model. function globalaction_set_param allows set parameter model. parameter specified name param value value. function globalaction_fun allows specify function executed given day. function object must receive object class epiworld_model argument. function add_global_action adds global action model. model checks actions executed time step. added action matches current time step, action executed. day negative, action executed time step. day positive, action executed specified time step.","code":""},{"path":[]},{"path":"/reference/global-actions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Global Actions — global-actions","text":"","code":"# Simple model model_sirconn <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) # Creating a tool epitool <- tool( name = \"Vaccine\", susceptibility_reduction = .9, transmission_reduction = .5, recovery_enhancer = .5, death_reduction = .9 ) # Adding a global action vaccine_day_20 <- globalaction_tool(epitool, .2, day = 20) add_global_action(model_sirconn, vaccine_day_20) # Running and printing run(model_sirconn, ndays = 40, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. model_sirconn #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 10000 agents, 1 virus(es), and 1 tool(s). #> The model has 3 states. #> The final distribution is: 2000 Susceptible, 0 Infected, and 8000 Recovered. plot_incidence(model_sirconn) # Example 2: Changing the contact rate ------------------------------------- model_sirconn2 <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) closure_day_10 <- globalaction_set_params(\"Contact rate\", 0, day = 10) add_global_action(model_sirconn2, closure_day_10) # Running and printing run(model_sirconn2, ndays = 40, seed = 1912) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. model_sirconn2 #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 10000 agents, 1 virus(es), and 0 tool(s). #> The model has 3 states. #> The final distribution is: 2127 Susceptible, 0 Infected, and 7873 Recovered. plot_incidence(model_sirconn2) # Example using `globalaction_fun` to record the state of the # agents at each time step. # We start by creating an SIR connected model model <- ModelSIRCONN( name = \"SIR with Global Saver\", n = 1000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.3 ) # We create the object where the history of the agents will be stored agents_history <- NULL # This function prints the total number of agents in each state # and stores the history of the agents in the object `agents_history` hist_saver <- function(m) { message(\"Today's totals are: \", paste(get_today_total(m), collapse = \", \")) # We use the `<<-` operator to assign the value to the global variable # `agents_history` (see ?\"<<-\") agents_history <<- cbind( agents_history, get_agents_states(m) ) }"},{"path":"/reference/run_multiple.html","id":null,"dir":"Reference","previous_headings":"","what":"Run multiple simulations at once — run_multiple","title":"Run multiple simulations at once — run_multiple","text":"run_multiple function allows running multiple simulations . available, users can take advantage parallel computing speed process.","code":""},{"path":"/reference/run_multiple.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Run multiple simulations at once — run_multiple","text":"","code":"run_multiple( m, ndays, nsims, seed = sample.int(10000, 1), saver = make_saver(), reset = TRUE, verbose = TRUE, nthreads = 1L ) run_multiple_get_results(m) make_saver(..., fn = \"\")"},{"path":"/reference/run_multiple.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Run multiple simulations at once — run_multiple","text":"m, ndays, seed See run. nsims Integer. Number replicats saver object class epiworld_saver. reset TRUE (default,) resets simulation. verbose TRUE (default,) prints progress bar. nthreads Integer. Number threads (parallel computing.) ... List strings (characters) specifying save (see details). fn file name pattern.","code":""},{"path":"/reference/run_multiple.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Run multiple simulations at once — run_multiple","text":"case make_saver, list class epiworld_saver. run_multiple function runs specified number simulations returns model object class epiworld_model. run_multiple_get_results function returns named list data specified make_saver.","code":""},{"path":"/reference/run_multiple.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Run multiple simulations at once — run_multiple","text":"Currently, following elements can saved: total_hist History model (total numbers per time). virus_info Information viruses. virus_hist Changes viruses. tool_info Information tools. tool_hist Changes tools. transmission Transmission events. transition Transition matrices. reproductive Reproductive number. generation Estimation generation time.","code":""},{"path":"/reference/run_multiple.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Run multiple simulations at once — run_multiple","text":"","code":"model_sir <- ModelSIRCONN( name = \"COVID-19\", prevalence = 0.01, n = 1000, contact_rate = 2, transmission_rate = 0.9, recovery_rate = 0.1 ) # Generating a saver saver <- make_saver(\"total_hist\", \"reproductive\") # Running and printing run_multiple(model_sir, ndays = 100, nsims = 50, saver = saver, nthread = 1) #> Starting multiple runs (50) using 1 thread(s) #> _________________________________________________________________________ #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Retrieving the results ans <- run_multiple_get_results(model_sir) head(ans$total_hist) #> sim_num date nviruses state counts #> 1 1 0 1 Susceptible 990 #> 2 1 0 1 Infected 10 #> 3 1 0 1 Recovered 0 #> 4 1 1 1 Susceptible 974 #> 5 1 1 1 Infected 26 #> 6 1 1 1 Recovered 0 head(ans$reproductive) #> sim_num virus_id virus source source_exposure_date rt #> 1 1 0 COVID-19 175 10 0 #> 2 1 0 COVID-19 672 10 0 #> 3 1 0 COVID-19 718 10 0 #> 4 1 0 COVID-19 210 9 0 #> 5 1 0 COVID-19 448 8 0 #> 6 1 0 COVID-19 592 8 0 # Plotting multi_sir <- run_multiple_get_results(model_sir)$total_hist multi_sir <- multi_sir[multi_sir$date <= 20,] plot(multi_sir)"},{"path":"/reference/tool.html","id":null,"dir":"Reference","previous_headings":"","what":"Tools in epiworld — tool","title":"Tools in epiworld — tool","text":"Tools functions affect agents react virus. can used simulate effects vaccination, isolation, social distancing.","code":""},{"path":"/reference/tool.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tools in epiworld — tool","text":"","code":"tool( name, susceptibility_reduction, transmission_reduction, recovery_enhancer, death_reduction ) set_name_tool(tool, name) get_name_tool(tool) add_tool(model, tool, proportion) add_tool_n(model, tool, n) rm_tool(model, tool_pos) rm_tool(model, tool_pos) tool_fun_logit(vars, coefs, model) set_susceptibility_reduction(tool, prob) set_susceptibility_reduction_ptr(tool, model, param) set_susceptibility_reduction_fun(tool, model, tfun) set_transmission_reduction(tool, prob) set_transmission_reduction_ptr(tool, model, param) set_transmission_reduction_fun(tool, model, tfun) set_recovery_enhancer(tool, prob) set_recovery_enhancer_ptr(tool, model, param) set_recovery_enhancer_fun(tool, model, tfun) set_death_reduction(tool, prob) set_death_reduction_ptr(tool, model, param) set_death_reduction_fun(tool, model, tfun) # S3 method for epiworld_agents_tools print(x, max_print = 10, ...)"},{"path":"/reference/tool.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tools in epiworld — tool","text":"name Name tool susceptibility_reduction Numeric. Proportion reduces susceptibility. transmission_reduction Numeric. Proportion reduces transmission. recovery_enhancer Numeric. Proportion improves recovery. death_reduction Numeric. Proportion reduces probability death.e tool object class epiworld_tool model Model proportion case add_tool, proportion, otherwise, integer. n positive integer. Number agents initially tool. tool_pos Positive integer. Index tool's position model. vars Integer vector. Indices (starting 0) positions variables used compute logit probability. coefs Numeric vector. length vars, vector coefficients associated logit probability. prob Numeric scalar. probability (zero one). param Character scalar. Name parameter featured model added tool (see details). tfun object class epiworld_tool_fun. x object class epiworld_agents_tools. max_print Numeric scalar. Maximum number tools print. ... Currently ignored.","code":""},{"path":"/reference/tool.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tools in epiworld — tool","text":"tool function creates tool class epiworld_tool. set_name_tool function assigns name tool class epiworld_tool returns tool. get_name_tool function returns name tool class epiworld_tool. add_tool_n function adds specified tool model class epiworld_model specified count n. rm_tool function removes specified tool model. set_susceptibility_reduction function assigns probability reduction specified tool class epiworld_tool. set_transmission_reduction function assigns probability reduction specified tool class epiworld_tool. set_recovery_enhancer function assigns probability increase specified tool class epiworld_tool. set_death_reduction function assigns probability decrease specified tool class epiworld_tool.","code":""},{"path":"/reference/tool.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tools in epiworld — tool","text":"name epiworld_tool object can manipulated functions set_name_tool() get_name_tool(). add_tool function adds specified tool model class epiworld_model specified proportion. case set_susceptibility_reduction_ptr, set_transmission_reduction_ptr, set_recovery_enhancer, set_death_reduction_ptr, corresponding parameters passed pointer tool. implication using pointers values read directly model object, changes reflected.","code":""},{"path":"/reference/tool.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tools in epiworld — tool","text":"","code":"# Simple model model_sirconn <- ModelSIRCONN( name = \"COVID-19\", n = 10000, prevalence = 0.01, contact_rate = 5, transmission_rate = 0.4, recovery_rate = 0.95 ) # Running and printing run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. plot(model_sirconn) epitool <- tool( name = \"Vaccine\", susceptibility_reduction = .9, transmission_reduction = .5, recovery_enhancer = .5, death_reduction = .9 ) epitool #> Tool : Vaccine #> Id : (empty) #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 set_name_tool(epitool, 'Pfizer') # Assigning name to the tool get_name_tool(epitool) # Returning the name of the tool #> [1] \"Pfizer\" add_tool(model_sirconn, epitool, .5) run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. model_sirconn #> ________________________________________________________________________________ #> Susceptible-Infected-Removed (SIR) (connected) #> It features 10000 agents, 1 virus(es), and 1 tool(s). #> The model has 3 states. #> The final distribution is: 8344 Susceptible, 0 Infected, and 1656 Recovered. plot(model_sirconn) # To declare a certain number of individuals with the tool rm_tool(model_sirconn, 0) # Removing epitool from the model add_tool_n(model_sirconn, epitool, 5500) run(model_sirconn, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Adjusting probabilities due to tool set_susceptibility_reduction(epitool, 0.1) # Susceptibility reduction #> Tool : Pfizer #> Id : 0 #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 set_transmission_reduction(epitool, 0.2) # Transmission reduction #> Tool : Pfizer #> Id : 0 #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 set_recovery_enhancer(epitool, 0.15) # Probability increase of recovery #> Tool : Pfizer #> Id : 0 #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 set_death_reduction(epitool, 0.05) # Probability reduction of death #> Tool : Pfizer #> Id : 0 #> state_init : -99 #> state_post : -99 #> queue_init : 0 #> queue_post : 0 run(model_sirconn, ndays = 100, seed = 1912) # Run model to view changes #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # Using the logit function -------------- sir <- ModelSIR( name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery_rate = 0.1 ) # Adding a small world population agents_smallworld( sir, n = 10000, k = 5, d = FALSE, p = .01 ) # Creating a tool mask_wearing <- tool( name = \"Mask\", susceptibility_reduction = 0.0, transmission_reduction = 0.3, # Only transmission recovery_enhancer = 0.0, death_reduction = 0.0 ) add_tool(sir, mask_wearing, .5) run(sir, ndays = 50, seed = 11) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. hist_0 <- get_hist_total(sir) # And adding features dat <- cbind( female = sample.int(2, 10000, replace = TRUE) - 1, x = rnorm(10000) ) set_agents_data(sir, dat) # Creating the logit function tfun <- tool_fun_logit( vars = c(0L, 1L), coefs = c(-1, 1), model = sir ) # The infection prob is lower hist(plogis(dat %*% rbind(.5,1))) tfun # printing #> An epiworld_tool_function object. #> (model: Susceptible-Infected-Recovered (SIR)) #> This function was built using -tool_fun_logit()-. and it features the following coefficients: #> 0: -1.00 #> 1: 1.00 set_susceptibility_reduction_fun( tool = get_tool(sir, 0), model = sir, tfun = tfun ) run(sir, ndays = 50, seed = 11) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. hist_1 <- get_hist_total(sir) op <- par(mfrow = c(1, 2)) plot(hist_0); abline(v = 30) plot(hist_1); abline(v = 30) par(op)"},{"path":"/reference/virus.html","id":null,"dir":"Reference","previous_headings":"","what":"Virus design — virus","title":"Virus design — virus","text":"Viruses can considered anything can transmitted (e.g., diseases, well ideas.) models epiworldR can feature multiple viruses.","code":""},{"path":"/reference/virus.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Virus design — virus","text":"","code":"virus( name, prob_infecting, recovery_rate = 0.5, prob_death = 0, post_immunity = -1, incubation = 7 ) set_name_virus(virus, name) get_name_virus(virus) add_virus(model, virus, proportion) add_virus_n(model, virus, n) virus_set_state(virus, init, end, removed) rm_virus(model, virus_pos) virus_fun_logit(vars, coefs, model) set_prob_infecting(virus, prob) set_prob_infecting_ptr(virus, model, param) set_prob_infecting_fun(virus, model, vfun) set_prob_recovery(virus, prob) set_prob_recovery_ptr(virus, model, param) set_prob_recovery_fun(virus, model, vfun) set_prob_death(virus, prob) set_prob_death_ptr(virus, model, param) set_prob_death_fun(virus, model, vfun) set_incubation(virus, incubation) set_incubation_ptr(virus, model, param) set_incubation_fun(virus, model, vfun) # S3 method for epiworld_agents_viruses print(x, max_print = 10, ...)"},{"path":"/reference/virus.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Virus design — virus","text":"name virus prob_infecting Numeric scalar. Probability infection (transmission). recovery_rate Numeric scalar. Probability recovery. prob_death Numeric scalar. Probability death. post_immunity Numeric scalar. Post immunity (prob re-infection). incubation Numeric scalar. Incubation period (days) virus. virus object class epiworld_virus model object class epiworld_model. proportion case add_virus, proportion, otherwise, integer. n positive integer. Initial count agents virus. init, end, removed states acquiring virus, removing virus, removing agent result virus, respectively. virus_pos Positive integer. Index virus's position model. vars Integer vector. Indices (starting 0) positions variables used compute logit probability. coefs Numeric vector. length vars, vector coefficients associated logit probability. prob Numeric scalar. probability (zero one). param Character scalar. Name parameter featured model added virus (see details). vfun object class epiworld_virus_fun. x object class epiworld_agents_viruses. max_print Numeric scalar. Maximum number viruses print. ... Currently ignored.","code":""},{"path":"/reference/virus.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Virus design — virus","text":"set_name_virus function return value, merely assigns name virus choice. get_name_virus function returns name virus class epiworld_virus. add_virus function return value, instead adds virus choice model object class epiworld_model. add_virus_n function return value, instead adds specified number agents virus choice model object class epiworld_model. virus_set_state function return value assigns epidemiological properties specified virus class epiworld_virus. rm_virus function return value, instead removes specified virus model class epiworld_model. set_prob_infecting function return value, instead assigns probability infection specified virus class epiworld_virus. set_prob_recovery function return value, instead assigns probability recovery specified virus class epiworld_virus. set_prob_death function return value, instead assigns probability death specified virus class epiworld_virus. set_incubation function return value, instead assigns incubation period specified virus class epiworld_virus.","code":""},{"path":"/reference/virus.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Virus design — virus","text":"virus() function can used initialize virus. Virus features can modified using functions set_prob_*. function virus_fun_logit() creates \"virus function\" can evaluated transmission, recovery, death. name sugests, computes probabilities using logit function (see examples). name epiworld_virus object can manipulated functions set_name_virus() get_name_virus(). case set_prob_infecting_ptr, set_prob_recovery_ptr, set_prob_death_ptr, corresponding parameters passed pointer virus. implication using pointers values read directly model object, changes reflected.","code":""},{"path":"/reference/virus.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Virus design — virus","text":"","code":"mseirconn <- ModelSEIRCONN( name = \"COVID-19\", prevalence = 0.01, n = 10000, contact_rate = 4, incubation_days = 7, transmission_rate = 0.5, recovery_rate = 0.99 ) delta <- virus(\"Delta Variant\", 0, .5, .2, .01) # Adding virus and setting/getting virus name add_virus(mseirconn, delta, .3) set_name_virus(delta, \"COVID-19 Strain\") get_name_virus(delta) #> [1] \"COVID-19 Strain\" run(mseirconn, ndays = 100, seed = 992) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. mseirconn #> ________________________________________________________________________________ #> Susceptible-Exposed-Infected-Removed (SEIR) (connected) #> It features 10000 agents, 2 virus(es), and 0 tool(s). #> The model has 4 states. #> The final distribution is: 3774 Susceptible, 102 Exposed, 18 Infected, and 6106 Recovered. rm_virus(mseirconn, 0) # Removing the first virus from the model object add_virus_n(mseirconn, delta, 100) # Setting initial count of delta virus # to n = 100 # Setting parameters for the delta virus manually set_prob_infecting(delta, 0.5) set_prob_recovery(delta, 0.9) set_prob_death(delta, 0.01) run(mseirconn, ndays = 100, seed = 992) # Run the model to observe changes #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. # If the states were (for example): # 1: Infected # 2: Recovered # 3: Dead delta2 <- virus(\"Delta Variant 2\", 0, .5, .2, .01) virus_set_state(delta2, 1, 2, 3) # Using the logit function -------------- sir <- ModelSIR( name = \"COVID-19\", prevalence = 0.01, transmission_rate = 0.9, recovery = 0.1 ) # Adding a small world population agents_smallworld( sir, n = 10000, k = 5, d = FALSE, p = .01 ) run(sir, ndays = 50, seed = 11) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. plot(sir) # And adding features dat <- cbind( female = sample.int(2, 10000, replace = TRUE) - 1, x = rnorm(10000) ) set_agents_data(sir, dat) # Creating the logit function vfun <- virus_fun_logit( vars = c(0L, 1L), coefs = c(-1, 1), model = sir ) # The infection prob is lower hist(plogis(dat %*% rbind(-1,1))) vfun # printing #> An epiworld_virus_function object. #> (model: Susceptible-Infected-Recovered (SIR)) #> This function was built using -virus_fun_logit()-. and it features the following coefficients: #> 0: -1.00 #> 1: 1.00 set_prob_infecting_fun( virus = get_virus(sir, 0), model = sir, vfun = vfun ) run(sir, ndays = 50, seed = 11) #> _________________________________________________________________________ #> |Running the model... #> |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> | done. plot(sir)"},{"path":"/news/index.html","id":"epiworldr-00-3","dir":"Changelog","previous_headings":"","what":"epiworldR 0.0-3","title":"epiworldR 0.0-3","text":"Added following models: ModelSEIRD, ModelSEIRDCONN, ModelSIRD, ModelSIRDCONN, ModelSISD. Fixed bug reported issue 6.","code":""},{"path":"/news/index.html","id":"epiworldr-00-2","dir":"Changelog","previous_headings":"","what":"epiworldR 0.0-2","title":"epiworldR 0.0-2","text":"CRAN release: 2023-06-21 Added NEWS.md file track changes package. Fixed bug reported CRAN reference nullptr. Renamed arguments across Models favor consistency. Figures now show virus/tool name instead id. Fixed bug run_multiple added tests (C++). Redid autoconf Makevars using RcppArmadillo template checking OpenMP.","code":""}]