
twinSIR
Modelsintensityplot
methods to plot the evolution of the total infection
intensity, its epidemic proportion or its endemic proportion over time.
The default plot
method for objects of class "twinSIR"
is just a wrapper for the intensityplot
method.## S3 method for class 'twinSIR':
plot(x, which = c("epidemic proportion", "endemic proportion",
"total intensity"), ...)## S3 method for class '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 class 'simEpidata':
intensityplot(x, which = c("epidemic proportion", "endemic proportion",
"total intensity"), aggregate = TRUE, theta = NULL,
plot = TRUE, add = FALSE, rug.opts = list(), ...)
"twinSIR"
(fitted model) or
"simEpidata"
(simulated twinSIR
epidemic),
respectively."epidemic proportion"
, "endemic proportion"
,
or "total intensity"
. Partial matching is applied. Determines
whether to plot the path of the total intensity $\lambda(t)$ or its
epidemic or endemic proporFALSE
) or their sum only
(TRUE
, the default).x
is of class
"twinSIR"
, then theta = c(alpha, beta)
, where beta
consists of the coefficients of the piecewise constant log-baseline function
and theTRUE
.
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 thTRUE
, paths are added to the current plot, using
lines
.rug
, or
NULL
(or NA
), in which case no rug
will be plotted.
By default, the argument ticksize
is setplot.twinSIR
methode, arguments passed to
intensityplot.twinSIR
.
For the intensityplot
methods, further graphical parameters
passed to the function matplot
"stop"
and as many rows as there
are "stop"
time points in the event history x
. The other
columns depend on the argument aggregate
: if TRUE
, there
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 "stop"
time points.twinSIR
or simulate.twinSIR
for the simulation of epidemic data
according to a twinSIR
specification.data("fooepidata")
data("foofit")
# an overview of the evolution of the epidemic
plot(fooepidata)
# overall total intensity
plot(foofit, which="total")
# overall epidemic proportion
epi <- plot(foofit, which="epidemic")
# look at returned values
head(epi)
# add the inverse overall endemic proportion = 1 - epidemic proportion
ende <- plot(foofit, which="endemic", add=TRUE, col=2)
legend("right", legend="endemic proportion
(= 1 - epidemic proportion)",
lty=1, col=2, bty="n")
# individual intensities
tmp <- plot(foofit, which="total", aggregate=FALSE,
col=rgb(0,0,0,alpha=if(getRversion() < "2.7.0") 1 else 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[3](t) * "and " * lambda[99](t)))
legend("topright", legend=paste("Individual", c(3,99)), col=c(1,2), lty=c(1,2))
Run the code above in your browser using DataLab