Conversion (aggregation) of "epidataCS" to "epidata" or "sts"
epidataCS_aggregate.RdContinuous-time continuous-space epidemic data stored in an object of
class "epidataCS" can be aggregated in space or in space
and time yielding an object of class "epidata" or
"sts" for use of twinSIR or
hhh4 modelling, respectively.
Usage
## aggregation in space and time over 'stgrid' for use of 'hhh4' models
epidataCS2sts(object, freq, start, neighbourhood,
tiles = NULL, popcol.stgrid = NULL, popdensity = TRUE)
## aggregation in space for use of 'twinSIR' models
# S3 method for class 'epidataCS'
as.epidata(data, tileCentroids, eps = 0.001, ...)Arguments
- object, data
an object of class
"epidataCS".- freq,start
see the description of the
"sts"class. Thestartspecification should reflect the beginning ofobject$stgrid, i.e., the start of the first time interval.- neighbourhood
binary adjacency or neighbourhood-order matrix of the regions (
tiles). If missing buttilesis given, a binary adjacency matrix will be auto-generated fromtilesusing functionality of the spdep package (seepoly2adjmat). Since the"neighbourhood"slot in"sts"is actually optional,neighbourhood=NULLalso works.- tiles
object inheriting from
"SpatialPolygons"representing the regions inobject$stgrid(column"tile"). It will become the"map"slot of the resulting"sts"object. Itsrow.namesmust matchlevels(object$stgrid$tile). Ifneighbourhoodis provided,tilesis optional (not required forhhh4, but for plots of the resulting"sts"object).- popcol.stgrid
single character or numeric value indexing the column in
object$stgridwhich contains the population data (counts or densities, depending on thepopdensityargument). This will become the"populationFrac"slot (optional).- popdensity
logical indicating if the column referenced by
popcol.stgridcontains population densities or absolute counts.- tileCentroids
a coordinate matrix of the region centroids (i.e., the result of
coordinates(tiles)). Its row names must matchlevels(data$stgrid$tile). This will be the coordinates used for the “population” (i.e., thetilesfrom"epidataCS") in the discrete-spacetwinSIRmodelling.- eps
numeric scalar for breaking tied removal and infection times between different individuals (tiles), which might occur during conversion from
"epidataCS"to"epidata". Rather dumb, this is simply done by subtractingepsfrom each tied removal time. One should consider other ways of breaking the tied event times.- ...
unused (argument of the generic).
Details
Conversion to "sts" only makes sense if the time
intervals (BLOCKs) of the stgrid are regularly spaced
(to give freq intervals per year). Note that events of the
prehistory (not covered by stgrid) are not included in the
resulting sts object.
Some comments on the conversion to "epidata":
the conversion results into SIS epidemics only,
i.e. the at-risk indicator is set to 1 immediately after
recovery. A tile is considered infective if at least one individual
within the tile is infective, otherwise it is susceptible.
The lengths of the infectious periods are taken from
data$events$eps.t. There will be no f columns in the resulting
"epidata". These must be generated by a subsequent call to
as.epidata with desired f.
Value
epidataCS2sts: an object of class "sts"
representing the multivariate time-series of the number of
cases aggregated over stgrid.
as.epidata.epidataCS: an object of class
"epidata" representing an SIS epidemic in form of a
multivariate point process (one for each region/tile).
Examples
data("imdepi")
load(system.file("shapes", "districtsD.RData", package="surveillance"))
## convert imdepi point pattern into multivariate time series
imdsts <- epidataCS2sts(imdepi, freq = 12, start = c(2002, 1),
neighbourhood = NULL, # not needed here
tiles = districtsD)
## check the overall number of events by district
stopifnot(all.equal(colSums(observed(imdsts)),
c(table(imdepi$events$tile))))
## compare plots of monthly number of cases
opar <- par(mfrow = c(2, 1))
plot(imdepi, "time")
plot(imdsts, ~time)
par(opar)
## plot number of cases by district in Bavaria (municipality keys 09xxx)
imd09 <- imdsts[, grep("^09", colnames(imdsts), value = TRUE), drop = TRUE]
plot(imd09, ~unit)
## also test conversion to an SIS event history ("epidata") of the "tiles"
if (requireNamespace("intervals")) {
imdepi_short <- subset(imdepi, time < 50) # to reduce the runtime
imdepi_short$stgrid <- subset(imdepi_short$stgrid, start < 50)
imdepidata <- as.epidata(imdepi_short,
tileCentroids = coordinates(districtsD))
summary(imdepidata)
}