-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding mixing models (need examples) (#16)
* Adding mixing models (need examples) * Updating readme with figures and list of models * Adding entity to the model * Adding new entity wrappers * Starting off with entity vignette * Working on the vignette * Updating version of epiworld * Updating README * Refactoring how virus and tools are added * Updating calling methods * Finally passing * Adding a note on the news file * Adding defunct message * Updating roxygen * Updating news and minor updates to README.md * Working on entity * Correcting mixing vignette * Adding the dist functions (starting to). Expected to fail [skip ci] * Updating interface * Updating version of acions * Updating epiworld c++ * Updating epiworld (warnings) * Removing dangling calls * Final check errors * Missed Rd file * Updating reference * Adding examples and cleaning docs. * Updating
- Loading branch information
Showing
108 changed files
with
4,641 additions
and
1,016 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM rocker/r-base:latest | ||
|
||
RUN \ | ||
echo 'options(repos=c(CRAN="https://cloud.r-project.org"))' >> ~/.Rprofile && \ | ||
Rscript --vanilla -e 'getOption("repos")' | ||
|
||
# Adding Git | ||
RUN apt-get update && apt-get install -y --no-install-recommends git | ||
|
||
# Adding R packages | ||
RUN \ | ||
wget https://github.com/jgm/pandoc/releases/download/3.2.1/pandoc-3.2.1-1-amd64.deb && \ | ||
dpkg -i pandoc-3.2.1-1-amd64.deb | ||
|
||
RUN install2.r cpp11 rmarkdown roxygen2 tinytest data.table netplot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp | ||
{ | ||
"name": "epiworldR", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "gcc -v", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
"remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
Package: epiworldR | ||
Type: Package | ||
Title: Fast Agent-Based Epi Models | ||
Version: 0.1-1 | ||
Date: 2024-04-07 | ||
Version: 0.3-2 | ||
Date: 2024-06-12 | ||
Authors@R: c( | ||
person("Derek", "Meyer", role=c("aut","cre"), | ||
email="[email protected]", comment = c(ORCID = "0009-0005-1350-6988")), | ||
|
@@ -21,7 +21,7 @@ URL: https://github.com/UofUEpiBio/epiworldR, | |
https://uofuepibio.github.io/epiworldR-workshop/ | ||
BugReports: https://github.com/UofUEpiBio/epiworldR/issues | ||
License: MIT + file LICENSE | ||
RoxygenNote: 7.3.1 | ||
RoxygenNote: 7.3.2 | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
LinkingTo: cpp11 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#' Susceptible Exposed Infected Removed model (SEIR) with mixing | ||
#' @param name String. Name of the virus | ||
#' @param prevalence Double. Initial proportion of individuals with the virus. | ||
#' @param contact_rate Numeric scalar. Average number of contacts per step. | ||
#' @param transmission_rate Numeric scalar between 0 and 1. Probability of | ||
#' transmission. | ||
#' @param incubation_days Numeric scalar. Average number of days in the | ||
#' incubation period. | ||
#' @param recovery_rate Numeric scalar between 0 and 1. Probability of recovery. | ||
#' @param x Object of class SIRCONN. | ||
#' @param ... Currently ignore. | ||
#' @param n Number of individuals in the population. | ||
#' @param contact_matrix Matrix of contact rates between individuals. | ||
#' @export | ||
#' @family Models | ||
#' @details | ||
#' The `contact_matrix` is a matrix of contact rates between entities. The | ||
#' matrix should be of size `n x n`, where `n` is the number of entities. | ||
#' This is a row-stochastic matrix, i.e., the sum of each row should be 1. | ||
#' | ||
#' The [initial_states] function allows the user to set the initial state of the | ||
#' model. In particular, the user can specify how many of the non-infected | ||
#' agents have been removed at the beginning of the simulation. | ||
#' @returns | ||
#' - The `ModelSEIRMixing`function returns a model of class [epiworld_model]. | ||
#' @aliases epiworld_seirmixing | ||
#' | ||
#' @examples | ||
#' | ||
#' # 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) | ||
#' summary(flu_model) | ||
#' plot_incidence(flu_model) | ||
#' | ||
#' @seealso epiworld-methods | ||
ModelSEIRMixing <- function( | ||
name, n, prevalence, contact_rate, transmission_rate, | ||
incubation_days, recovery_rate, contact_matrix | ||
) { | ||
|
||
structure( | ||
ModelSEIRMixing_cpp( | ||
name, n, prevalence, contact_rate, | ||
transmission_rate, incubation_days, | ||
recovery_rate, as.vector(contact_matrix) | ||
), | ||
class = c("epiworld_seirmixing", "epiworld_model") | ||
) | ||
|
||
} | ||
|
||
#' @rdname ModelSEIRMixing | ||
#' @export | ||
#' @returns The `plot` function returns a plot of the SEIRMixing model of class | ||
#' [epiworld_model]. | ||
#' @param main Title of the plot | ||
plot.epiworld_seirmixing <- function(x, main = get_name(x), ...) { # col = NULL | ||
plot_epi(x, main = main, ...) | ||
} |
Oops, something went wrong.