Learn R Programming

SimInf (version 7.0.1)

plot,SimInf_model-method: Display the outcome from a simulated trajectory

Description

Plot either the median and the quantile range of the counts in all nodes, or plot the counts in specified nodes.

Usage

# S4 method for SimInf_model
plot(x, compartments = NULL, node = NULL, range = 0.5, ...)

Arguments

x

The model to plot.

compartments

Character vector with the compartments in the model to include in the plot. Default is NULL i.e. include all compartments in the model.

node

Indices specifying the nodes to include when plotting data. Plot one line for each node. Default (node = NULL) is to extract data from all nodes and plot the median count for the specified compartments.

range

Show the quantile range of the count in each compartment. Default is to show the interquartile range i.e. the middle 50% of the count in transparent color. The median value is shown in the same color. Use range = 0.95 to show the middle 95% of the count. To display individual lines for each node, specify range = FALSE.

...

Additional arguments affecting the plot produced.

Examples

Run this code
# NOT RUN {
## Create an 'SIR' model with 100 nodes and initialise
## it with 990 susceptible individuals and 10 infected
## individuals in each node. Run the model over 100 days.
model <- SIR(u0 = data.frame(S = rep(990, 100),
                             I = rep(10, 100),
                             R = rep(0, 100)),
             tspan = 1:100,
             beta = 0.16,
             gamma = 0.077)

## Run the model and save the result.
result <- run(model)

## Plot the median and interquartile range of the number
## of susceptible, infected and recovered individuals.
plot(result)

## Plot the median and the middle 95\% quantile range of the
## number of susceptible, infected and recovered individuals.
plot(result, range = 0.95)

## Plot the median and interquartile range of the  number
## of infected individuals.
plot(result, compartments = "I")

## Plot the number of susceptible, infected
## and recovered individuals in the first
## three nodes.
plot(result, node = 1:3, range = FALSE)

## Use a stair step plot type instead.
plot(result, node = 1:3, range = FALSE, type = "s")

## Plot the number of infected individuals in the first node.
plot(result, compartments = "I", node = 1, range = FALSE)
# }

Run the code above in your browser using DataLab