Learn R Programming

epiworldR (version 0.6.1.0)

epiworld-data: Accessing the database of epiworld

Description

Models in epiworld are stored in a database. This database can be accessed using the functions described in this manual page. Some elements of the database are: the transition matrix, the incidence matrix, the reproductive number, the generation time, and daily incidence at the virus and tool level.

Usage

get_hist_total(x)

get_today_total(x)

get_hist_virus(x)

get_hist_tool(x)

get_transition_probability(x)

get_reproductive_number(x)

# S3 method for epiworld_repnum plot( x, y = NULL, ylab = "Average Rep. Number", xlab = "Day (step)", main = "Reproductive Number", type = "b", plot = TRUE, ... )

plot_reproductive_number(x, ...)

get_hist_transition_matrix(x, skip_zeros = FALSE)

# S3 method for epiworld_hist_transition as.array(x, ...)

plot_incidence(x, ...)

# S3 method for epiworld_hist_transition plot( x, type = "b", xlab = "Day (step)", ylab = "Counts", main = "Daily incidence", plot = TRUE, ... )

get_transmissions(x)

get_generation_time(x)

# S3 method for epiworld_generation_time plot( x, type = "b", xlab = "Day (step)", ylab = "Avg. Generation Time", main = "Generation Time", plot = TRUE, ... )

plot_generation_time(x, ...)

Value

  • The get_hist_total function returns an object of class epiworld_hist_total.

  • The get_today_total function returns a named vector with the total number of individuals in each state at the end of the simulation.

  • The get_hist_virus function returns an object of class epiworld_hist_virus.

  • The get_hist_tool function returns an object of epiworld_hist_virus.

  • The get_transition_probability function returns an object of class matrix.

  • The get_reproductive_number function returns an object of class epiworld_repnum.

  • The plot function returns a plot of the reproductive number over time.

  • get_hist_transition_matrix returns a data.frame with four columns: "state_from", "state_to", "date", and "counts."

  • The as.array method for epiworld_hist_transition objects turns the data.frame returned by get_hist_transition_matrix into an array of nstates x nstates x (ndays + 1) entries, where the first entry is the initial state.

  • The plot_incidence function returns a plot originating from the object get_hist_transition_matrix.

  • The plot function returns a plot which originates from the epiworld_hist_transition object.

  • The function get_transmissions returns a data.frame with the following columns: date, source, target, virus_id, virus, and source_exposure_date.

  • The function get_generation_time returns a data.frame with the following columns: "agent", "virus_id", "virus", "date", and "gentime".

  • The function plot_generation_time is a wrapper for plot and get_generation_time.

Arguments

x

An object of class epiworld_sir, epiworld_seir, etc. any model.

y

Ignored.

ylab, xlab, main, type

Further parameters passed to graphics::plot()

plot

Logical scalar. If TRUE (default), the function will the desired statistic.

...

In the case of plot methods, further arguments passed to graphics::plot.

skip_zeros

Logical scalar. When FALSE it will return all the entries in the transition matrix.

Details

The plot_reproductive_number function is a wrapper around get_reproductive_number that plots the result.

The plot_incidence function is a wrapper between get_hist_transition_matrix and it's plot method.

The plot method for the epiworld_hist_transition class plots the daily incidence of each state. The function returns the data frame used for plotting.

See Also

Other Models: ModelDiffNet(), ModelSEIR(), ModelSEIRCONN(), ModelSEIRD(), ModelSEIRDCONN(), ModelSEIRMixing(), ModelSIR(), ModelSIRCONN(), ModelSIRD(), ModelSIRDCONN(), ModelSIRLogit(), ModelSIRMixing(), ModelSIS(), ModelSISD(), ModelSURV()

Examples

Run this 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)

# Retrieving the transition probability
get_transition_probability(seirconn)

# Retrieving date, state, and counts dataframe including any added tools
get_hist_tool(seirconn)

# Retrieving overall date, state, and counts dataframe
head(get_hist_total(seirconn))

# Retrieving date, state, and counts dataframe by variant
head(get_hist_virus(seirconn))

# 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)

# And turn it into an array
as.array(t_hist)[, , 1:3]

# We cam also get (and plot) the incidence, as well as
# the generation time
inci <- plot_incidence(seirconn)
gent <- plot_generation_time(seirconn)

Run the code above in your browser using DataLab