intensityplot methods to plot the evolution of the total infection
intensity, its epidemic proportion or its endemic proportion over time.
plot method for objects of class
is just a wrapper for the
The implementation is illustrated in Meyer et al. (2017, Section 4),
# S3 method for twinSIR plot(x, which = c("epidemic proportion", "endemic proportion", "total intensity"), ...) # S3 method for twinSIR intensityplot(x, which = c("epidemic proportion", "endemic proportion", "total intensity"), aggregate = TRUE, theta = NULL, plot = TRUE, add = FALSE, rug.opts = list(), ...) # S3 method for simEpidata intensityplot(x, which = c("epidemic proportion", "endemic proportion", "total intensity"), aggregate = TRUE, theta = NULL, plot = TRUE, add = FALSE, rug.opts = list(), ...)
"total intensity". Partial matching is applied. Determines
whether to plot the path of the total intensity \(\lambda(t)\) or its
epidemic or endemic proportions
logical. Determines whether lines for all individual infection
intensities should be drawn (
FALSE) or their sum only
TRUE, the default).
numeric vector of model coefficients. If
x is of class
theta = c(alpha, beta), where
consists of the coefficients of the piecewise constant log-baseline function
and the coefficients of the endemic (
cox) predictor. If
theta = c(alpha, 1, betarest),
where 1 refers to the (true) log-baseline used in the simulation and
betarest is the vector of the remaining coefficients of the endemic
The default (
NULL) means that the fitted or true parameters,
respectively, will be used.
logical indicating if a plot is desired, defaults to
Otherwise, only the data of the plot will be returned. Especially with
aggregate = FALSE and many individuals one might e.g. consider to
plot a subset of the individual intensity paths only or do some further
calculations/analysis of the infection intensities.
TRUE, paths are added to the current plot, using
either a list of arguments passed to the function
NA), in which case no
rug will be plotted.
By default, the argument
ticksize is set to 0.02 and
is set to
TRUE. Note that the argument
x of the
rug() function, which contains the
locations for the
rug is fixed internally and can not be modified.
The locations of the rug are the time points of infections.
plot.twinSIR method, arguments passed to
intensityplot methods, further graphical parameters
passed to the function
main. Note that the
add are implicit and can not be specified here.
numeric matrix with the first column
"stop" and as many rows as there
"stop" time points in the event history
x. The other
columns depend on the argument
is only one other column named
which, which contains the values of
which at the respective
"stop" time points. Otherwise, if
aggregate = FALSE, there is one column for each individual, each of
them containing the individual
which at the respective
Meyer, S., Held, L. and Höhle, M. (2017): Spatio-temporal analysis of epidemic phenomena using the R package surveillance. Journal of Statistical Software, 77 (11), 1-55. doi: 10.18637/jss.v077.i11
data("hagelloch") plot(hagelloch) # a simplistic twinSIR model fit <- twinSIR(~ household, data = hagelloch) # overall total intensity plot(fit, which = "total") # overall epidemic proportion epi <- plot(fit, which = "epidemic", ylim = c(0, 1)) head(epi) # add overall endemic proportion = 1 - epidemic proportion ende <- plot(fit, which = "endemic", add = TRUE, col = 2) legend("topleft", legend = "endemic proportion", lty = 1, col = 2, bty = "n") # individual intensities tmp <- plot(fit, which = "total", aggregate = FALSE, col = rgb(0, 0, 0, alpha = 0.1), main = expression("Individual infection intensities " * lambda[i](t) == Y[i](t) %.% (e[i](t) + h[i](t)))) # return value: matrix of individual intensity paths str(tmp) # plot intensity path only for individuals 3 and 99 matplot(x = tmp[,1], y = tmp[,1+c(3,99)], type = "S", ylab = "Force of infection", xlab = "time", main = expression("Paths of the infection intensities " * lambda(t) * " and " * lambda(t))) legend("topright", legend = paste("Individual", c(3,99)), col = 1:2, lty = 1:2)