Learn R Programming

epinet (version 2.1.11)

plot.epinet: Plot the spread of an epidemic

Description

Plot the spread of an epidemic over a contact network.

Usage

# S3 method for epinet
plot(x, index = dim(x$transtree)[2],
    lwd = 1, leaf.labs = TRUE, leaf.cex = 0.75, zero.at.start = FALSE, 
    main = "Transmission Tree", xlab = "Time", ylab= "", 
    e.col = "black", i.col = "red", lty.transmission = 3,
    marktransitions = TRUE, label.trans = "|", cex.trans = 0.5, ...)

Value

returns no value. Strictly invoked for the plotting side effect.

Arguments

x

output from epinet.

index

a number indicating which of the MCMC samples to plot. Defaults to the final sample in the chain.

lwd

line width for the (horizontal) line segments representing the exposed and infective periods for each individual. Also controls the line width for the (vertical) line segments showing the transmission pathways.

leaf.labs

boolean variable controlling whether the leaf labels (Node IDs) are displayed to the right of their infective period. Defaults to TRUE.

leaf.cex

Character expansion factor for the leaf labels, if they are displayed. Defaults to 0.75.

zero.at.start

boolean variable governing whether the epidemic times are shifted so that the epidemic begins at time zero. Defaults to FALSE.

main

main title for plot.

xlab

label for x axis on plot. Defaults to “Time”.

ylab

label for y axis on plot. Defaults to blank.

e.col

color to be used to plot the individuals' exposed periods on the plot. Defaults to black.

i.col

color to be used to plot the individuals' infective periods on the plot. Defaults to red.

lty.transmission

line type used to mark the (vertical) infection pathway on the plot. Defaults to 3 (dotted).

marktransitions

boolean variable indicating whether tick marks should be placed at the times where the individuals move from the exposed to the infective state. Defaults to TRUE.

label.trans

character used to mark transition points, if marktransitions is TRUE. Defaults to “|”.

cex.trans

magnification to be used to for transition labels, if marktransitions is TRUE. Defaults to 0.5.

...

other plotting arguments to be passed through to the call to plot() that draws the axes and titles.

Author

David Welch david.welch@auckland.ac.nz, Chris Groendyke cgroendyke@gmail.com

Details

Plots the output from the link{epinet} function indicating the path that the infection took during the epidemic (the transmission tree) and the times that each node entered the Exposed, Infective, and Removed states. The default plotting parameter values work well for epidemics up to about 50 - 60 infecteds. For a larger number of infecteds, it is recommended to use pdf and adjust plotting dimensions.

References

Groendyke, C. and Welch, D. 2018. epinet: An R Package to Analyze Epidemics Spread across Contact Networks, Journal of Statistical Software, 83-11.

See Also

epinet for performing inference on the network and epidemic model parameters. The functions epi2newick and write.epinet offer other options for outputting inferred parameter samples and transmission trees.

Examples

Run this code
# Simulate an epidemic through a network of 30
set.seed(3)
N <- 30
# Build dyadic covariate matrix (X)
# Have a single covariate for overall edge density; this is the Erdos-Renyi model
nodecov <- matrix(1:N, nrow = N)
dcm <- BuildX(nodecov)
# Simulate network and then simulate epidemic over network
examplenet <- SimulateDyadicLinearERGM(N, dyadiccovmat = dcm, eta = -1.8)
exampleepidemic <- SEIR.simulator(examplenet, N = 30, 
    beta = 0.3, ki = 2, thetai = 5, latencydist = "gamma")

# Set inputs for MCMC algorithm
mcmcinput <- MCMCcontrol(nsamp = 5000, thinning = 10, extrathinning = 10, 
    etapropsd = 0.2) 
priorcontrol <- priorcontrol(bprior = c(0, 1), tiprior = c(1, 3), teprior = c(1, 3), 
    etaprior = c(0, 10), kiprior = c(2, 8), keprior = c(2, 8), priordists = "uniform")
# Run MCMC algorithm on this epidemic
# Delete Exposure and Infection times; will infer these in the MCMC algorithm
exampleepidemic[, 3:4] <- NA
examplemcmc <- epinet( ~ 1, exampleepidemic, dcm, mcmcinput, priorcontrol,
     verbose = FALSE)

# Plot starting state of epidemic from chain 
plot(examplemcmc, index = 1)

# Plot final state of epidemic from chain 
plot(examplemcmc)

Run the code above in your browser using DataLab