Learn R Programming

EpiModel (version 2.0.1)

plot.icm: Plot Data from a Stochastic Individual Contact Epidemic Model

Description

Plots epidemiological data from a stochastic individual contact model simulated with icm.

Usage

# S3 method for icm
plot(
  x,
  y,
  popfrac = FALSE,
  sim.lines = FALSE,
  sims,
  sim.col,
  sim.lwd,
  sim.alpha,
  mean.line = TRUE,
  mean.smooth = TRUE,
  mean.col,
  mean.lwd = 2,
  mean.lty = 1,
  qnts = 0.5,
  qnts.col,
  qnts.alpha,
  qnts.smooth = TRUE,
  legend,
  leg.cex = 0.8,
  axs = "r",
  grid = FALSE,
  add = FALSE,
  ...
)

Arguments

x

An EpiModel model object of class netsim.

y

Output compartments or flows from netsim object to plot.

popfrac

If TRUE, plot prevalence of values rather than numbers (see details).

sim.lines

If TRUE, plot individual simulation lines. Default is to plot lines for one-group models but not for two-group models.

sims

If type="epi" or "formation", a vector of simulation numbers to plot. If type="network", a single simulation number for network plot, or else "min" to plot the simulation number with the lowest disease prevalence, "max" for the simulation with the highest disease prevalence, or "mean" for the simulation with the prevalance closest to the mean across simulations at the specified time step.

sim.col

Vector of any standard R color format for simulation lines.

sim.lwd

Line width for simulation lines.

sim.alpha

Transparency level for simulation lines, where 0 = transparent and 1 = opaque (see transco).

mean.line

If TRUE, plot mean of simulations across time.

mean.smooth

If TRUE, use a lowess smoother on the mean line.

mean.col

Vector of any standard R color format for mean lines.

mean.lwd

Line width for mean lines.

mean.lty

Line type for mean lines.

qnts

If numeric, plot polygon of simulation quantiles based on the range implied by the argument (see details). If FALSE, suppress polygon from plot.

qnts.col

Vector of any standard R color format for polygons.

qnts.alpha

Transparency level for quantile polygons, where 0 = transparent and 1 = opaque (see transco).

qnts.smooth

If TRUE, use a lowess smoother on quantile polygons.

legend

If TRUE, plot default legend.

leg.cex

Legend scale size.

axs

Plot axis type (see par for details), with default to "r".

grid

If TRUE, a grid is added to the background of plot (see grid for details), with default of nx by ny.

add

If TRUE, new plot window is not called and lines are added to existing plot window.

...

additional arguments to pass.

See Also

icm

Examples

Run this code
# NOT RUN {
## Example 1: Plotting multiple compartment values from SIR model
param <- param.icm(inf.prob = 0.5, act.rate = 0.5, rec.rate = 0.02)
init <- init.icm(s.num = 500, i.num = 1, r.num = 0)
control <- control.icm(type = "SIR", nsteps = 100,
                       nsims = 3, verbose = FALSE)
mod <- icm(param, init, control)
plot(mod, grid = TRUE)

## Example 2: Plot only infected with specific output from SI model
param <- param.icm(inf.prob = 0.25, act.rate = 0.25)
init <- init.icm(s.num = 500, i.num = 10)
control <- control.icm(type = "SI", nsteps = 100,
                       nsims = 3, verbose = FALSE)
mod2 <- icm(param, init, control)

# Plot prevalence
plot(mod2, y = "i.num", mean.line = FALSE, sim.lines = TRUE)

# Plot incidence
par(mfrow = c(1, 2))
plot(mod2, y = "si.flow", mean.smooth = TRUE, grid = TRUE)
plot(mod2, y = "si.flow", qnts.smooth = FALSE, qnts = 1)

# }

Run the code above in your browser using DataLab