| epiworld-transition | R Documentation |
Functions to extract and visualize state transition counts, daily incidence, and conversion to array format.
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,
...
)
x |
An object of class |
skip_zeros |
Logical scalar. When |
... |
In the case of plot methods, further arguments passed to graphics::plot. |
ylab, xlab, main, type |
Further parameters passed to |
plot |
Logical scalar. If |
The plot_incidence function is a wrapper between
get_hist_transition_matrix and its 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.
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 method for epiworld_hist_transition returns a plot of the
daily incidence.
# SEIR Connected model
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
)
set.seed(937)
run(seirconn, 50)
# Get the transition history
t_hist <- get_hist_transition_matrix(seirconn)
head(t_hist)
# Convert to array
as.array(t_hist)[, , 1:3]
# Plot incidence
inci <- plot_incidence(seirconn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.