diff --git a/CODE_OF_CONDUCT.html b/CODE_OF_CONDUCT.html index 91076da..09b1d0c 100644 --- a/CODE_OF_CONDUCT.html +++ b/CODE_OF_CONDUCT.html @@ -37,7 +37,7 @@
diff --git a/LICENSE.html b/LICENSE.html index 74b399a..fd19fc3 100644 --- a/LICENSE.html +++ b/LICENSE.html @@ -37,7 +37,7 @@
diff --git a/articles/getting-started.html b/articles/getting-started.html index 36e7d93..e1fc5e5 100644 --- a/articles/getting-started.html +++ b/articles/getting-started.html @@ -66,9 +66,9 @@

Derek

George Vega Yon

-

2025-01-28

+

2025-01-29

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

Setup and running the model#> Number of entities : 0 #> Days (duration) : 50 (of 50) #> Number of viruses : 1 -#> Last run elapsed t : 109.00ms -#> Last run speed : 22.85 million agents x day / second +#> Last run elapsed t : 88.00ms +#> Last run speed : 28.24 million agents x day / second #> Rewiring : off #> #> Global events: diff --git a/articles/implementation.html b/articles/implementation.html index 5226a36..18dd2ac 100644 --- a/articles/implementation.html +++ b/articles/implementation.html @@ -68,7 +68,7 @@

Derek

2023-06-20

- Source:
vignettes/implementation.Rmd + Source: vignettes/implementation.Rmd
implementation.Rmd

diff --git a/articles/likelihood-free-mcmc.html b/articles/likelihood-free-mcmc.html index 87daa7f..f717a14 100644 --- a/articles/likelihood-free-mcmc.html +++ b/articles/likelihood-free-mcmc.html @@ -64,9 +64,9 @@

Likelihood Free Markhov Chain Monte Carlo (LFMCMC)

Andrew Pulsipher

-

2025-01-28

+

2025-01-29

- Source: vignettes/likelihood-free-mcmc.Rmd + Source: vignettes/likelihood-free-mcmc.Rmd
likelihood-free-mcmc.Rmd
@@ -142,8 +142,8 @@

Setup The SIR Model#> Number of entities : 0 #> Days (duration) : 50 (of 50) #> Number of viruses : 1 -#> Last run elapsed t : 296.00µs -#> Last run speed : 337.84 million agents x day / second +#> Last run elapsed t : 291.00µs +#> Last run speed : 343.64 million agents x day / second #> Rewiring : off #> #> Global events: @@ -298,7 +298,7 @@

Results#> #> N Samples (total) : 2000 #> N Samples (after burn-in period) : 500 -#> Elapsed t : 2.00s +#> Elapsed t : 1.00s #> #> Parameters: #> -Recovery rate : 0.14 [ 0.13, 0.15] (initial : 0.30) diff --git a/articles/mixing.html b/articles/mixing.html index bf95b61..a2b9728 100644 --- a/articles/mixing.html +++ b/articles/mixing.html @@ -64,9 +64,9 @@

Mixing models

George Vega Yon

-

2025-01-28

+

2025-01-29

- Source:
vignettes/mixing.Rmd + Source: vignettes/mixing.Rmd
mixing.Rmd
@@ -163,8 +163,8 @@

An SEIR model with mixing#> Number of entities : 3 #> Days (duration) : 100 (of 100) #> Number of viruses : 1 -#> Last run elapsed t : 109.00ms -#> Last run speed : 8.20 million agents x day / second +#> Last run elapsed t : 108.00ms +#> Last run speed : 8.28 million agents x day / second #> Rewiring : off #> #> Global events: diff --git a/articles/run-multiple.html b/articles/run-multiple.html index 7b2f9b0..9d52f5b 100644 --- a/articles/run-multiple.html +++ b/articles/run-multiple.html @@ -66,9 +66,9 @@

Derek

George Vega Yon

-

2025-01-28

+

2025-01-29

- Source:
vignettes/run-multiple.Rmd + Source: vignettes/run-multiple.Rmd
run-multiple.Rmd
diff --git a/authors.html b/authors.html index 6daecb3..c93069f 100644 --- a/authors.html +++ b/authors.html @@ -74,7 +74,7 @@

Authors

Citation

-

Source: inst/CITATION

+

Source: inst/CITATION

Meyer, Derek and Vega Yon, George (2023). epiworldR: Fast Agent-Based Epi Models. Journal of Open Source Software, 8(90), 5781, https://doi.org/10.21105/joss.05781

@Article{,
diff --git a/news/index.html b/news/index.html
index 66f579a..63c2c59 100644
--- a/news/index.html
+++ b/news/index.html
@@ -37,11 +37,11 @@
   
-

epiworldR 0.6.1.0

+

epiworldR 0.6.1.0

CRAN release: 2025-01-28

  • Updates to reflect changes in the epiworld C++ library (mostly bug fixes)

  • Package now requires R version >=4.1.0, because it uses the pipe |>

diff --git a/paper.html b/paper.html index d935994..0e2b7cd 100644 --- a/paper.html +++ b/paper.html @@ -37,7 +37,7 @@
diff --git a/pkgdown.yml b/pkgdown.yml index 517a19e..fabbf74 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -7,4 +7,4 @@ articles: likelihood-free-mcmc: likelihood-free-mcmc.html mixing: mixing.html run-multiple: run-multiple.html -last_built: 2025-01-28T22:29Z +last_built: 2025-01-29T15:07Z diff --git a/reference/LFMCMC.html b/reference/LFMCMC.html index 3c65a3e..752ac55 100644 --- a/reference/LFMCMC.html +++ b/reference/LFMCMC.html @@ -37,7 +37,7 @@
diff --git a/reference/ModelDiffNet.html b/reference/ModelDiffNet.html index 5677ffb..3d5265f 100644 --- a/reference/ModelDiffNet.html +++ b/reference/ModelDiffNet.html @@ -41,7 +41,7 @@
diff --git a/reference/ModelSEIR.html b/reference/ModelSEIR.html index 975959f..aeaa279 100644 --- a/reference/ModelSEIR.html +++ b/reference/ModelSEIR.html @@ -37,7 +37,7 @@
diff --git a/reference/ModelSEIRCONN.html b/reference/ModelSEIRCONN.html index 4b178dd..8acd931 100644 --- a/reference/ModelSEIRCONN.html +++ b/reference/ModelSEIRCONN.html @@ -39,7 +39,7 @@
diff --git a/reference/ModelSEIRD.html b/reference/ModelSEIRD.html index ab565d9..ce7d738 100644 --- a/reference/ModelSEIRD.html +++ b/reference/ModelSEIRD.html @@ -37,7 +37,7 @@
diff --git a/reference/ModelSEIRDCONN.html b/reference/ModelSEIRDCONN.html index 54d6459..fdcb5e0 100644 --- a/reference/ModelSEIRDCONN.html +++ b/reference/ModelSEIRDCONN.html @@ -39,7 +39,7 @@
diff --git a/reference/ModelSEIRMixing.html b/reference/ModelSEIRMixing.html index 23e3260..7163b12 100644 --- a/reference/ModelSEIRMixing.html +++ b/reference/ModelSEIRMixing.html @@ -37,7 +37,7 @@
@@ -202,7 +202,7 @@

Examples#> Days (duration) : 100 (of 100) #> Number of viruses : 1 #> Last run elapsed t : 109.00ms -#> Last run speed : 8.23 million agents x day / second +#> Last run speed : 8.24 million agents x day / second #> Rewiring : off #> #> Global events: diff --git a/reference/ModelSIR.html b/reference/ModelSIR.html index a0b7ceb..966d5d6 100644 --- a/reference/ModelSIR.html +++ b/reference/ModelSIR.html @@ -37,7 +37,7 @@
diff --git a/reference/ModelSIRCONN.html b/reference/ModelSIRCONN.html index 8ac51a6..97601f3 100644 --- a/reference/ModelSIRCONN.html +++ b/reference/ModelSIRCONN.html @@ -37,7 +37,7 @@
diff --git a/reference/ModelSIRD.html b/reference/ModelSIRD.html index 90f96bc..42b4055 100644 --- a/reference/ModelSIRD.html +++ b/reference/ModelSIRD.html @@ -37,7 +37,7 @@
diff --git a/reference/ModelSIRDCONN.html b/reference/ModelSIRDCONN.html index 1f9fb54..d4ba72b 100644 --- a/reference/ModelSIRDCONN.html +++ b/reference/ModelSIRDCONN.html @@ -37,7 +37,7 @@
diff --git a/reference/ModelSIRLogit.html b/reference/ModelSIRLogit.html index 068bea3..2384830 100644 --- a/reference/ModelSIRLogit.html +++ b/reference/ModelSIRLogit.html @@ -37,7 +37,7 @@
diff --git a/reference/ModelSIRMixing.html b/reference/ModelSIRMixing.html index 4d3c596..3caab57 100644 --- a/reference/ModelSIRMixing.html +++ b/reference/ModelSIRMixing.html @@ -37,7 +37,7 @@
@@ -195,8 +195,8 @@

Examples#> Number of entities : 3 #> Days (duration) : 100 (of 100) #> Number of viruses : 1 -#> Last run elapsed t : 59.00ms -#> Last run speed : 15.06 million agents x day / second +#> Last run elapsed t : 60.00ms +#> Last run speed : 14.99 million agents x day / second #> Rewiring : off #> #> Global events: diff --git a/reference/ModelSIS.html b/reference/ModelSIS.html index 4faa68f..e128798 100644 --- a/reference/ModelSIS.html +++ b/reference/ModelSIS.html @@ -37,7 +37,7 @@
diff --git a/reference/ModelSISD.html b/reference/ModelSISD.html index 760e23d..e3818da 100644 --- a/reference/ModelSISD.html +++ b/reference/ModelSISD.html @@ -37,7 +37,7 @@
diff --git a/reference/ModelSURV.html b/reference/ModelSURV.html index 10f335e..e7123fe 100644 --- a/reference/ModelSURV.html +++ b/reference/ModelSURV.html @@ -37,7 +37,7 @@
diff --git a/reference/agents.html b/reference/agents.html index 5a636a0..704f495 100644 --- a/reference/agents.html +++ b/reference/agents.html @@ -45,7 +45,7 @@
diff --git a/reference/agents_smallworld.html b/reference/agents_smallworld.html index 6701277..e5caa75 100644 --- a/reference/agents_smallworld.html +++ b/reference/agents_smallworld.html @@ -45,7 +45,7 @@
diff --git a/reference/entities.html b/reference/entities.html index 839b4a6..4b21260 100644 --- a/reference/entities.html +++ b/reference/entities.html @@ -37,7 +37,7 @@
@@ -192,8 +192,8 @@

Examples#> Number of entities : 2 #> Days (duration) : 100 (of 100) #> Number of viruses : 1 -#> Last run elapsed t : 60.00ms -#> Last run speed : 16.63 million agents x day / second +#> Last run elapsed t : 59.00ms +#> Last run speed : 16.78 million agents x day / second #> Rewiring : off #> #> Global events: diff --git a/reference/epiworld-data.html b/reference/epiworld-data.html index b232635..62c80cd 100644 --- a/reference/epiworld-data.html +++ b/reference/epiworld-data.html @@ -43,7 +43,7 @@
diff --git a/reference/epiworld-methods.html b/reference/epiworld-methods.html index eb4de12..cd841e7 100644 --- a/reference/epiworld-methods.html +++ b/reference/epiworld-methods.html @@ -43,7 +43,7 @@
diff --git a/reference/epiworldR-deprecated.html b/reference/epiworldR-deprecated.html index bac92c0..3a0adc8 100644 --- a/reference/epiworldR-deprecated.html +++ b/reference/epiworldR-deprecated.html @@ -39,7 +39,7 @@
diff --git a/reference/epiworldR-package.html b/reference/epiworldR-package.html index 0ea795c..2fb9649 100644 --- a/reference/epiworldR-package.html +++ b/reference/epiworldR-package.html @@ -37,7 +37,7 @@
diff --git a/reference/global-events.html b/reference/global-events.html index 0e834f3..10e57b5 100644 --- a/reference/global-events.html +++ b/reference/global-events.html @@ -41,7 +41,7 @@
diff --git a/reference/run_multiple.html b/reference/run_multiple.html index 7ced83a..88d154b 100644 --- a/reference/run_multiple.html +++ b/reference/run_multiple.html @@ -41,7 +41,7 @@
diff --git a/reference/tool.html b/reference/tool.html index 1573a43..d265ceb 100644 --- a/reference/tool.html +++ b/reference/tool.html @@ -41,7 +41,7 @@
diff --git a/reference/virus.html b/reference/virus.html index 02e26b2..f3f0a9a 100644 --- a/reference/virus.html +++ b/reference/virus.html @@ -41,7 +41,7 @@
diff --git a/search.json b/search.json index 1ad6cc8..2eb7915 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 13\\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,276, number agents infected state increased 5 1, recovered agents increased 46,723 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 events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - COVID-19 #> #> 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 : 109.00ms #> Last run speed : 22.85 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - COVID-19 #> #> 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 -> 3276 #> - (1) Infected : 5 -> 1 #> - (2) Recovered : 0 -> 46723 #> #> Transition Probabilities: #> - Susceptible 0.95 0.05 0.00 #> - Infected 0.00 0.69 0.31 #> - 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_param add_tool #> [3] add_virus agents_from_edgelist #> [5] agents_smallworld get_agents #> [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] today verbose_off #> [33] 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 49988 #> 5 1 Infected 12 #> 6 1 Recovered 0 repnum <- get_reproductive_number(model_sir) head(repnum) #> virus_id virus source source_exposure_date rt #> 1 0 COVID-19 7312 44 0 #> 2 0 COVID-19 46328 43 0 #> 3 0 COVID-19 43475 42 0 #> 4 0 COVID-19 23672 42 0 #> 5 0 COVID-19 18224 42 1 #> 6 0 COVID-19 48317 41 2 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.601587 630 2.29016 0 8 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, prevalence = .0001, as_proportion = TRUE ) # Adding the virus to the model add_virus(model_sir, flu) 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: 3285 Susceptible, 3 Infected, and 46712 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\", prevalence = 0.5, as_proportion = TRUE, susceptibility_reduction = .9, transmission_reduction = .5, recovery_enhancer = .5, death_reduction = .9 ) add_tool(model_sir, vaccine) 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 ii infects agent jj, agent jj able infect agent ii 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 ii jj given following formula: P(→j|one)=pij×∏k≠(1−pkj)∏k(1−pkj)+∑kpkj×∏l≠k(1−plj) 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 pijp_{ij} computed function ii, jj, 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, pij=pv×(1−factorhost)×(1−factortarget) p_{ij} = p_{v} \\times \\left(1 - factor_{host}\\right) \\times \\left(1 - factor_{target}\\right) pvp_{v} raw transmission probability virus vv, factortfactor_{t} increasing/reducing factors tools process. example, p_v 0.9, host wearing mask, factormask host=0.3factor_{\\mbox{mask host}} = 0.3 target vaccinated, factorvaccinated target=0.5factor_{\\mbox{vaccinated target}} = 0.5, adjusted probability pijp_{ij} 0.9×(1−0.3)×(1−0.5)=0.270.9 \\times (1 - 0.3) \\times (1 - 0.5) = 0.27. agents one tool, factors combined follows: factoragent=1−∏t∈toolsagent(1−factort) factor_{agent} = 1 - \\prod_{t\\tools_{agent}}\\left(1 - factor_{t}\\right) Therefore, example, vaccinated agent wearing mask factor 1−(1−0.30)×(1−0.5)=0.651 - (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 cc drawn binomial distribution parameters nn pp, nn number agents p=p =contact_rate/n/ n. , cc agents randomly selected population. Transmission can occur agents susceptible agent. probability transmission cc agents calculated described previous section.","code":""},{"path":"/articles/likelihood-free-mcmc.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Likelihood Free Markhov Chain Monte Carlo (LFMCMC)","text":"purpose “LFMCMC” class epiworldR perform Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) simulation. LFMCMC used approximate models likelihood function either unavailable computationally expensive. example assumes general understanding LFMCMC. learn , see Handbook Markhov Chain Monte Carlo Brooks et al. https://doi.org/10.1201/b10905. example, use LFMCMC recover parameters SIR model.","code":""},{"path":"/articles/likelihood-free-mcmc.html","id":"setup-the-sir-model","dir":"Articles","previous_headings":"","what":"Setup The SIR Model","title":"Likelihood Free Markhov Chain Monte Carlo (LFMCMC)","text":"SIR model following characteristics: Virus Name: COVID-19 Initial Virus Prevalence: 0.01 Recovery Rate: 1/7 (0.14) Transmission Rate: 0.1 Number Agents: 2,000 use ModelSIR agents_smallworld functions construct model epiworldR. run model 50 days print results. Note “Model parameters” “Distribution population time 50” output. goal recover model parameters (Recovery Transmission rates) LFMCMC. accomplish comparing population distribution simulation run “observed” distribution model. get distribution using get_today_total function epiworldR. practical cases, use observed data, instead model simulation. use simulation example show accuracy LFMCMC recovering model parameters. Whenever use term “observed data” , referring model distribution (model_sir_data).","code":"library(epiworldR) model_seed <- 122 model_sir <- ModelSIR( name = \"COVID-19\", prevalence = .01, transmission_rate = .1, recovery_rate = 1 / 7 ) agents_smallworld( model_sir, n = 2000, k = 5, d = FALSE, p = 0.01 ) verbose_off(model_sir) run( model_sir, ndays = 50, seed = model_seed ) summary(model_sir) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Recovered (SIR) #> Population size : 2000 #> Agents' data : (none) #> Number of entities : 0 #> Days (duration) : 50 (of 50) #> Number of viruses : 1 #> Last run elapsed t : 296.00µs #> Last run speed : 337.84 million agents x day / second #> Rewiring : off #> #> Global events: #> (none) #> #> Virus(es): #> - COVID-19 #> #> Tool(s): #> (none) #> #> Model parameters: #> - Recovery rate : 0.1429 #> - Transmission rate : 0.1000 #> #> Distribution of the population at time 50: #> - (0) Susceptible : 1980 -> 1865 #> - (1) Infected : 20 -> 0 #> - (2) Recovered : 0 -> 135 #> #> Transition Probabilities: #> - Susceptible 1.00 0.00 0.00 #> - Infected 0.00 0.85 0.15 #> - Recovered 0.00 0.00 1.00 model_sir_data <- get_today_total(model_sir)"},{"path":"/articles/likelihood-free-mcmc.html","id":"setup-lfmcmc","dir":"Articles","previous_headings":"","what":"Setup LFMCMC","title":"Likelihood Free Markhov Chain Monte Carlo (LFMCMC)","text":"epiworldR, LFMCMC requires four functions: simulation function runs model given set parameters produces output matches structure observed data. example, set Recovery Transmission rate parameters, run SIR model 50 days, return distribution population end run. summary function extracts summary statistics given data. produce output format observed data simulated data simulation_fun. example, since population distribution already summary data, summary function simply passes data . complicated use cases, might instead compute summary statistics mean standard deviation. proposal function returns new set parameters, “proposing” parameters LFMCMC algorithm try simulation function. example, takes parameters previous run (old_params) random step away values. kernel function effectively scores results latest simulation run observed data, comparing summary statistics summary_fun . LFMCMC uses kernel score Hastings Ratio determine whether accept parameters run. example, since summary_fun simply passes data , simulated_stats observed_stats simulated observed data respectively. four functions defined, can initialize simulation object using LFMCMC function epiworldR along appropriate setter functions.","code":"simulation_fun <- function(params, lfmcmc_obj) { set_param(model_sir, \"Recovery rate\", params[1]) set_param(model_sir, \"Transmission rate\", params[2]) run( model_sir, ndays = 50 ) get_today_total(model_sir) } summary_fun <- function(data, lfmcmc_obj) { return(data) } proposal_fun <- function(old_params, lfmcmc_obj) { res <- plogis(qlogis(old_params) + rnorm(length(old_params), sd = .1)) return(res) } kernel_fun <- function( simulated_stats, observed_stats, epsilon, lfmcmc_obj ) { diff <- ((simulated_stats - observed_stats)^2)^epsilon dnorm(sqrt(sum(diff))) } lfmcmc_model <- LFMCMC(model_sir) |> set_simulation_fun(simulation_fun) |> set_summary_fun(summary_fun) |> set_proposal_fun(proposal_fun) |> set_kernel_fun(kernel_fun) |> set_observed_data(model_sir_data)"},{"path":"/articles/likelihood-free-mcmc.html","id":"run-lfmcmc-simulation","dir":"Articles","previous_headings":"","what":"Run LFMCMC Simulation","title":"Likelihood Free Markhov Chain Monte Carlo (LFMCMC)","text":"run LFMCMC, need set initial model parameters. example, use initial Recovery rate 0.3 initial Transmission rate 0.3. set kernel epsilon 1.0 run simulation 2,000 samples (iterations) using run_lfmcmc function.","code":"initial_params <- c(0.3, 0.3) epsilon <- 1.0 n_samples <- 2000 # Run the LFMCMC simulation run_lfmcmc( lfmcmc = lfmcmc_model, params_init = initial_params, n_samples = n_samples, epsilon = epsilon, seed = model_seed ) #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done."},{"path":"/articles/likelihood-free-mcmc.html","id":"results","dir":"Articles","previous_headings":"","what":"Results","title":"Likelihood Free Markhov Chain Monte Carlo (LFMCMC)","text":"make printed results easier read, use set_params_names set_stats_names functions calling print. also use burn-period 1,500 samples. can also look trace parameters: Recall observed data came model Recovery rate 0.3 Transmission rate 0.3. output shows, LFMCMC made close approximation parameters, resulted close approximation observed population distribution. example highlights effectiveness using LFMCMC highly complex models.","code":"set_params_names(lfmcmc_model, c(\"Recovery rate\", \"Transmission rate\")) set_stats_names(lfmcmc_model, get_states(model_sir)) print(lfmcmc_model, burnin = 1500) #> ___________________________________________ #> #> LIKELIHOOD-FREE MARKOV CHAIN MONTE CARLO #> #> N Samples (total) : 2000 #> N Samples (after burn-in period) : 500 #> Elapsed t : 2.00s #> #> Parameters: #> -Recovery rate : 0.14 [ 0.13, 0.15] (initial : 0.30) #> -Transmission rate : 0.09 [ 0.09, 0.10] (initial : 0.30) #> #> Statistics: #> -Susceptible : 1865.49 [ 1864.00, 1866.00] (Observed: 1865.00) #> -Infected : 0.00 [ 0.00, 0.00] (Observed: 0.00) #> -Recovered : 134.51 [ 134.00, 136.00] (Observed: 135.00) #> ___________________________________________ # Extracting the accepted parameters accepted <- get_all_accepted_params(lfmcmc_model) # Plotting the trace plot( accepted[, 1], type = \"l\", ylim = c(0, 1), main = \"Trace of the parameters\", lwd = 2, col = \"tomato\", xlab = \"Step\", ylab = \"Parameter value\" ) lines(accepted[, 2], type = \"l\", lwd = 2, col = \"steelblue\") legend( \"topright\", bty = \"n\", legend = c(\"Recovery rate\", \"Transmission rate\"), pch = 20, col = c(\"tomato\", \"steelblue\") )"},{"path":"/articles/mixing.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Mixing models","text":"vignette shows create mixing model using epiworldR package. Mixing models feature multiple populations. group, called Entities, subset agents. agents can interact within group agents groups. contact matrix defines interaction agents.","code":""},{"path":"/articles/mixing.html","id":"an-seir-model-with-mixing","dir":"Articles","previous_headings":"","what":"An SEIR model with mixing","title":"Mixing models","text":"example, simulate outbreak featuring three populations. contact matrix defined follows: [0.90.050.050.10.80.10.10.20.7] \\left[% \\begin{array}{ccc} 0.9 & 0.05 & 0.05 \\\\ 0.1 & 0.8 & 0.1 \\\\ 0.1 & 0.2 & 0.7 \\\\ \\end{array}% \\right] matrix represents probability agent population ii interacting agent population jj. matrix row-stochastic, meaning sum row equal 1. build model using entity class epiworld. following code chunk instantiates three entities contact matrix. hand, can proceed create mixing model. following code chunk creates model, SEIR mixing, adds entities model: function add_entity adds corresponding entity. default behavior randomly assigns agents entities beginning simulation. Agents may assigned one entity. following code-chunk simulates model 100 days, summarizes results, plots incidence curve:","code":"library(epiworldR) e1 <- entity(\"Population 1\", 3e3, as_proportion = FALSE) e2 <- entity(\"Population 2\", 3e3, as_proportion = FALSE) e3 <- entity(\"Population 3\", 3e3, as_proportion = FALSE) # Row-stochastic matrix (rowsums 1) cmatrix <- c( c(0.9, 0.05, 0.05), c(0.1, 0.8, 0.1), c(0.1, 0.2, 0.7) ) |> matrix(byrow = TRUE, nrow = 3) N <- 9e3 flu_model <- ModelSEIRMixing( name = \"Flu\", n = N, prevalence = 1 / N, contact_rate = 20, transmission_rate = 0.1, recovery_rate = 1 / 7, incubation_days = 7, contact_matrix = cmatrix ) # Adding the entities flu_model |> add_entity(e1) |> add_entity(e2) |> add_entity(e3) set.seed(331) run(flu_model, ndays = 100) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. summary(flu_model) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Exposed-Infected-Removed (SEIR) with Mixing #> Population size : 9000 #> Agents' data : (none) #> Number of entities : 3 #> Days (duration) : 100 (of 100) #> Number of viruses : 1 #> Last run elapsed t : 109.00ms #> Last run speed : 8.20 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - Flu #> #> Tool(s): #> (none) #> #> Model parameters: #> - Avg. Incubation days : 7.0000 #> - Contact rate : 20.0000 #> - Prob. Recovery : 0.1429 #> - Prob. Transmission : 0.1000 #> #> Distribution of the population at time 100: #> - (0) Susceptible : 8999 -> 137 #> - (1) Exposed : 1 -> 35 #> - (2) Infected : 0 -> 139 #> - (3) Recovered : 0 -> 8689 #> #> Transition Probabilities: #> - Susceptible 0.96 0.04 0.00 0.00 #> - Exposed 0.00 0.84 0.16 0.00 #> - Infected 0.00 0.00 0.86 0.14 #> - Recovered 0.00 0.00 0.00 1.00 plot_incidence(flu_model)"},{"path":"/articles/mixing.html","id":"investigating-the-history","dir":"Articles","previous_headings":"","what":"Investigating the history","title":"Mixing models","text":"running simulation, possible question : many agents entity infected day? following code chunk retrieves agents entity transmissions occurred simulation: can retrieve daily incidence entity merging transmissions agents’ entities. following code chunk accomplishes : information, can now visualize daily incidence entity. following code chunk plots daily incidence entity:","code":"library(data.table) agents_entities <- lapply(get_entities(flu_model), \\(e) { entity_get_agents(e) }) |> rbindlist() head(agents_entities) #> agent entity #> #> 1: 507 0 #> 2: 1710 0 #> 3: 8984 0 #> 4: 7844 0 #> 5: 760 0 #> 6: 4379 0 # Retrieving the transmissions transmissions <- get_transmissions(flu_model) |> data.table() # We only need the date and the source transmissions <- subset( transmissions, select = c(\"date\", \"source\") ) # Attaching the entity to the source transmissions <- merge( transmissions, agents_entities, by.x = \"source\", by.y = \"agent\" ) # Aggregating by date x entity (counts) transmissions <- transmissions[, .N, by = .(date, entity)] # Taking a look at the data head(transmissions) #> date entity N #> #> 1: 75 1 12 #> 2: 47 0 114 #> 3: 51 0 133 #> 4: 52 0 152 #> 5: 47 2 74 #> 6: 48 2 87 setorder(transmissions, date, entity) ran <- range(transmissions$N) transmissions[entity == 0, plot( x = date, y = N, type = \"l\", col = \"black\", ylim = ran)] #> NULL transmissions[entity == 1, lines(x = date, y = N, col = \"red\")] #> NULL transmissions[entity == 2, lines(x = date, y = N, col = \"blue\")] #> NULL legend( \"topright\", legend = c(\"Population 1\", \"Population 2\", \"Population 3\"), col = c(\"black\", \"red\", \"blue\"), lty = 1 )"},{"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 13\\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, nthreads = 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 2 0 COVID-19 9964 50 0 #> 2 2 0 COVID-19 9828 50 0 #> 3 2 0 COVID-19 9689 50 0 #> 4 2 0 COVID-19 9687 50 0 #> 5 2 0 COVID-19 9651 50 0 #> 6 2 0 COVID-19 9277 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":"George Vega Yon. Author. Derek Meyer. Author. Andrew Pulsipher. Author, maintainer. 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, Derek Vega Yon, George (2023). epiworldR: Fast Agent-Based Epi Models. Journal Open Source Software, 8(90), 5781, https://doi.org/10.21105/joss.05781 Meyer D, Pulsipher , Vega Yon G (2025). epiworldR: Fast Agent-Based Epi Models. R package version 0.6.1.0, https://github.com/UofUEpiBio/epiworldR.","code":"@Article{, entry = {Article}, title = {epiworldR: Fast Agent-Based Epi Models}, author = {Derek Meyer and George {Vega Yon}}, journal = {The Journal of Open Source Software}, year = {2023}, month = {oct}, volume = {8}, number = {90}, doi = {10.21105/joss.05781}, url = {https://joss.theoj.org/papers/10.21105/joss.05781}, } @Manual{, title = {{{epiworldR: Fast Agent-Based Epi Models}}}, author = {Derek Meyer and Andrew Pulsipher and George {Vega Yon}}, year = {2025}, note = {R package version 0.6.1.0}, url = {https://github.com/UofUEpiBio/epiworldR}, }"},{"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. Current available models: ModelDiffNet ModelSEIR ModelSEIRCONN ModelSEIRD ModelSEIRDCONN ModelSEIRMixing ModelSIR ModelSIRCONN ModelSIRD ModelSIRDCONN ModelSIRLogit ModelSIRMixing ModelSIS ModelSISD ModelSURV","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.","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: 1209 Susceptible, 499 Infected, and 98292 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 : 66.00ms #> Last run speed : 74.96 million agents x day / second #> Rewiring : off #> #> Global events: #> (none) #> #> Virus(es): #> - COVID-19 #> #> Tool(s): #> (none) #> #> Model parameters: #> - Recovery rate : 0.3000 #> - Transmission rate : 0.7000 #> #> Distribution of the population at time 50: #> - (0) Susceptible : 99000 -> 1209 #> - (1) Infected : 1000 -> 499 #> - (2) Recovered : 0 -> 98292 #> #> Transition Probabilities: #> - Susceptible 0.92 0.08 0.00 #> - Infected 0.00 0.70 0.30 #> - Recovered 0.00 0.00 1.00 plot(sir) plot_incidence(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 = 10, incubation_days = 7, transmission_rate = 0.1, recovery_rate = 1 / 7 ) |> add_virus( virus( name = \"COVID-19\", prevalence = 0.01, as_proportion = TRUE, prob_infecting = 0.01, recovery_rate = 0.6, prob_death = 0.5, incubation = 7 )) set.seed(132) run(model_seirconn, ndays = 100) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. summary(model_seirconn) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Exposed-Infected-Removed (SEIR) (connected) #> Population size : 10000 #> Agents' data : (none) #> Number of entities : 0 #> Days (duration) : 100 (of 100) #> Number of viruses : 2 #> Last run elapsed t : 15.00ms #> Last run speed : 65.69 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - COVID-19 #> - COVID-19 #> #> Tool(s): #> (none) #> #> Model parameters: #> - Avg. Incubation days : 7.0000 #> - Contact rate : 10.0000 #> - Prob. Recovery : 0.1429 #> - Prob. Transmission : 0.1000 #> #> Distribution of the population at time 100: #> - (0) Susceptible : 9800 -> 11 #> - (1) Exposed : 200 -> 0 #> - (2) Infected : 0 -> 3 #> - (3) Recovered : 0 -> 9986 #> #> Transition Probabilities: #> - Susceptible 0.94 0.06 0.00 0.00 #> - Exposed 0.00 0.85 0.15 0.00 #> - Infected 0.00 0.00 0.86 0.14 #> - Recovered 0.00 0.00 0.00 1.00 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 5.769231 91 5.455022 1.000 20.750 #> 2 0 COVID-19 2 6.400000 10 4.880801 0.450 14.875 #> 3 0 COVID-19 3 5.166667 18 4.422536 0.425 13.000 #> 4 0 COVID-19 4 4.659091 44 3.784566 0.000 12.850 #> 5 0 COVID-19 5 5.205882 34 3.273210 0.000 12.175 #> 6 0 COVID-19 6 3.137255 51 2.713077 0.000 8.750 head(plot_generation_time(model_seirconn)) #> date avg n sd ci_lower ci_upper virus virus_id #> 1 2 4.444444 9 2.185813 2.2 8.000 COVID-19 0 #> 2 3 7.411765 17 3.922034 2.4 15.000 COVID-19 0 #> 3 4 8.538462 39 7.100208 2.0 22.000 COVID-19 0 #> 4 5 6.312500 32 3.905641 2.0 13.225 COVID-19 0 #> 5 6 7.200000 40 4.052223 2.0 15.100 COVID-19 0 #> 6 7 7.660000 50 4.461216 2.0 17.000 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.13466 0.14878 # Looking into the agents get_agents(model_logit) #> Agents from the model \"Susceptible-Infected-Removed (SIR) (logit)\": #> Agent: 0, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 1, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 2, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 3, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 4, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 5, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 6, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 7, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 8, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 9, state: Susceptible (0), Has virus: no, NTools: 0i 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(epiworldR) library(netplot) #> Loading required package: grid x <- igraph::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:","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) #> _________________________________________________________________________ #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 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 77 10 0 #> 2 1 0 COVID-19 970 8 0 #> 3 1 0 COVID-19 895 8 0 #> 4 1 0 COVID-19 866 8 0 #> 5 1 0 COVID-19 811 8 0 #> 6 1 0 COVID-19 752 8 0 plot(ans$reproductive)"},{"path":"/index.html","id":"tutorials","dir":"","previous_headings":"","what":"Tutorials","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":"citation","dir":"","previous_headings":"","what":"Citation","title":"Fast Agent-Based Epi Models","text":"use epiworldR research, please cite follows:","code":"citation(\"epiworldR\") #> To cite epiworldR in publications use: #> #> Meyer, Derek and Vega Yon, George (2023). epiworldR: Fast Agent-Based #> Epi Models. Journal of Open Source Software, 8(90), 5781, #> https://doi.org/10.21105/joss.05781 #> #> And the actual R package: #> #> Meyer D, Pulsipher A, Vega Yon G (2024). _epiworldR: Fast Agent-Based #> Epi Models_. R package version 0.6.0.0, #> . #> #> To see these entries in BibTeX format, use 'print(, #> bibtex=TRUE)', 'toBibtex(.)', or set #> 'options(citation.bibtex.max=999)'."},{"path":"/index.html","id":"existing-alternatives","dir":"","previous_headings":"","what":"Existing Alternatives","title":"Fast Agent-Based Epi Models","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":"/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":"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/LFMCMC.html","id":null,"dir":"Reference","previous_headings":"","what":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC)","code":""},{"path":"/reference/LFMCMC.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"","code":"LFMCMC(model = NULL) run_lfmcmc(lfmcmc, params_init, n_samples, epsilon, seed = NULL) set_observed_data(lfmcmc, observed_data) set_proposal_fun(lfmcmc, fun) use_proposal_norm_reflective(lfmcmc) set_simulation_fun(lfmcmc, fun) set_summary_fun(lfmcmc, fun) set_kernel_fun(lfmcmc, fun) use_kernel_fun_gaussian(lfmcmc) get_mean_params(lfmcmc) get_mean_stats(lfmcmc) get_initial_params(lfmcmc) get_current_proposed_params(lfmcmc) get_current_accepted_params(lfmcmc) get_current_proposed_stats(lfmcmc) get_current_accepted_stats(lfmcmc) get_observed_stats(lfmcmc) get_all_sample_params(lfmcmc) get_all_sample_stats(lfmcmc) get_all_sample_acceptance(lfmcmc) get_all_sample_drawn_prob(lfmcmc) get_all_sample_kernel_scores(lfmcmc) get_all_accepted_params(lfmcmc) get_all_accepted_stats(lfmcmc) get_all_accepted_kernel_scores(lfmcmc) get_n_samples(lfmcmc) get_n_stats(lfmcmc) get_n_params(lfmcmc) # S3 method for class 'epiworld_lfmcmc' verbose_off(x) set_params_names(lfmcmc, names) set_stats_names(lfmcmc, names) # S3 method for class 'epiworld_lfmcmc' print(x, burnin = 0, ...)"},{"path":"/reference/LFMCMC.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"model model class epiworld_model NULL (see details). lfmcmc LFMCMC model params_init Initial model parameters, treated double n_samples Number samples, treated integer epsilon Epsilon parameter, treated double seed Random engine seed observed_data Observed data, treated double. fun function (see details). x LFMCMC model print names Character vector names. burnin Integer. Number samples discard burnin computing summary. ... Ignored","code":""},{"path":"/reference/LFMCMC.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"LFMCMC function returns model class epiworld_lfmcmc. simulated model class epiworld_lfmcmc. use_kernel_fun_gaussian: LFMCMC model kernel function set gaussian. get_mean_params: param means given lfmcmc model. get_mean_stats: stats means given lfmcmc model. function get_initial_params returns initial parameters given LFMCMC model. function get_current_proposed_params returns proposed parameters next LFMCMC sample. function get_current_accepted_params returns recently accepted parameters (current state LFMCMC) function get_current_proposed_stats returns statistics simulation run proposed parameters function get_current_accepted_stats returns statistics recently accepted parameters function get_observed_stats returns statistics observed data function get_all_sample_params returns matrix sample parameters given LFMCMC model. number rows equal number samples number columns equal number parameters. function get_all_sample_stats returns matrix statistics given LFMCMC model. number rows equal number samples number columns equal number statistics. function get_all_sample_acceptance returns vector boolean flags indicate whether given sample accepted function get_all_sample_drawn_prob returns vector drawn probabilities sample function get_all_sample_kernel_scores returns vector kernel scores sample function get_all_accepted_params returns matrix accepted parameters given LFMCMC model. number rows equal number samples number columns equal number parameters. function get_all_accepted_stats returns matrix accepted statistics given LFMCMC model. number rows equal number samples number columns equal number statistics. function get_all_accepted_kernel_scores returns vector kernel scores accepted sample functions get_n_samples, get_n_stats, get_n_params return number samples, statistics, parameters given LFMCMC model, respectively. verbose_on verbose_off functions return model, however verbose_off returns model progress bar. set_params_names: lfmcmc model parameter names added. set_stats_names: lfmcmc model stats names added.","code":""},{"path":"/reference/LFMCMC.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"Performs Likelihood-Free Markhov Chain Monte Carlo simulation. model NULL, model uses random-number generator engine model. Otherwise, model NULL, new random-number generator engine created. functions passed LFMCMC object different arguments depending object: set_proposal_fun: vector parameters model. set_simulation_fun: vector parameters model. set_summary_fun: vector simulated data model. set_kernel_fun: vector simulated statistics, observed statistics, epsilon, model. verbose_on verbose_off functions activate deactivate printing progress screen, respectively. functions return model (x) invisibly.","code":""},{"path":"/reference/LFMCMC.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"","code":"## Setup an SIR model to use in the simulation model_seed <- 122 model_sir <- ModelSIR(name = \"COVID-19\", prevalence = .1, transmission_rate = .9, recovery_rate = .3) agents_smallworld( model_sir, n = 1000, k = 5, d = FALSE, p = 0.01 ) verbose_off(model_sir) run(model_sir, ndays = 50, seed = model_seed) ## Setup LFMCMC # Extract the observed data from the model obs_data <- get_today_total(model_sir) # Define the simulation function simfun <- function(params, lfmcmc_obj) { set_param(model_sir, \"Recovery rate\", params[1]) set_param(model_sir, \"Transmission rate\", params[2]) run(model_sir, ndays = 50) res <- get_today_total(model_sir) return(res) } # Define the summary function sumfun <- function(dat, lfmcmc_obj) { return(dat) } # Create the LFMCMC model lfmcmc_model <- LFMCMC(model_sir) |> set_simulation_fun(simfun) |> set_summary_fun(sumfun) |> use_proposal_norm_reflective() |> use_kernel_fun_gaussian() |> set_observed_data(obs_data) ## Run LFMCMC simulation # Set initial parameters par0 <- c(0.1, 0.5) n_samp <- 2000 epsil <- 1.0 # Run the LFMCMC simulation verbose_off(lfmcmc_model) run_lfmcmc( lfmcmc = lfmcmc_model, params_init = par0, n_samples = n_samp, epsilon = epsil, seed = model_seed ) # Print the results set_stats_names(lfmcmc_model, get_states(model_sir)) set_params_names(lfmcmc_model, c(\"Immune recovery\", \"Infectiousness\")) print(lfmcmc_model) #> ___________________________________________ #> #> LIKELIHOOD-FREE MARKOV CHAIN MONTE CARLO #> #> N Samples (total) : 2000 #> N Samples (after burn-in period) : 2000 #> Elapsed t : 1.00s #> #> Parameters: #> -Immune recovery : 0.45 [ 0.14, 0.95] (initial : 0.10) #> -Infectiousness : 0.85 [ 0.54, 1.00] (initial : 0.50) #> #> Statistics: #> -Susceptible : 0.22 [ 0.00, 2.00] (Observed: 0.00) #> -Infected : 0.07 [ 0.00, 1.00] (Observed: 0.00) #> -Recovered : 995.71 [ 998.00, 1000.00] (Observed: 1000.00) #> ___________________________________________ #> get_mean_stats(lfmcmc_model) #> [1] 0.2215 0.0655 995.7130 get_mean_params(lfmcmc_model) #> [1] 0.4482147 0.8480773"},{"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 class '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 class '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":"/reference/ModelSEIR.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"initial_states function allows user set initial state model. user must provide vector proportions indicating following values: (1) Proportion non-infected agents removed, (2) Proportion exposed agents set infected.","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, 0 Infected, and 1000 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 class '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: 446 Susceptible, 4 Exposed, 3 Infected, and 9547 Recovered. plot(model_seirconn) # Adding the flu flu <- virus(\"Flu\", .9, 1 / 7, prevalence = 0.001, as_proportion = TRUE) add_virus(model_seirconn, flu) #' # 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: 0 Susceptible, 0 Exposed, 0 Infected, and 10000 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 class '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":"/reference/ModelSEIRD.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"initial_states function allows user set initial state model. user must provide vector proportions indicating following values: (1) Proportion exposed agents infected, (2) proportion non-infected agents already removed, (3) proportion non-ifected agents already deceased.","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: 2654 Susceptible, 383 Exposed, 1389 Infected, 87607 Removed, and 7967 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 class '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":"/reference/ModelSEIRDCONN.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"initial_states function allows user set initial state model. user must provide vector proportions indicating following values: (1) Proportion exposed agents infected, (2) proportion non-infected agents already removed, (3) proportion non-ifected agents already deceased.","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: 490 Susceptible, 2 Exposed, 1 Infected, 9280 Removed, and 227 Deceased. plot(model_seirdconn) # Adding the flu flu <- virus( \"Flu\", prob_infecting = .3, recovery_rate = 1 / 7, prob_death = 0.001, prevalence = 0.001, as_proportion = TRUE ) add_virus(model = model_seirdconn, virus = flu) #' # 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: 449 Susceptible, 8 Exposed, 8 Infected, 9331 Removed, and 204 Deceased. plot(model_seirdconn)"},{"path":"/reference/ModelSEIRMixing.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","text":"Susceptible Exposed Infected Removed model (SEIR) mixing","code":""},{"path":"/reference/ModelSEIRMixing.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","text":"","code":"ModelSEIRMixing( name, n, prevalence, contact_rate, transmission_rate, incubation_days, recovery_rate, contact_matrix ) # S3 method for class 'epiworld_seirmixing' plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSEIRMixing.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","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. incubation_days Numeric scalar. Average number days incubation period. recovery_rate Numeric scalar 0 1. Probability recovery. contact_matrix Matrix contact rates individuals. x Object class SIRCONN. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSEIRMixing.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","text":"ModelSEIRMixingfunction returns model class epiworld_model. plot function returns plot SEIRMixing model class epiworld_model.","code":""},{"path":"/reference/ModelSEIRMixing.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","text":"contact_matrix matrix contact rates entities. matrix size n x n, n number entities. row-stochastic matrix, .e., sum row 1. initial_states function allows user set initial state model. particular, user can specify many non-infected agents removed beginning simulation.","code":""},{"path":[]},{"path":"/reference/ModelSEIRMixing.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","text":"","code":"# Start off creating three entities. # Individuals will be distribured randomly between the three. e1 <- entity(\"Population 1\", 3e3, as_proportion = FALSE) e2 <- entity(\"Population 2\", 3e3, as_proportion = FALSE) e3 <- entity(\"Population 3\", 3e3, as_proportion = FALSE) # Row-stochastic matrix (rowsums 1) cmatrix <- c( c(0.9, 0.05, 0.05), c(0.1, 0.8, 0.1), c(0.1, 0.2, 0.7) ) |> matrix(byrow = TRUE, nrow = 3) N <- 9e3 flu_model <- ModelSEIRMixing( name = \"Flu\", n = N, prevalence = 1 / N, contact_rate = 20, transmission_rate = 0.1, recovery_rate = 1 / 7, incubation_days = 7, contact_matrix = cmatrix ) # Adding the entities to the model flu_model |> add_entity(e1) |> add_entity(e2) |> add_entity(e3) set.seed(331) run(flu_model, ndays = 100) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. summary(flu_model) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Exposed-Infected-Removed (SEIR) with Mixing #> Population size : 9000 #> Agents' data : (none) #> Number of entities : 3 #> Days (duration) : 100 (of 100) #> Number of viruses : 1 #> Last run elapsed t : 109.00ms #> Last run speed : 8.23 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - Flu #> #> Tool(s): #> (none) #> #> Model parameters: #> - Avg. Incubation days : 7.0000 #> - Contact rate : 20.0000 #> - Prob. Recovery : 0.1429 #> - Prob. Transmission : 0.1000 #> #> Distribution of the population at time 100: #> - (0) Susceptible : 8999 -> 137 #> - (1) Exposed : 1 -> 35 #> - (2) Infected : 0 -> 139 #> - (3) Recovered : 0 -> 8689 #> #> Transition Probabilities: #> - Susceptible 0.96 0.04 0.00 0.00 #> - Exposed 0.00 0.84 0.16 0.00 #> - Infected 0.00 0.00 0.86 0.14 #> - Recovered 0.00 0.00 0.00 1.00 #> plot_incidence(flu_model)"},{"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 class '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":"/reference/ModelSIR.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"SIR model — ModelSIR","text":"initial_states function allows user set initial state model. particular, user can specify many non-infected agents removed beginning simulation.","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, 3 Infected, and 997 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 class '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":"/reference/ModelSIRCONN.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"initial_states function allows user set initial state model. particular, user can specify many non-infected agents removed beginning simulation.","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: 2012 Susceptible, 0 Infected, and 7988 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 class '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":"/reference/ModelSIRD.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"SIRD model — ModelSIRD","text":"initial_states function allows user set initial state model. user must provide vector proportions indicating following values: (1) proportion non-infected agents already removed, (2) proportion non-ifected agents already deceased.","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, 0 Infected, 913 Recovered, and 87 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 class '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":"/reference/ModelSIRDCONN.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"initial_states function allows user set initial state model. user must provide vector proportions indicating following values: (1) proportion non-infected agents already removed, (2) proportion non-ifected agents already deceased.","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: 3678 Susceptible, 0 Infected, 86905 Recovered, and 9417 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.13466 0.14878 # Looking into the individual agents. get_agents(model_logit) #> Agents from the model \"Susceptible-Infected-Removed (SIR) (logit)\": #> Agent: 0, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 1, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 2, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 3, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 4, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 5, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 6, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 7, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 8, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 9, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> ... 99990 more agents ..."},{"path":"/reference/ModelSIRMixing.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","text":"Susceptible Infected Removed model (SIR) mixing","code":""},{"path":"/reference/ModelSIRMixing.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","text":"","code":"ModelSIRMixing( name, n, prevalence, contact_rate, transmission_rate, recovery_rate, contact_matrix ) # S3 method for class 'epiworld_sirmixing' plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIRMixing.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","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. contact_matrix Matrix contact rates individuals. x Object class SIRCONN. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSIRMixing.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","text":"ModelSIRMixingfunction returns model class epiworld_model. plot function returns plot SIRMixing model class epiworld_model.","code":""},{"path":"/reference/ModelSIRMixing.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","text":"contact_matrix matrix contact rates entities. matrix size n x n, n number entities. row-stochastic matrix, .e., sum row 1. initial_states function allows user set initial state model. particular, user can specify many non-infected agents removed beginning simulation.","code":""},{"path":[]},{"path":"/reference/ModelSIRMixing.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","text":"","code":"# From the vignette # Start off creating three entities. # Individuals will be distribured randomly between the three. e1 <- entity(\"Population 1\", 3e3, as_proportion = FALSE) e2 <- entity(\"Population 2\", 3e3, as_proportion = FALSE) e3 <- entity(\"Population 3\", 3e3, as_proportion = FALSE) # Row-stochastic matrix (rowsums 1) cmatrix <- c( c(0.9, 0.05, 0.05), c(0.1, 0.8, 0.1), c(0.1, 0.2, 0.7) ) |> matrix(byrow = TRUE, nrow = 3) N <- 9e3 flu_model <- ModelSIRMixing( name = \"Flu\", n = N, prevalence = 1 / N, contact_rate = 20, transmission_rate = 0.1, recovery_rate = 1 / 7, contact_matrix = cmatrix ) # Adding the entities to the model flu_model |> add_entity(e1) |> add_entity(e2) |> add_entity(e3) set.seed(331) run(flu_model, ndays = 100) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. summary(flu_model) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Removed (SIR) with Mixing #> Population size : 9000 #> Agents' data : (none) #> Number of entities : 3 #> Days (duration) : 100 (of 100) #> Number of viruses : 1 #> Last run elapsed t : 59.00ms #> Last run speed : 15.06 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - Flu #> #> Tool(s): #> (none) #> #> Model parameters: #> - Contact rate : 20.0000 #> - Prob. Recovery : 0.1429 #> - Prob. Transmission : 0.1000 #> #> Distribution of the population at time 100: #> - (0) Susceptible : 8999 -> 134 #> - (1) Infected : 1 -> 0 #> - (2) Recovered : 0 -> 8866 #> #> Transition Probabilities: #> - Susceptible 0.96 0.04 0.00 #> - Infected 0.00 0.87 0.13 #> - Recovered 0.00 0.00 1.00 #> plot_incidence(flu_model)"},{"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 class '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: 99 Susceptible, and 901 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 class '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: 94 Susceptible, 441 Infected, and 465 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 class '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: 9974 Susceptible, 0 Latent, 0 Symptomatic, 0 Symptomatic isolated, 0 Asymptomatic, 0 Asymptomatic isolated, 26 Recovered, and 0 Removed. # Plotting plot(model_surv, main = \"SURV Model\")"},{"path":"/reference/agents.html","id":null,"dir":"Reference","previous_headings":"","what":"Agents in epiworldR — agents","title":"Agents in epiworldR — 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/agents.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Agents in epiworldR — agents","text":"","code":"get_agents(model, ...) # S3 method for class 'epiworld_model' get_agents(model, ...) # S3 method for class 'epiworld_agents' x[i] # S3 method for class 'epiworld_agent' print(x, compressed = FALSE, ...) # S3 method for class 'epiworld_agents' print(x, compressed = TRUE, max_print = 10, ...) get_state(x)"},{"path":"/reference/agents.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Agents in epiworldR — agents","text":"model object class epiworld_model. ... Ignored x object class epiworld_agents Index (id) agent (0 n-1) compressed Logical scalar. FALSE, prints detailed information agent. max_print Integer scalar. Maximum number agents print.","code":""},{"path":"/reference/agents.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Agents in epiworldR — 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/agents.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Agents in epiworldR — 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 : Susceptible (0) #> Has virus : no #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 1 #> State : Recovered (2) #> Has virus : no #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 2 #> State : Susceptible (0) #> Has virus : no #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 3 #> State : Susceptible (0) #> Has virus : no #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 4 #> State : Susceptible (0) #> Has virus : no #> 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 : Susceptible (0) #> Has virus : no #> Tool count : 0 #> Neigh. count : 0 # interest's position where '0' is."},{"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)"},{"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).","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, 3 Infected, and 997 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/entities.html","id":null,"dir":"Reference","previous_headings":"","what":"Get entities — entities","title":"Get entities — entities","text":"Entities epiworld objects can contain agents.","code":""},{"path":"/reference/entities.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get entities — entities","text":"","code":"get_entities(model) # S3 method for class 'epiworld_entities' x[i] entity(name, prevalence, as_proportion, to_unassigned = TRUE) get_entity_size(entity) get_entity_name(entity) entity_add_agent(entity, agent, model = attr(entity, \"model\")) rm_entity(model, id) add_entity(model, entity) load_agents_entities_ties(model, agents_id, entities_id) entity_get_agents(entity) distribute_entity_randomly(prevalence, as_proportion, to_unassigned = TRUE) distribute_entity_to_set(agents_ids) set_distribution_entity(entity, distfun)"},{"path":"/reference/entities.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get entities — entities","text":"model Model object class epiworld_model. x Object class epiworld_entities. Integer index. name Character scalar. Name entity. prevalence Numeric scalar. Prevalence entity. as_proportion Logical scalar. TRUE, prevalence interpreted proportion. to_unassigned Logical scalar. TRUE, entity added unassigned pool. entity Entity object class epiworld_entity. agent Agent object class epiworld_agent. id Integer scalar. Entity id remove (starting zero). agents_id Integer vector. entities_id Integer vector. agents_ids Integer vector. Ids agents distribute. distfun Distribution function object class epiworld_distribution_entity.","code":""},{"path":"/reference/entities.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get entities — entities","text":"function entity creates entity object. function get_entity_size returns number agents entity. function get_entity_name returns name entity. function entity_add_agent adds agent entity. function rm_entity removes entity model. function load_agents_entities_ties loads agents entities. function entity_get_agents returns integer vector agents entity (ids).","code":""},{"path":"/reference/entities.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Get entities — entities","text":"Epiworld entities especially useful mixing models, particularly ModelSIRMixing ModelSEIRMixing.","code":""},{"path":"/reference/entities.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get entities — entities","text":"","code":"# Creating a mixing model mymodel <- ModelSIRMixing( name = \"My model\", n = 10000, prevalence = .001, contact_rate = 10, transmission_rate = .1, recovery_rate = 1 / 7, contact_matrix = matrix(c(.9, .1, .1, .9), 2, 2) ) ent1 <- entity(\"First\", 5000, FALSE) ent2 <- entity(\"Second\", 5000, FALSE) mymodel |> add_entity(ent1) |> add_entity(ent2) run(mymodel, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. summary(mymodel) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Removed (SIR) with Mixing #> Population size : 10000 #> Agents' data : (none) #> Number of entities : 2 #> Days (duration) : 100 (of 100) #> Number of viruses : 1 #> Last run elapsed t : 60.00ms #> Last run speed : 16.63 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - My model #> #> Tool(s): #> (none) #> #> Model parameters: #> - Contact rate : 10.0000 #> - Prob. Recovery : 0.1429 #> - Prob. Transmission : 0.1000 #> #> Distribution of the population at time 100: #> - (0) Susceptible : 9990 -> 376 #> - (1) Infected : 10 -> 1 #> - (2) Recovered : 0 -> 9623 #> #> Transition Probabilities: #> - Susceptible 0.97 0.03 0.00 #> - Infected 0.00 0.86 0.14 #> - Recovered 0.00 0.00 1.00 #>"},{"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 class '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 class 'epiworld_hist_transition' as.array(x, ...) plot_incidence(x, ...) # S3 method for class '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 class '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.9028099 0.09719012 0.0000000 0.0000000 #> Exposed 0.0000000 0.85844742 0.1415526 0.0000000 #> Infected 0.0000000 0.00000000 0.7000978 0.2999022 #> 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 861 # 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 861 # 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 861 139 0 #> Infected 0 0 0 0 #> Recovered 0 0 0 0 #> #> , , 2 #> #> Susceptible Exposed Infected Recovered #> Susceptible 8822 178 0 0 #> Exposed 0 737 124 0 #> Infected 0 0 92 47 #> 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 = NULL) # S3 method for class 'epiworld_model' summary(object, ...) get_states(x) get_param(x, pname) add_param(x, pname, pval) # S3 method for class 'epiworld_model' add_param(x, pname, pval) set_param(x, pname, pval) set_name(x, mname) get_name(x) get_n_viruses(x) get_n_tools(x) get_ndays(x) today(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) initial_states(model, proportions) clone_model(model)"},{"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 (passed set.seed()). 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 proportions Numeric vector. Proportions agents distributed (see details).","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. add_param returns model added parameter invisibly. 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. today returns current model day 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. inital_states returns model updated initial state. clone_model returns copy model.","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. epiworld_model objects pointers underlying C++ class epiworld. generate copy model, use clone_model, otherwise, assignment operator copy pointer.","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) #> Warning: SIR Connected models do not have queue. 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. today(model_sirconn) # Returns the current day of the simulation. This will #> [1] 100 # match \"get_ndays()\" if run at the end of a simulation, but will differ if run # during a simulation 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, prevalence = 0.5, as_prop = TRUE)) 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-deprecated.html","id":null,"dir":"Reference","previous_headings":"","what":"Deprecated and removed functions in epiworldR — epiworldR-deprecated","title":"Deprecated and removed functions in epiworldR — epiworldR-deprecated","text":"Starting version 0.0-4, epiworld changed refered \"actions.\" Following traditional ABMs, actions now called \"events.\"","code":""},{"path":"/reference/epiworldR-deprecated.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Deprecated and removed functions in epiworldR — epiworldR-deprecated","text":"","code":"add_tool_n(model, tool, n) add_virus_n(model, virus, n) globalaction_tool(...) globalaction_tool_logit(...) globalaction_set_params(...) globalaction_fun(...)"},{"path":"/reference/epiworldR-deprecated.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Deprecated and removed functions in epiworldR — epiworldR-deprecated","text":"model Model object class epiworld_model. tool Tool object class epiworld_tool. n Deprecated. virus Virus object class epiworld_virus. ... Arguments passed new function.","code":""},{"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: Andrew Pulsipher pulsipher.@gmail.com (ORCID) Authors: George Vega Yon g.vegayon@gmail.com (ORCID) Derek Meyer derekmeyer37@gmail.com (ORCID) contributors: Susan Holmes (ORCID) (JOSS reviewer) [reviewer] Abinash Satapathy (ORCID) (JOSS reviewer) [reviewer] Carinogurjao [reviewer] Centers Disease Control Prevention (Award number 1U01CK000585; 75D30121F00003) [funder]","code":""},{"path":"/reference/global-events.html","id":null,"dir":"Reference","previous_headings":"","what":"Global Events — global-events","title":"Global Events — global-events","text":"Global events functions executed time step simulation. useful implementing interventions, vaccination, isolation, social distancing means tools.","code":""},{"path":"/reference/global-events.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Global Events — global-events","text":"","code":"globalevent_tool(tool, prob, name = get_name_tool(tool), day = -99) globalevent_tool_logit( tool, vars, coefs, name = get_name_tool(tool), day = -99 ) globalevent_set_params( param, value, name = paste0(\"Set \", param, \" to \", value), day = -99 ) globalevent_fun(fun, name = deparse(substitute(fun)), day = -99) add_globalevent(model, event, action = NULL) rm_globalevent(model, event)"},{"path":"/reference/global-events.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Global Events — global-events","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. event event added removed. add, object class epiworld_globalevent. remove, integer position event model (starting zero). action (Deprecated) use event instead.","code":""},{"path":"/reference/global-events.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Global Events — global-events","text":"globalevent_set_params function returns object class epiworld_globalevent_set_param epiworld_globalevent. globalevent_tool returns object class epiworld_globalevent_tool epiworld_globalevent. globalevent_tool_logit returns object class epiworld_globalevent_tool_logit epiworld_globalevent. function add_globalevent returns model added event function rm_globalevent returns model removed event.","code":""},{"path":"/reference/global-events.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Global Events — global-events","text":"function globalevent_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 globalevent_set_param allows set parameter model. parameter specified name param value value. function globalevent_fun allows specify function executed given day. function object must receive object class epiworld_model argument. function add_globalevent 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-events.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Global Events — global-events","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\", prevalence = 0, as_proportion = FALSE, susceptibility_reduction = .9, transmission_reduction = .5, recovery_enhancer = .5, death_reduction = .9 ) # Adding a global event vaccine_day_20 <- globalevent_tool(epitool, .2, day = 20) add_globalevent(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: 2012 Susceptible, 0 Infected, and 7988 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 <- globalevent_set_params(\"Contact rate\", 0, day = 10) add_globalevent(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: 2083 Susceptible, 0 Infected, and 7917 Recovered. plot_incidence(model_sirconn2) # Example using `globalevent_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, nthreads = 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 981 #> 5 1 1 1 Infected 18 #> 6 1 1 1 Recovered 1 head(ans$reproductive) #> sim_num virus_id virus source source_exposure_date rt #> 1 1 0 COVID-19 519 10 0 #> 2 1 0 COVID-19 152 9 0 #> 3 1 0 COVID-19 949 8 0 #> 4 1 0 COVID-19 921 8 0 #> 5 1 0 COVID-19 855 8 0 #> 6 1 0 COVID-19 816 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, prevalence, as_proportion, susceptibility_reduction, transmission_reduction, recovery_enhancer, death_reduction ) set_name_tool(tool, name) get_name_tool(tool) add_tool(model, tool, proportion) 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 class 'epiworld_agents_tools' print(x, max_print = 10, ...) set_distribution_tool(tool, distfun) distribute_tool_randomly(prevalence, as_proportion) distribute_tool_to_set(agents_ids)"},{"path":"/reference/tool.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tools in epiworld — tool","text":"name Name tool prevalence Numeric scalar. Prevalence tool. as_proportion Logical scalar. TRUE, prevalence interpreted proportion total number agents model. 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 Deprecated. 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. distfun object class epiworld_tool_distfun. agents_ids Integer vector. Indices agents tool assigned.","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. 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. distribute_tool_randomly function returns distribution function class epiworld_tool_distfun. distribute_tool_to_set function returns distribution function class epiworld_tool_distfun.","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. set_distribution_tool function assigns distribution function specified tool class epiworld_tool. distribution function can created using functions distribute_tool_randomly() distribute_tool_to_set(). distribute_tool_randomly function creates distribution function randomly assigns tool proportion population. distribute_tool_to_set function creates distribution function assigns tool set agents.","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\", prevalence = 0.5, as_proportion = TRUE, 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) 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: 8804 Susceptible, 0 Infected, and 1196 Recovered. plot(model_sirconn) # To declare a certain number of individuals with the tool rm_tool(model_sirconn, 0) # Removing epitool from the model # Setting prevalence to 0.1 set_distribution_tool(epitool, distribute_tool_randomly(0.1, TRUE)) add_tool(model_sirconn, epitool) 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 set_recovery_enhancer(epitool, 0.15) # Probability increase of recovery set_death_reduction(epitool, 0.05) # Probability reduction of death rm_tool(model_sirconn, 0) add_tool(model_sirconn, epitool) 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\", prevalence = 0.5, as_proportion = TRUE, susceptibility_reduction = 0.0, transmission_reduction = 0.3, # Only transmission recovery_enhancer = 0.0, death_reduction = 0.0 ) add_tool(sir, mask_wearing) 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, prevalence, as_proportion, 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) 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) set_distribution_virus(virus, distfun) distribute_virus_randomly(prevalence, as_proportion) distribute_virus_set(agents_ids)"},{"path":"/reference/virus.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Virus design — virus","text":"name virus prevalence Numeric scalar. Prevalence virus. as_proportion Logical scalar. TRUE, prevalence set proportion total number agents model. 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 Deprecated. 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. distfun object class epiworld_distribution_virus. agents_ids Integer vector. Indices agents receive virus.","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. 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. distribute_virus_randomly function returns function can used distribute virus model.","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. distribute_virus_randomly function factory function used randomly distribute virus model. prevalence can set proportion number agents. resulting function can passed set_distribution_virus.","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, prevalence = 0.3, as_proportion = TRUE ) # Adding virus and setting/getting virus name add_virus(mseirconn, delta) 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: 3609 Susceptible, 113 Exposed, 11 Infected, and 6267 Recovered. rm_virus(mseirconn, 0) # Removing the first virus from the model object set_distribution_virus(delta, distribute_virus_randomly(100, as_proportion = FALSE)) add_virus(mseirconn, delta) # 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, prevalence = 0, as_proportion = TRUE ) 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-0610","dir":"Changelog","previous_headings":"","what":"epiworldR 0.6.1.0","title":"epiworldR 0.6.1.0","text":"Updates reflect changes epiworld C++ library (mostly bug fixes) Package now requires R version >=4.1.0, uses pipe |>","code":""},{"path":"/news/index.html","id":"epiworldr-0600","dir":"Changelog","previous_headings":"","what":"epiworldR 0.6.0.0","title":"epiworldR 0.6.0.0","text":"CRAN release: 2025-01-16 package now includes LFMCMC module implements likelihood-free Markov Chain Monte Carlo algorithm. module used estimate parameters models. new function add_param() allows user add parameters model. new function rm_globalevent() allows user remove global events model. function today() returns current day (step) simulation. changed versioning system. allow R package increase version number preserving epiworld (C++) versioning, added fourth number indicates R-patches (similar RcppArmadillo).","code":""},{"path":"/news/index.html","id":"epiworldr-03-2","dir":"Changelog","previous_headings":"","what":"epiworldR 0.3-2","title":"epiworldR 0.3-2","text":"CRAN release: 2024-10-08 Starting version 0.3-0, epiworldR versioned using version C++ library, epiworld. Adds new mixing models ModelSIRMixing ModelSEIRMixing. Ports Entity class. Entities used group agents within model. Refactors add_tool, add_virus, add_entity simplifying syntax. Now, functions receive model object. Prevalence specified object . add_tool_n add_virus_n now deprecated. globalaction_* now defunct. Use globalevent_* instead. New functions specify viruses, tools, entities distributed among agents: distribute_viruses, distribute_tools, distribute_entities.","code":""},{"path":"/news/index.html","id":"epiworldr-01-0","dir":"Changelog","previous_headings":"","what":"epiworldR 0.1-0","title":"epiworldR 0.1-0","text":"CRAN release: 2024-04-08 Force model update agents’ states running simulation. causing issues calling run_multiple() single call run(). Reported 14.","code":""},{"path":"/news/index.html","id":"epiworldr-00-4","dir":"Changelog","previous_headings":"","what":"epiworldR 0.0-4","title":"epiworldR 0.0-4","text":"CRAN release: 2024-02-09 Added missing checks tool class adding model add_too_n. Various small improvements.","code":""},{"path":"/news/index.html","id":"epiworldr-00-3","dir":"Changelog","previous_headings":"","what":"epiworldR 0.0-3","title":"epiworldR 0.0-3","text":"CRAN release: 2023-09-08 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 13\\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,276, number agents infected state increased 5 1, recovered agents increased 46,723 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 events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - COVID-19 #> #> 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 : 88.00ms #> Last run speed : 28.24 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - COVID-19 #> #> 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 -> 3276 #> - (1) Infected : 5 -> 1 #> - (2) Recovered : 0 -> 46723 #> #> Transition Probabilities: #> - Susceptible 0.95 0.05 0.00 #> - Infected 0.00 0.69 0.31 #> - 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_param add_tool #> [3] add_virus agents_from_edgelist #> [5] agents_smallworld get_agents #> [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] today verbose_off #> [33] 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 49988 #> 5 1 Infected 12 #> 6 1 Recovered 0 repnum <- get_reproductive_number(model_sir) head(repnum) #> virus_id virus source source_exposure_date rt #> 1 0 COVID-19 7312 44 0 #> 2 0 COVID-19 46328 43 0 #> 3 0 COVID-19 43475 42 0 #> 4 0 COVID-19 23672 42 0 #> 5 0 COVID-19 18224 42 1 #> 6 0 COVID-19 48317 41 2 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.601587 630 2.29016 0 8 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, prevalence = .0001, as_proportion = TRUE ) # Adding the virus to the model add_virus(model_sir, flu) 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: 3285 Susceptible, 3 Infected, and 46712 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\", prevalence = 0.5, as_proportion = TRUE, susceptibility_reduction = .9, transmission_reduction = .5, recovery_enhancer = .5, death_reduction = .9 ) add_tool(model_sir, vaccine) 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 ii infects agent jj, agent jj able infect agent ii 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 ii jj given following formula: P(→j|one)=pij×∏k≠(1−pkj)∏k(1−pkj)+∑kpkj×∏l≠k(1−plj) 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 pijp_{ij} computed function ii, jj, 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, pij=pv×(1−factorhost)×(1−factortarget) p_{ij} = p_{v} \\times \\left(1 - factor_{host}\\right) \\times \\left(1 - factor_{target}\\right) pvp_{v} raw transmission probability virus vv, factortfactor_{t} increasing/reducing factors tools process. example, p_v 0.9, host wearing mask, factormask host=0.3factor_{\\mbox{mask host}} = 0.3 target vaccinated, factorvaccinated target=0.5factor_{\\mbox{vaccinated target}} = 0.5, adjusted probability pijp_{ij} 0.9×(1−0.3)×(1−0.5)=0.270.9 \\times (1 - 0.3) \\times (1 - 0.5) = 0.27. agents one tool, factors combined follows: factoragent=1−∏t∈toolsagent(1−factort) factor_{agent} = 1 - \\prod_{t\\tools_{agent}}\\left(1 - factor_{t}\\right) Therefore, example, vaccinated agent wearing mask factor 1−(1−0.30)×(1−0.5)=0.651 - (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 cc drawn binomial distribution parameters nn pp, nn number agents p=p =contact_rate/n/ n. , cc agents randomly selected population. Transmission can occur agents susceptible agent. probability transmission cc agents calculated described previous section.","code":""},{"path":"/articles/likelihood-free-mcmc.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Likelihood Free Markhov Chain Monte Carlo (LFMCMC)","text":"purpose “LFMCMC” class epiworldR perform Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) simulation. LFMCMC used approximate models likelihood function either unavailable computationally expensive. example assumes general understanding LFMCMC. learn , see Handbook Markhov Chain Monte Carlo Brooks et al. https://doi.org/10.1201/b10905. example, use LFMCMC recover parameters SIR model.","code":""},{"path":"/articles/likelihood-free-mcmc.html","id":"setup-the-sir-model","dir":"Articles","previous_headings":"","what":"Setup The SIR Model","title":"Likelihood Free Markhov Chain Monte Carlo (LFMCMC)","text":"SIR model following characteristics: Virus Name: COVID-19 Initial Virus Prevalence: 0.01 Recovery Rate: 1/7 (0.14) Transmission Rate: 0.1 Number Agents: 2,000 use ModelSIR agents_smallworld functions construct model epiworldR. run model 50 days print results. Note “Model parameters” “Distribution population time 50” output. goal recover model parameters (Recovery Transmission rates) LFMCMC. accomplish comparing population distribution simulation run “observed” distribution model. get distribution using get_today_total function epiworldR. practical cases, use observed data, instead model simulation. use simulation example show accuracy LFMCMC recovering model parameters. Whenever use term “observed data” , referring model distribution (model_sir_data).","code":"library(epiworldR) model_seed <- 122 model_sir <- ModelSIR( name = \"COVID-19\", prevalence = .01, transmission_rate = .1, recovery_rate = 1 / 7 ) agents_smallworld( model_sir, n = 2000, k = 5, d = FALSE, p = 0.01 ) verbose_off(model_sir) run( model_sir, ndays = 50, seed = model_seed ) summary(model_sir) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Recovered (SIR) #> Population size : 2000 #> Agents' data : (none) #> Number of entities : 0 #> Days (duration) : 50 (of 50) #> Number of viruses : 1 #> Last run elapsed t : 291.00µs #> Last run speed : 343.64 million agents x day / second #> Rewiring : off #> #> Global events: #> (none) #> #> Virus(es): #> - COVID-19 #> #> Tool(s): #> (none) #> #> Model parameters: #> - Recovery rate : 0.1429 #> - Transmission rate : 0.1000 #> #> Distribution of the population at time 50: #> - (0) Susceptible : 1980 -> 1865 #> - (1) Infected : 20 -> 0 #> - (2) Recovered : 0 -> 135 #> #> Transition Probabilities: #> - Susceptible 1.00 0.00 0.00 #> - Infected 0.00 0.85 0.15 #> - Recovered 0.00 0.00 1.00 model_sir_data <- get_today_total(model_sir)"},{"path":"/articles/likelihood-free-mcmc.html","id":"setup-lfmcmc","dir":"Articles","previous_headings":"","what":"Setup LFMCMC","title":"Likelihood Free Markhov Chain Monte Carlo (LFMCMC)","text":"epiworldR, LFMCMC requires four functions: simulation function runs model given set parameters produces output matches structure observed data. example, set Recovery Transmission rate parameters, run SIR model 50 days, return distribution population end run. summary function extracts summary statistics given data. produce output format observed data simulated data simulation_fun. example, since population distribution already summary data, summary function simply passes data . complicated use cases, might instead compute summary statistics mean standard deviation. proposal function returns new set parameters, “proposing” parameters LFMCMC algorithm try simulation function. example, takes parameters previous run (old_params) random step away values. kernel function effectively scores results latest simulation run observed data, comparing summary statistics summary_fun . LFMCMC uses kernel score Hastings Ratio determine whether accept parameters run. example, since summary_fun simply passes data , simulated_stats observed_stats simulated observed data respectively. four functions defined, can initialize simulation object using LFMCMC function epiworldR along appropriate setter functions.","code":"simulation_fun <- function(params, lfmcmc_obj) { set_param(model_sir, \"Recovery rate\", params[1]) set_param(model_sir, \"Transmission rate\", params[2]) run( model_sir, ndays = 50 ) get_today_total(model_sir) } summary_fun <- function(data, lfmcmc_obj) { return(data) } proposal_fun <- function(old_params, lfmcmc_obj) { res <- plogis(qlogis(old_params) + rnorm(length(old_params), sd = .1)) return(res) } kernel_fun <- function( simulated_stats, observed_stats, epsilon, lfmcmc_obj ) { diff <- ((simulated_stats - observed_stats)^2)^epsilon dnorm(sqrt(sum(diff))) } lfmcmc_model <- LFMCMC(model_sir) |> set_simulation_fun(simulation_fun) |> set_summary_fun(summary_fun) |> set_proposal_fun(proposal_fun) |> set_kernel_fun(kernel_fun) |> set_observed_data(model_sir_data)"},{"path":"/articles/likelihood-free-mcmc.html","id":"run-lfmcmc-simulation","dir":"Articles","previous_headings":"","what":"Run LFMCMC Simulation","title":"Likelihood Free Markhov Chain Monte Carlo (LFMCMC)","text":"run LFMCMC, need set initial model parameters. example, use initial Recovery rate 0.3 initial Transmission rate 0.3. set kernel epsilon 1.0 run simulation 2,000 samples (iterations) using run_lfmcmc function.","code":"initial_params <- c(0.3, 0.3) epsilon <- 1.0 n_samples <- 2000 # Run the LFMCMC simulation run_lfmcmc( lfmcmc = lfmcmc_model, params_init = initial_params, n_samples = n_samples, epsilon = epsilon, seed = model_seed ) #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done."},{"path":"/articles/likelihood-free-mcmc.html","id":"results","dir":"Articles","previous_headings":"","what":"Results","title":"Likelihood Free Markhov Chain Monte Carlo (LFMCMC)","text":"make printed results easier read, use set_params_names set_stats_names functions calling print. also use burn-period 1,500 samples. can also look trace parameters: Recall observed data came model Recovery rate 0.3 Transmission rate 0.3. output shows, LFMCMC made close approximation parameters, resulted close approximation observed population distribution. example highlights effectiveness using LFMCMC highly complex models.","code":"set_params_names(lfmcmc_model, c(\"Recovery rate\", \"Transmission rate\")) set_stats_names(lfmcmc_model, get_states(model_sir)) print(lfmcmc_model, burnin = 1500) #> ___________________________________________ #> #> LIKELIHOOD-FREE MARKOV CHAIN MONTE CARLO #> #> N Samples (total) : 2000 #> N Samples (after burn-in period) : 500 #> Elapsed t : 1.00s #> #> Parameters: #> -Recovery rate : 0.14 [ 0.13, 0.15] (initial : 0.30) #> -Transmission rate : 0.09 [ 0.09, 0.10] (initial : 0.30) #> #> Statistics: #> -Susceptible : 1865.49 [ 1864.00, 1866.00] (Observed: 1865.00) #> -Infected : 0.00 [ 0.00, 0.00] (Observed: 0.00) #> -Recovered : 134.51 [ 134.00, 136.00] (Observed: 135.00) #> ___________________________________________ # Extracting the accepted parameters accepted <- get_all_accepted_params(lfmcmc_model) # Plotting the trace plot( accepted[, 1], type = \"l\", ylim = c(0, 1), main = \"Trace of the parameters\", lwd = 2, col = \"tomato\", xlab = \"Step\", ylab = \"Parameter value\" ) lines(accepted[, 2], type = \"l\", lwd = 2, col = \"steelblue\") legend( \"topright\", bty = \"n\", legend = c(\"Recovery rate\", \"Transmission rate\"), pch = 20, col = c(\"tomato\", \"steelblue\") )"},{"path":"/articles/mixing.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Mixing models","text":"vignette shows create mixing model using epiworldR package. Mixing models feature multiple populations. group, called Entities, subset agents. agents can interact within group agents groups. contact matrix defines interaction agents.","code":""},{"path":"/articles/mixing.html","id":"an-seir-model-with-mixing","dir":"Articles","previous_headings":"","what":"An SEIR model with mixing","title":"Mixing models","text":"example, simulate outbreak featuring three populations. contact matrix defined follows: [0.90.050.050.10.80.10.10.20.7] \\left[% \\begin{array}{ccc} 0.9 & 0.05 & 0.05 \\\\ 0.1 & 0.8 & 0.1 \\\\ 0.1 & 0.2 & 0.7 \\\\ \\end{array}% \\right] matrix represents probability agent population ii interacting agent population jj. matrix row-stochastic, meaning sum row equal 1. build model using entity class epiworld. following code chunk instantiates three entities contact matrix. hand, can proceed create mixing model. following code chunk creates model, SEIR mixing, adds entities model: function add_entity adds corresponding entity. default behavior randomly assigns agents entities beginning simulation. Agents may assigned one entity. following code-chunk simulates model 100 days, summarizes results, plots incidence curve:","code":"library(epiworldR) e1 <- entity(\"Population 1\", 3e3, as_proportion = FALSE) e2 <- entity(\"Population 2\", 3e3, as_proportion = FALSE) e3 <- entity(\"Population 3\", 3e3, as_proportion = FALSE) # Row-stochastic matrix (rowsums 1) cmatrix <- c( c(0.9, 0.05, 0.05), c(0.1, 0.8, 0.1), c(0.1, 0.2, 0.7) ) |> matrix(byrow = TRUE, nrow = 3) N <- 9e3 flu_model <- ModelSEIRMixing( name = \"Flu\", n = N, prevalence = 1 / N, contact_rate = 20, transmission_rate = 0.1, recovery_rate = 1 / 7, incubation_days = 7, contact_matrix = cmatrix ) # Adding the entities flu_model |> add_entity(e1) |> add_entity(e2) |> add_entity(e3) set.seed(331) run(flu_model, ndays = 100) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. summary(flu_model) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Exposed-Infected-Removed (SEIR) with Mixing #> Population size : 9000 #> Agents' data : (none) #> Number of entities : 3 #> Days (duration) : 100 (of 100) #> Number of viruses : 1 #> Last run elapsed t : 108.00ms #> Last run speed : 8.28 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - Flu #> #> Tool(s): #> (none) #> #> Model parameters: #> - Avg. Incubation days : 7.0000 #> - Contact rate : 20.0000 #> - Prob. Recovery : 0.1429 #> - Prob. Transmission : 0.1000 #> #> Distribution of the population at time 100: #> - (0) Susceptible : 8999 -> 137 #> - (1) Exposed : 1 -> 35 #> - (2) Infected : 0 -> 139 #> - (3) Recovered : 0 -> 8689 #> #> Transition Probabilities: #> - Susceptible 0.96 0.04 0.00 0.00 #> - Exposed 0.00 0.84 0.16 0.00 #> - Infected 0.00 0.00 0.86 0.14 #> - Recovered 0.00 0.00 0.00 1.00 plot_incidence(flu_model)"},{"path":"/articles/mixing.html","id":"investigating-the-history","dir":"Articles","previous_headings":"","what":"Investigating the history","title":"Mixing models","text":"running simulation, possible question : many agents entity infected day? following code chunk retrieves agents entity transmissions occurred simulation: can retrieve daily incidence entity merging transmissions agents’ entities. following code chunk accomplishes : information, can now visualize daily incidence entity. following code chunk plots daily incidence entity:","code":"library(data.table) agents_entities <- lapply(get_entities(flu_model), \\(e) { entity_get_agents(e) }) |> rbindlist() head(agents_entities) #> agent entity #> #> 1: 507 0 #> 2: 1710 0 #> 3: 8984 0 #> 4: 7844 0 #> 5: 760 0 #> 6: 4379 0 # Retrieving the transmissions transmissions <- get_transmissions(flu_model) |> data.table() # We only need the date and the source transmissions <- subset( transmissions, select = c(\"date\", \"source\") ) # Attaching the entity to the source transmissions <- merge( transmissions, agents_entities, by.x = \"source\", by.y = \"agent\" ) # Aggregating by date x entity (counts) transmissions <- transmissions[, .N, by = .(date, entity)] # Taking a look at the data head(transmissions) #> date entity N #> #> 1: 75 1 12 #> 2: 47 0 114 #> 3: 51 0 133 #> 4: 52 0 152 #> 5: 47 2 74 #> 6: 48 2 87 setorder(transmissions, date, entity) ran <- range(transmissions$N) transmissions[entity == 0, plot( x = date, y = N, type = \"l\", col = \"black\", ylim = ran)] #> NULL transmissions[entity == 1, lines(x = date, y = N, col = \"red\")] #> NULL transmissions[entity == 2, lines(x = date, y = N, col = \"blue\")] #> NULL legend( \"topright\", legend = c(\"Population 1\", \"Population 2\", \"Population 3\"), col = c(\"black\", \"red\", \"blue\"), lty = 1 )"},{"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 13\\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, nthreads = 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 2 0 COVID-19 9964 50 0 #> 2 2 0 COVID-19 9828 50 0 #> 3 2 0 COVID-19 9689 50 0 #> 4 2 0 COVID-19 9687 50 0 #> 5 2 0 COVID-19 9651 50 0 #> 6 2 0 COVID-19 9277 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":"George Vega Yon. Author. Derek Meyer. Author. Andrew Pulsipher. Author, maintainer. 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, Derek Vega Yon, George (2023). epiworldR: Fast Agent-Based Epi Models. Journal Open Source Software, 8(90), 5781, https://doi.org/10.21105/joss.05781 Meyer D, Pulsipher , Vega Yon G (2025). epiworldR: Fast Agent-Based Epi Models. R package version 0.6.1.0, https://github.com/UofUEpiBio/epiworldR.","code":"@Article{, entry = {Article}, title = {epiworldR: Fast Agent-Based Epi Models}, author = {Derek Meyer and George {Vega Yon}}, journal = {The Journal of Open Source Software}, year = {2023}, month = {oct}, volume = {8}, number = {90}, doi = {10.21105/joss.05781}, url = {https://joss.theoj.org/papers/10.21105/joss.05781}, } @Manual{, title = {{{epiworldR: Fast Agent-Based Epi Models}}}, author = {Derek Meyer and Andrew Pulsipher and George {Vega Yon}}, year = {2025}, note = {R package version 0.6.1.0}, url = {https://github.com/UofUEpiBio/epiworldR}, }"},{"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. Current available models: ModelDiffNet ModelSEIR ModelSEIRCONN ModelSEIRD ModelSEIRDCONN ModelSEIRMixing ModelSIR ModelSIRCONN ModelSIRD ModelSIRDCONN ModelSIRLogit ModelSIRMixing ModelSIS ModelSISD ModelSURV","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.","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: 1209 Susceptible, 499 Infected, and 98292 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 : 66.00ms #> Last run speed : 74.96 million agents x day / second #> Rewiring : off #> #> Global events: #> (none) #> #> Virus(es): #> - COVID-19 #> #> Tool(s): #> (none) #> #> Model parameters: #> - Recovery rate : 0.3000 #> - Transmission rate : 0.7000 #> #> Distribution of the population at time 50: #> - (0) Susceptible : 99000 -> 1209 #> - (1) Infected : 1000 -> 499 #> - (2) Recovered : 0 -> 98292 #> #> Transition Probabilities: #> - Susceptible 0.92 0.08 0.00 #> - Infected 0.00 0.70 0.30 #> - Recovered 0.00 0.00 1.00 plot(sir) plot_incidence(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 = 10, incubation_days = 7, transmission_rate = 0.1, recovery_rate = 1 / 7 ) |> add_virus( virus( name = \"COVID-19\", prevalence = 0.01, as_proportion = TRUE, prob_infecting = 0.01, recovery_rate = 0.6, prob_death = 0.5, incubation = 7 )) set.seed(132) run(model_seirconn, ndays = 100) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. summary(model_seirconn) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Exposed-Infected-Removed (SEIR) (connected) #> Population size : 10000 #> Agents' data : (none) #> Number of entities : 0 #> Days (duration) : 100 (of 100) #> Number of viruses : 2 #> Last run elapsed t : 15.00ms #> Last run speed : 65.69 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - COVID-19 #> - COVID-19 #> #> Tool(s): #> (none) #> #> Model parameters: #> - Avg. Incubation days : 7.0000 #> - Contact rate : 10.0000 #> - Prob. Recovery : 0.1429 #> - Prob. Transmission : 0.1000 #> #> Distribution of the population at time 100: #> - (0) Susceptible : 9800 -> 11 #> - (1) Exposed : 200 -> 0 #> - (2) Infected : 0 -> 3 #> - (3) Recovered : 0 -> 9986 #> #> Transition Probabilities: #> - Susceptible 0.94 0.06 0.00 0.00 #> - Exposed 0.00 0.85 0.15 0.00 #> - Infected 0.00 0.00 0.86 0.14 #> - Recovered 0.00 0.00 0.00 1.00 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 5.769231 91 5.455022 1.000 20.750 #> 2 0 COVID-19 2 6.400000 10 4.880801 0.450 14.875 #> 3 0 COVID-19 3 5.166667 18 4.422536 0.425 13.000 #> 4 0 COVID-19 4 4.659091 44 3.784566 0.000 12.850 #> 5 0 COVID-19 5 5.205882 34 3.273210 0.000 12.175 #> 6 0 COVID-19 6 3.137255 51 2.713077 0.000 8.750 head(plot_generation_time(model_seirconn)) #> date avg n sd ci_lower ci_upper virus virus_id #> 1 2 4.444444 9 2.185813 2.2 8.000 COVID-19 0 #> 2 3 7.411765 17 3.922034 2.4 15.000 COVID-19 0 #> 3 4 8.538462 39 7.100208 2.0 22.000 COVID-19 0 #> 4 5 6.312500 32 3.905641 2.0 13.225 COVID-19 0 #> 5 6 7.200000 40 4.052223 2.0 15.100 COVID-19 0 #> 6 7 7.660000 50 4.461216 2.0 17.000 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.13466 0.14878 # Looking into the agents get_agents(model_logit) #> Agents from the model \"Susceptible-Infected-Removed (SIR) (logit)\": #> Agent: 0, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 1, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 2, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 3, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 4, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 5, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 6, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 7, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 8, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 9, state: Susceptible (0), Has virus: no, NTools: 0i 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(epiworldR) library(netplot) #> Loading required package: grid x <- igraph::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:","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) #> _________________________________________________________________________ #> _________________________________________________________________________ #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 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 77 10 0 #> 2 1 0 COVID-19 970 8 0 #> 3 1 0 COVID-19 895 8 0 #> 4 1 0 COVID-19 866 8 0 #> 5 1 0 COVID-19 811 8 0 #> 6 1 0 COVID-19 752 8 0 plot(ans$reproductive)"},{"path":"/index.html","id":"tutorials","dir":"","previous_headings":"","what":"Tutorials","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":"citation","dir":"","previous_headings":"","what":"Citation","title":"Fast Agent-Based Epi Models","text":"use epiworldR research, please cite follows:","code":"citation(\"epiworldR\") #> To cite epiworldR in publications use: #> #> Meyer, Derek and Vega Yon, George (2023). epiworldR: Fast Agent-Based #> Epi Models. Journal of Open Source Software, 8(90), 5781, #> https://doi.org/10.21105/joss.05781 #> #> And the actual R package: #> #> Meyer D, Pulsipher A, Vega Yon G (2024). _epiworldR: Fast Agent-Based #> Epi Models_. R package version 0.6.0.0, #> . #> #> To see these entries in BibTeX format, use 'print(, #> bibtex=TRUE)', 'toBibtex(.)', or set #> 'options(citation.bibtex.max=999)'."},{"path":"/index.html","id":"existing-alternatives","dir":"","previous_headings":"","what":"Existing Alternatives","title":"Fast Agent-Based Epi Models","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":"/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":"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/LFMCMC.html","id":null,"dir":"Reference","previous_headings":"","what":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC)","code":""},{"path":"/reference/LFMCMC.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"","code":"LFMCMC(model = NULL) run_lfmcmc(lfmcmc, params_init, n_samples, epsilon, seed = NULL) set_observed_data(lfmcmc, observed_data) set_proposal_fun(lfmcmc, fun) use_proposal_norm_reflective(lfmcmc) set_simulation_fun(lfmcmc, fun) set_summary_fun(lfmcmc, fun) set_kernel_fun(lfmcmc, fun) use_kernel_fun_gaussian(lfmcmc) get_mean_params(lfmcmc) get_mean_stats(lfmcmc) get_initial_params(lfmcmc) get_current_proposed_params(lfmcmc) get_current_accepted_params(lfmcmc) get_current_proposed_stats(lfmcmc) get_current_accepted_stats(lfmcmc) get_observed_stats(lfmcmc) get_all_sample_params(lfmcmc) get_all_sample_stats(lfmcmc) get_all_sample_acceptance(lfmcmc) get_all_sample_drawn_prob(lfmcmc) get_all_sample_kernel_scores(lfmcmc) get_all_accepted_params(lfmcmc) get_all_accepted_stats(lfmcmc) get_all_accepted_kernel_scores(lfmcmc) get_n_samples(lfmcmc) get_n_stats(lfmcmc) get_n_params(lfmcmc) # S3 method for class 'epiworld_lfmcmc' verbose_off(x) set_params_names(lfmcmc, names) set_stats_names(lfmcmc, names) # S3 method for class 'epiworld_lfmcmc' print(x, burnin = 0, ...)"},{"path":"/reference/LFMCMC.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"model model class epiworld_model NULL (see details). lfmcmc LFMCMC model params_init Initial model parameters, treated double n_samples Number samples, treated integer epsilon Epsilon parameter, treated double seed Random engine seed observed_data Observed data, treated double. fun function (see details). x LFMCMC model print names Character vector names. burnin Integer. Number samples discard burnin computing summary. ... Ignored","code":""},{"path":"/reference/LFMCMC.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"LFMCMC function returns model class epiworld_lfmcmc. simulated model class epiworld_lfmcmc. use_kernel_fun_gaussian: LFMCMC model kernel function set gaussian. get_mean_params: param means given lfmcmc model. get_mean_stats: stats means given lfmcmc model. function get_initial_params returns initial parameters given LFMCMC model. function get_current_proposed_params returns proposed parameters next LFMCMC sample. function get_current_accepted_params returns recently accepted parameters (current state LFMCMC) function get_current_proposed_stats returns statistics simulation run proposed parameters function get_current_accepted_stats returns statistics recently accepted parameters function get_observed_stats returns statistics observed data function get_all_sample_params returns matrix sample parameters given LFMCMC model. number rows equal number samples number columns equal number parameters. function get_all_sample_stats returns matrix statistics given LFMCMC model. number rows equal number samples number columns equal number statistics. function get_all_sample_acceptance returns vector boolean flags indicate whether given sample accepted function get_all_sample_drawn_prob returns vector drawn probabilities sample function get_all_sample_kernel_scores returns vector kernel scores sample function get_all_accepted_params returns matrix accepted parameters given LFMCMC model. number rows equal number samples number columns equal number parameters. function get_all_accepted_stats returns matrix accepted statistics given LFMCMC model. number rows equal number samples number columns equal number statistics. function get_all_accepted_kernel_scores returns vector kernel scores accepted sample functions get_n_samples, get_n_stats, get_n_params return number samples, statistics, parameters given LFMCMC model, respectively. verbose_on verbose_off functions return model, however verbose_off returns model progress bar. set_params_names: lfmcmc model parameter names added. set_stats_names: lfmcmc model stats names added.","code":""},{"path":"/reference/LFMCMC.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"Performs Likelihood-Free Markhov Chain Monte Carlo simulation. model NULL, model uses random-number generator engine model. Otherwise, model NULL, new random-number generator engine created. functions passed LFMCMC object different arguments depending object: set_proposal_fun: vector parameters model. set_simulation_fun: vector parameters model. set_summary_fun: vector simulated data model. set_kernel_fun: vector simulated statistics, observed statistics, epsilon, model. verbose_on verbose_off functions activate deactivate printing progress screen, respectively. functions return model (x) invisibly.","code":""},{"path":"/reference/LFMCMC.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Likelihood-Free Markhov Chain Monte Carlo (LFMCMC) — LFMCMC","text":"","code":"## Setup an SIR model to use in the simulation model_seed <- 122 model_sir <- ModelSIR(name = \"COVID-19\", prevalence = .1, transmission_rate = .9, recovery_rate = .3) agents_smallworld( model_sir, n = 1000, k = 5, d = FALSE, p = 0.01 ) verbose_off(model_sir) run(model_sir, ndays = 50, seed = model_seed) ## Setup LFMCMC # Extract the observed data from the model obs_data <- get_today_total(model_sir) # Define the simulation function simfun <- function(params, lfmcmc_obj) { set_param(model_sir, \"Recovery rate\", params[1]) set_param(model_sir, \"Transmission rate\", params[2]) run(model_sir, ndays = 50) res <- get_today_total(model_sir) return(res) } # Define the summary function sumfun <- function(dat, lfmcmc_obj) { return(dat) } # Create the LFMCMC model lfmcmc_model <- LFMCMC(model_sir) |> set_simulation_fun(simfun) |> set_summary_fun(sumfun) |> use_proposal_norm_reflective() |> use_kernel_fun_gaussian() |> set_observed_data(obs_data) ## Run LFMCMC simulation # Set initial parameters par0 <- c(0.1, 0.5) n_samp <- 2000 epsil <- 1.0 # Run the LFMCMC simulation verbose_off(lfmcmc_model) run_lfmcmc( lfmcmc = lfmcmc_model, params_init = par0, n_samples = n_samp, epsilon = epsil, seed = model_seed ) # Print the results set_stats_names(lfmcmc_model, get_states(model_sir)) set_params_names(lfmcmc_model, c(\"Immune recovery\", \"Infectiousness\")) print(lfmcmc_model) #> ___________________________________________ #> #> LIKELIHOOD-FREE MARKOV CHAIN MONTE CARLO #> #> N Samples (total) : 2000 #> N Samples (after burn-in period) : 2000 #> Elapsed t : 1.00s #> #> Parameters: #> -Immune recovery : 0.45 [ 0.14, 0.95] (initial : 0.10) #> -Infectiousness : 0.85 [ 0.54, 1.00] (initial : 0.50) #> #> Statistics: #> -Susceptible : 0.22 [ 0.00, 2.00] (Observed: 0.00) #> -Infected : 0.07 [ 0.00, 1.00] (Observed: 0.00) #> -Recovered : 995.71 [ 998.00, 1000.00] (Observed: 1000.00) #> ___________________________________________ #> get_mean_stats(lfmcmc_model) #> [1] 0.2215 0.0655 995.7130 get_mean_params(lfmcmc_model) #> [1] 0.4482147 0.8480773"},{"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 class '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 class '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":"/reference/ModelSEIR.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Exposed Infected Recovered model (SEIR) — ModelSEIR","text":"initial_states function allows user set initial state model. user must provide vector proportions indicating following values: (1) Proportion non-infected agents removed, (2) Proportion exposed agents set infected.","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, 0 Infected, and 1000 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 class '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: 446 Susceptible, 4 Exposed, 3 Infected, and 9547 Recovered. plot(model_seirconn) # Adding the flu flu <- virus(\"Flu\", .9, 1 / 7, prevalence = 0.001, as_proportion = TRUE) add_virus(model_seirconn, flu) #' # 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: 0 Susceptible, 0 Exposed, 0 Infected, and 10000 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 class '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":"/reference/ModelSEIRD.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible-Exposed-Infected-Recovered-Deceased model (SEIRD) — ModelSEIRD","text":"initial_states function allows user set initial state model. user must provide vector proportions indicating following values: (1) Proportion exposed agents infected, (2) proportion non-infected agents already removed, (3) proportion non-ifected agents already deceased.","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: 2654 Susceptible, 383 Exposed, 1389 Infected, 87607 Removed, and 7967 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 class '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":"/reference/ModelSEIRDCONN.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Exposed Infected Removed Deceased model (SEIRD connected) — ModelSEIRDCONN","text":"initial_states function allows user set initial state model. user must provide vector proportions indicating following values: (1) Proportion exposed agents infected, (2) proportion non-infected agents already removed, (3) proportion non-ifected agents already deceased.","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: 490 Susceptible, 2 Exposed, 1 Infected, 9280 Removed, and 227 Deceased. plot(model_seirdconn) # Adding the flu flu <- virus( \"Flu\", prob_infecting = .3, recovery_rate = 1 / 7, prob_death = 0.001, prevalence = 0.001, as_proportion = TRUE ) add_virus(model = model_seirdconn, virus = flu) #' # 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: 449 Susceptible, 8 Exposed, 8 Infected, 9331 Removed, and 204 Deceased. plot(model_seirdconn)"},{"path":"/reference/ModelSEIRMixing.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","text":"Susceptible Exposed Infected Removed model (SEIR) mixing","code":""},{"path":"/reference/ModelSEIRMixing.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","text":"","code":"ModelSEIRMixing( name, n, prevalence, contact_rate, transmission_rate, incubation_days, recovery_rate, contact_matrix ) # S3 method for class 'epiworld_seirmixing' plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSEIRMixing.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","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. incubation_days Numeric scalar. Average number days incubation period. recovery_rate Numeric scalar 0 1. Probability recovery. contact_matrix Matrix contact rates individuals. x Object class SIRCONN. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSEIRMixing.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","text":"ModelSEIRMixingfunction returns model class epiworld_model. plot function returns plot SEIRMixing model class epiworld_model.","code":""},{"path":"/reference/ModelSEIRMixing.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","text":"contact_matrix matrix contact rates entities. matrix size n x n, n number entities. row-stochastic matrix, .e., sum row 1. initial_states function allows user set initial state model. particular, user can specify many non-infected agents removed beginning simulation.","code":""},{"path":[]},{"path":"/reference/ModelSEIRMixing.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Exposed Infected Removed model (SEIR) with mixing — ModelSEIRMixing","text":"","code":"# Start off creating three entities. # Individuals will be distribured randomly between the three. e1 <- entity(\"Population 1\", 3e3, as_proportion = FALSE) e2 <- entity(\"Population 2\", 3e3, as_proportion = FALSE) e3 <- entity(\"Population 3\", 3e3, as_proportion = FALSE) # Row-stochastic matrix (rowsums 1) cmatrix <- c( c(0.9, 0.05, 0.05), c(0.1, 0.8, 0.1), c(0.1, 0.2, 0.7) ) |> matrix(byrow = TRUE, nrow = 3) N <- 9e3 flu_model <- ModelSEIRMixing( name = \"Flu\", n = N, prevalence = 1 / N, contact_rate = 20, transmission_rate = 0.1, recovery_rate = 1 / 7, incubation_days = 7, contact_matrix = cmatrix ) # Adding the entities to the model flu_model |> add_entity(e1) |> add_entity(e2) |> add_entity(e3) set.seed(331) run(flu_model, ndays = 100) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. summary(flu_model) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Exposed-Infected-Removed (SEIR) with Mixing #> Population size : 9000 #> Agents' data : (none) #> Number of entities : 3 #> Days (duration) : 100 (of 100) #> Number of viruses : 1 #> Last run elapsed t : 109.00ms #> Last run speed : 8.24 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - Flu #> #> Tool(s): #> (none) #> #> Model parameters: #> - Avg. Incubation days : 7.0000 #> - Contact rate : 20.0000 #> - Prob. Recovery : 0.1429 #> - Prob. Transmission : 0.1000 #> #> Distribution of the population at time 100: #> - (0) Susceptible : 8999 -> 137 #> - (1) Exposed : 1 -> 35 #> - (2) Infected : 0 -> 139 #> - (3) Recovered : 0 -> 8689 #> #> Transition Probabilities: #> - Susceptible 0.96 0.04 0.00 0.00 #> - Exposed 0.00 0.84 0.16 0.00 #> - Infected 0.00 0.00 0.86 0.14 #> - Recovered 0.00 0.00 0.00 1.00 #> plot_incidence(flu_model)"},{"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 class '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":"/reference/ModelSIR.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"SIR model — ModelSIR","text":"initial_states function allows user set initial state model. particular, user can specify many non-infected agents removed beginning simulation.","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, 3 Infected, and 997 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 class '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":"/reference/ModelSIRCONN.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Infected Removed model (SIR connected) — ModelSIRCONN","text":"initial_states function allows user set initial state model. particular, user can specify many non-infected agents removed beginning simulation.","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: 2012 Susceptible, 0 Infected, and 7988 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 class '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":"/reference/ModelSIRD.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"SIRD model — ModelSIRD","text":"initial_states function allows user set initial state model. user must provide vector proportions indicating following values: (1) proportion non-infected agents already removed, (2) proportion non-ifected agents already deceased.","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, 0 Infected, 913 Recovered, and 87 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 class '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":"/reference/ModelSIRDCONN.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Infected Removed Deceased model (SIRD connected) — ModelSIRDCONN","text":"initial_states function allows user set initial state model. user must provide vector proportions indicating following values: (1) proportion non-infected agents already removed, (2) proportion non-ifected agents already deceased.","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: 3678 Susceptible, 0 Infected, 86905 Recovered, and 9417 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.13466 0.14878 # Looking into the individual agents. get_agents(model_logit) #> Agents from the model \"Susceptible-Infected-Removed (SIR) (logit)\": #> Agent: 0, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 1, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 2, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 3, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 4, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 5, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 6, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 7, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 8, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> Agent: 9, state: Susceptible (0), Has virus: no, NTools: 0i NNeigh: 8 #> ... 99990 more agents ..."},{"path":"/reference/ModelSIRMixing.html","id":null,"dir":"Reference","previous_headings":"","what":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","text":"Susceptible Infected Removed model (SIR) mixing","code":""},{"path":"/reference/ModelSIRMixing.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","text":"","code":"ModelSIRMixing( name, n, prevalence, contact_rate, transmission_rate, recovery_rate, contact_matrix ) # S3 method for class 'epiworld_sirmixing' plot(x, main = get_name(x), ...)"},{"path":"/reference/ModelSIRMixing.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","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. contact_matrix Matrix contact rates individuals. x Object class SIRCONN. main Title plot ... Currently ignore.","code":""},{"path":"/reference/ModelSIRMixing.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","text":"ModelSIRMixingfunction returns model class epiworld_model. plot function returns plot SIRMixing model class epiworld_model.","code":""},{"path":"/reference/ModelSIRMixing.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","text":"contact_matrix matrix contact rates entities. matrix size n x n, n number entities. row-stochastic matrix, .e., sum row 1. initial_states function allows user set initial state model. particular, user can specify many non-infected agents removed beginning simulation.","code":""},{"path":[]},{"path":"/reference/ModelSIRMixing.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Susceptible Infected Removed model (SIR) with mixing — ModelSIRMixing","text":"","code":"# From the vignette # Start off creating three entities. # Individuals will be distribured randomly between the three. e1 <- entity(\"Population 1\", 3e3, as_proportion = FALSE) e2 <- entity(\"Population 2\", 3e3, as_proportion = FALSE) e3 <- entity(\"Population 3\", 3e3, as_proportion = FALSE) # Row-stochastic matrix (rowsums 1) cmatrix <- c( c(0.9, 0.05, 0.05), c(0.1, 0.8, 0.1), c(0.1, 0.2, 0.7) ) |> matrix(byrow = TRUE, nrow = 3) N <- 9e3 flu_model <- ModelSIRMixing( name = \"Flu\", n = N, prevalence = 1 / N, contact_rate = 20, transmission_rate = 0.1, recovery_rate = 1 / 7, contact_matrix = cmatrix ) # Adding the entities to the model flu_model |> add_entity(e1) |> add_entity(e2) |> add_entity(e3) set.seed(331) run(flu_model, ndays = 100) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. summary(flu_model) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Removed (SIR) with Mixing #> Population size : 9000 #> Agents' data : (none) #> Number of entities : 3 #> Days (duration) : 100 (of 100) #> Number of viruses : 1 #> Last run elapsed t : 60.00ms #> Last run speed : 14.99 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - Flu #> #> Tool(s): #> (none) #> #> Model parameters: #> - Contact rate : 20.0000 #> - Prob. Recovery : 0.1429 #> - Prob. Transmission : 0.1000 #> #> Distribution of the population at time 100: #> - (0) Susceptible : 8999 -> 134 #> - (1) Infected : 1 -> 0 #> - (2) Recovered : 0 -> 8866 #> #> Transition Probabilities: #> - Susceptible 0.96 0.04 0.00 #> - Infected 0.00 0.87 0.13 #> - Recovered 0.00 0.00 1.00 #> plot_incidence(flu_model)"},{"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 class '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: 99 Susceptible, and 901 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 class '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: 94 Susceptible, 441 Infected, and 465 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 class '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: 9974 Susceptible, 0 Latent, 0 Symptomatic, 0 Symptomatic isolated, 0 Asymptomatic, 0 Asymptomatic isolated, 26 Recovered, and 0 Removed. # Plotting plot(model_surv, main = \"SURV Model\")"},{"path":"/reference/agents.html","id":null,"dir":"Reference","previous_headings":"","what":"Agents in epiworldR — agents","title":"Agents in epiworldR — 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/agents.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Agents in epiworldR — agents","text":"","code":"get_agents(model, ...) # S3 method for class 'epiworld_model' get_agents(model, ...) # S3 method for class 'epiworld_agents' x[i] # S3 method for class 'epiworld_agent' print(x, compressed = FALSE, ...) # S3 method for class 'epiworld_agents' print(x, compressed = TRUE, max_print = 10, ...) get_state(x)"},{"path":"/reference/agents.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Agents in epiworldR — agents","text":"model object class epiworld_model. ... Ignored x object class epiworld_agents Index (id) agent (0 n-1) compressed Logical scalar. FALSE, prints detailed information agent. max_print Integer scalar. Maximum number agents print.","code":""},{"path":"/reference/agents.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Agents in epiworldR — 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/agents.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Agents in epiworldR — 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 : Susceptible (0) #> Has virus : no #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 1 #> State : Recovered (2) #> Has virus : no #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 2 #> State : Susceptible (0) #> Has virus : no #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 3 #> State : Susceptible (0) #> Has virus : no #> Tool count : 0 #> Neigh. count : 0 #> Information about agent id 4 #> State : Susceptible (0) #> Has virus : no #> 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 : Susceptible (0) #> Has virus : no #> Tool count : 0 #> Neigh. count : 0 # interest's position where '0' is."},{"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)"},{"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).","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, 3 Infected, and 997 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/entities.html","id":null,"dir":"Reference","previous_headings":"","what":"Get entities — entities","title":"Get entities — entities","text":"Entities epiworld objects can contain agents.","code":""},{"path":"/reference/entities.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get entities — entities","text":"","code":"get_entities(model) # S3 method for class 'epiworld_entities' x[i] entity(name, prevalence, as_proportion, to_unassigned = TRUE) get_entity_size(entity) get_entity_name(entity) entity_add_agent(entity, agent, model = attr(entity, \"model\")) rm_entity(model, id) add_entity(model, entity) load_agents_entities_ties(model, agents_id, entities_id) entity_get_agents(entity) distribute_entity_randomly(prevalence, as_proportion, to_unassigned = TRUE) distribute_entity_to_set(agents_ids) set_distribution_entity(entity, distfun)"},{"path":"/reference/entities.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get entities — entities","text":"model Model object class epiworld_model. x Object class epiworld_entities. Integer index. name Character scalar. Name entity. prevalence Numeric scalar. Prevalence entity. as_proportion Logical scalar. TRUE, prevalence interpreted proportion. to_unassigned Logical scalar. TRUE, entity added unassigned pool. entity Entity object class epiworld_entity. agent Agent object class epiworld_agent. id Integer scalar. Entity id remove (starting zero). agents_id Integer vector. entities_id Integer vector. agents_ids Integer vector. Ids agents distribute. distfun Distribution function object class epiworld_distribution_entity.","code":""},{"path":"/reference/entities.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get entities — entities","text":"function entity creates entity object. function get_entity_size returns number agents entity. function get_entity_name returns name entity. function entity_add_agent adds agent entity. function rm_entity removes entity model. function load_agents_entities_ties loads agents entities. function entity_get_agents returns integer vector agents entity (ids).","code":""},{"path":"/reference/entities.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Get entities — entities","text":"Epiworld entities especially useful mixing models, particularly ModelSIRMixing ModelSEIRMixing.","code":""},{"path":"/reference/entities.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get entities — entities","text":"","code":"# Creating a mixing model mymodel <- ModelSIRMixing( name = \"My model\", n = 10000, prevalence = .001, contact_rate = 10, transmission_rate = .1, recovery_rate = 1 / 7, contact_matrix = matrix(c(.9, .1, .1, .9), 2, 2) ) ent1 <- entity(\"First\", 5000, FALSE) ent2 <- entity(\"Second\", 5000, FALSE) mymodel |> add_entity(ent1) |> add_entity(ent2) run(mymodel, ndays = 100, seed = 1912) #> _________________________________________________________________________ #> Running the model... #> ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| done. #> done. summary(mymodel) #> ________________________________________________________________________________ #> ________________________________________________________________________________ #> SIMULATION STUDY #> #> Name of the model : Susceptible-Infected-Removed (SIR) with Mixing #> Population size : 10000 #> Agents' data : (none) #> Number of entities : 2 #> Days (duration) : 100 (of 100) #> Number of viruses : 1 #> Last run elapsed t : 59.00ms #> Last run speed : 16.78 million agents x day / second #> Rewiring : off #> #> Global events: #> - Update infected individuals (runs daily) #> #> Virus(es): #> - My model #> #> Tool(s): #> (none) #> #> Model parameters: #> - Contact rate : 10.0000 #> - Prob. Recovery : 0.1429 #> - Prob. Transmission : 0.1000 #> #> Distribution of the population at time 100: #> - (0) Susceptible : 9990 -> 376 #> - (1) Infected : 10 -> 1 #> - (2) Recovered : 0 -> 9623 #> #> Transition Probabilities: #> - Susceptible 0.97 0.03 0.00 #> - Infected 0.00 0.86 0.14 #> - Recovered 0.00 0.00 1.00 #>"},{"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 class '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 class 'epiworld_hist_transition' as.array(x, ...) plot_incidence(x, ...) # S3 method for class '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 class '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.9028099 0.09719012 0.0000000 0.0000000 #> Exposed 0.0000000 0.85844742 0.1415526 0.0000000 #> Infected 0.0000000 0.00000000 0.7000978 0.2999022 #> 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 861 # 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 861 # 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 861 139 0 #> Infected 0 0 0 0 #> Recovered 0 0 0 0 #> #> , , 2 #> #> Susceptible Exposed Infected Recovered #> Susceptible 8822 178 0 0 #> Exposed 0 737 124 0 #> Infected 0 0 92 47 #> 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 = NULL) # S3 method for class 'epiworld_model' summary(object, ...) get_states(x) get_param(x, pname) add_param(x, pname, pval) # S3 method for class 'epiworld_model' add_param(x, pname, pval) set_param(x, pname, pval) set_name(x, mname) get_name(x) get_n_viruses(x) get_n_tools(x) get_ndays(x) today(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) initial_states(model, proportions) clone_model(model)"},{"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 (passed set.seed()). 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 proportions Numeric vector. Proportions agents distributed (see details).","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. add_param returns model added parameter invisibly. 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. today returns current model day 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. inital_states returns model updated initial state. clone_model returns copy model.","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. epiworld_model objects pointers underlying C++ class epiworld. generate copy model, use clone_model, otherwise, assignment operator copy pointer.","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) #> Warning: SIR Connected models do not have queue. 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. today(model_sirconn) # Returns the current day of the simulation. This will #> [1] 100 # match \"get_ndays()\" if run at the end of a simulation, but will differ if run # during a simulation 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, prevalence = 0.5, as_prop = TRUE)) 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-deprecated.html","id":null,"dir":"Reference","previous_headings":"","what":"Deprecated and removed functions in epiworldR — epiworldR-deprecated","title":"Deprecated and removed functions in epiworldR — epiworldR-deprecated","text":"Starting version 0.0-4, epiworld changed refered \"actions.\" Following traditional ABMs, actions now called \"events.\"","code":""},{"path":"/reference/epiworldR-deprecated.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Deprecated and removed functions in epiworldR — epiworldR-deprecated","text":"","code":"add_tool_n(model, tool, n) add_virus_n(model, virus, n) globalaction_tool(...) globalaction_tool_logit(...) globalaction_set_params(...) globalaction_fun(...)"},{"path":"/reference/epiworldR-deprecated.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Deprecated and removed functions in epiworldR — epiworldR-deprecated","text":"model Model object class epiworld_model. tool Tool object class epiworld_tool. n Deprecated. virus Virus object class epiworld_virus. ... Arguments passed new function.","code":""},{"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: Andrew Pulsipher pulsipher.@gmail.com (ORCID) Authors: George Vega Yon g.vegayon@gmail.com (ORCID) Derek Meyer derekmeyer37@gmail.com (ORCID) contributors: Susan Holmes (ORCID) (JOSS reviewer) [reviewer] Abinash Satapathy (ORCID) (JOSS reviewer) [reviewer] Carinogurjao [reviewer] Centers Disease Control Prevention (Award number 1U01CK000585; 75D30121F00003) [funder]","code":""},{"path":"/reference/global-events.html","id":null,"dir":"Reference","previous_headings":"","what":"Global Events — global-events","title":"Global Events — global-events","text":"Global events functions executed time step simulation. useful implementing interventions, vaccination, isolation, social distancing means tools.","code":""},{"path":"/reference/global-events.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Global Events — global-events","text":"","code":"globalevent_tool(tool, prob, name = get_name_tool(tool), day = -99) globalevent_tool_logit( tool, vars, coefs, name = get_name_tool(tool), day = -99 ) globalevent_set_params( param, value, name = paste0(\"Set \", param, \" to \", value), day = -99 ) globalevent_fun(fun, name = deparse(substitute(fun)), day = -99) add_globalevent(model, event, action = NULL) rm_globalevent(model, event)"},{"path":"/reference/global-events.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Global Events — global-events","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. event event added removed. add, object class epiworld_globalevent. remove, integer position event model (starting zero). action (Deprecated) use event instead.","code":""},{"path":"/reference/global-events.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Global Events — global-events","text":"globalevent_set_params function returns object class epiworld_globalevent_set_param epiworld_globalevent. globalevent_tool returns object class epiworld_globalevent_tool epiworld_globalevent. globalevent_tool_logit returns object class epiworld_globalevent_tool_logit epiworld_globalevent. function add_globalevent returns model added event function rm_globalevent returns model removed event.","code":""},{"path":"/reference/global-events.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Global Events — global-events","text":"function globalevent_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 globalevent_set_param allows set parameter model. parameter specified name param value value. function globalevent_fun allows specify function executed given day. function object must receive object class epiworld_model argument. function add_globalevent 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-events.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Global Events — global-events","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\", prevalence = 0, as_proportion = FALSE, susceptibility_reduction = .9, transmission_reduction = .5, recovery_enhancer = .5, death_reduction = .9 ) # Adding a global event vaccine_day_20 <- globalevent_tool(epitool, .2, day = 20) add_globalevent(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: 2012 Susceptible, 0 Infected, and 7988 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 <- globalevent_set_params(\"Contact rate\", 0, day = 10) add_globalevent(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: 2083 Susceptible, 0 Infected, and 7917 Recovered. plot_incidence(model_sirconn2) # Example using `globalevent_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, nthreads = 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 981 #> 5 1 1 1 Infected 18 #> 6 1 1 1 Recovered 1 head(ans$reproductive) #> sim_num virus_id virus source source_exposure_date rt #> 1 1 0 COVID-19 519 10 0 #> 2 1 0 COVID-19 152 9 0 #> 3 1 0 COVID-19 949 8 0 #> 4 1 0 COVID-19 921 8 0 #> 5 1 0 COVID-19 855 8 0 #> 6 1 0 COVID-19 816 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, prevalence, as_proportion, susceptibility_reduction, transmission_reduction, recovery_enhancer, death_reduction ) set_name_tool(tool, name) get_name_tool(tool) add_tool(model, tool, proportion) 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 class 'epiworld_agents_tools' print(x, max_print = 10, ...) set_distribution_tool(tool, distfun) distribute_tool_randomly(prevalence, as_proportion) distribute_tool_to_set(agents_ids)"},{"path":"/reference/tool.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tools in epiworld — tool","text":"name Name tool prevalence Numeric scalar. Prevalence tool. as_proportion Logical scalar. TRUE, prevalence interpreted proportion total number agents model. 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 Deprecated. 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. distfun object class epiworld_tool_distfun. agents_ids Integer vector. Indices agents tool assigned.","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. 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. distribute_tool_randomly function returns distribution function class epiworld_tool_distfun. distribute_tool_to_set function returns distribution function class epiworld_tool_distfun.","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. set_distribution_tool function assigns distribution function specified tool class epiworld_tool. distribution function can created using functions distribute_tool_randomly() distribute_tool_to_set(). distribute_tool_randomly function creates distribution function randomly assigns tool proportion population. distribute_tool_to_set function creates distribution function assigns tool set agents.","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\", prevalence = 0.5, as_proportion = TRUE, 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) 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: 8804 Susceptible, 0 Infected, and 1196 Recovered. plot(model_sirconn) # To declare a certain number of individuals with the tool rm_tool(model_sirconn, 0) # Removing epitool from the model # Setting prevalence to 0.1 set_distribution_tool(epitool, distribute_tool_randomly(0.1, TRUE)) add_tool(model_sirconn, epitool) 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 set_recovery_enhancer(epitool, 0.15) # Probability increase of recovery set_death_reduction(epitool, 0.05) # Probability reduction of death rm_tool(model_sirconn, 0) add_tool(model_sirconn, epitool) 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\", prevalence = 0.5, as_proportion = TRUE, susceptibility_reduction = 0.0, transmission_reduction = 0.3, # Only transmission recovery_enhancer = 0.0, death_reduction = 0.0 ) add_tool(sir, mask_wearing) 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, prevalence, as_proportion, 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) 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) set_distribution_virus(virus, distfun) distribute_virus_randomly(prevalence, as_proportion) distribute_virus_set(agents_ids)"},{"path":"/reference/virus.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Virus design — virus","text":"name virus prevalence Numeric scalar. Prevalence virus. as_proportion Logical scalar. TRUE, prevalence set proportion total number agents model. 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 Deprecated. 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. distfun object class epiworld_distribution_virus. agents_ids Integer vector. Indices agents receive virus.","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. 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. distribute_virus_randomly function returns function can used distribute virus model.","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. distribute_virus_randomly function factory function used randomly distribute virus model. prevalence can set proportion number agents. resulting function can passed set_distribution_virus.","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, prevalence = 0.3, as_proportion = TRUE ) # Adding virus and setting/getting virus name add_virus(mseirconn, delta) 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: 3609 Susceptible, 113 Exposed, 11 Infected, and 6267 Recovered. rm_virus(mseirconn, 0) # Removing the first virus from the model object set_distribution_virus(delta, distribute_virus_randomly(100, as_proportion = FALSE)) add_virus(mseirconn, delta) # 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, prevalence = 0, as_proportion = TRUE ) 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-0610","dir":"Changelog","previous_headings":"","what":"epiworldR 0.6.1.0","title":"epiworldR 0.6.1.0","text":"CRAN release: 2025-01-28 Updates reflect changes epiworld C++ library (mostly bug fixes) Package now requires R version >=4.1.0, uses pipe |>","code":""},{"path":"/news/index.html","id":"epiworldr-0600","dir":"Changelog","previous_headings":"","what":"epiworldR 0.6.0.0","title":"epiworldR 0.6.0.0","text":"CRAN release: 2025-01-16 package now includes LFMCMC module implements likelihood-free Markov Chain Monte Carlo algorithm. module used estimate parameters models. new function add_param() allows user add parameters model. new function rm_globalevent() allows user remove global events model. function today() returns current day (step) simulation. changed versioning system. allow R package increase version number preserving epiworld (C++) versioning, added fourth number indicates R-patches (similar RcppArmadillo).","code":""},{"path":"/news/index.html","id":"epiworldr-03-2","dir":"Changelog","previous_headings":"","what":"epiworldR 0.3-2","title":"epiworldR 0.3-2","text":"CRAN release: 2024-10-08 Starting version 0.3-0, epiworldR versioned using version C++ library, epiworld. Adds new mixing models ModelSIRMixing ModelSEIRMixing. Ports Entity class. Entities used group agents within model. Refactors add_tool, add_virus, add_entity simplifying syntax. Now, functions receive model object. Prevalence specified object . add_tool_n add_virus_n now deprecated. globalaction_* now defunct. Use globalevent_* instead. New functions specify viruses, tools, entities distributed among agents: distribute_viruses, distribute_tools, distribute_entities.","code":""},{"path":"/news/index.html","id":"epiworldr-01-0","dir":"Changelog","previous_headings":"","what":"epiworldR 0.1-0","title":"epiworldR 0.1-0","text":"CRAN release: 2024-04-08 Force model update agents’ states running simulation. causing issues calling run_multiple() single call run(). Reported 14.","code":""},{"path":"/news/index.html","id":"epiworldr-00-4","dir":"Changelog","previous_headings":"","what":"epiworldR 0.0-4","title":"epiworldR 0.0-4","text":"CRAN release: 2024-02-09 Added missing checks tool class adding model add_too_n. Various small improvements.","code":""},{"path":"/news/index.html","id":"epiworldr-00-3","dir":"Changelog","previous_headings":"","what":"epiworldR 0.0-3","title":"epiworldR 0.0-3","text":"CRAN release: 2023-09-08 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":""}]