epidataCS_aggregate | R Documentation |
"epidataCS"
to "epidata"
or "sts"
Continuous-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.
## 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, ...)
object , data |
an object of class |
freq , start |
see the description of the |
neighbourhood |
binary adjacency or neighbourhood-order matrix of the regions
( |
tiles |
object inheriting from |
popcol.stgrid |
single character or numeric value indexing the
column in |
popdensity |
logical indicating if the column referenced by
|
tileCentroids |
a coordinate matrix of the region centroids (i.e., the result of
|
eps |
numeric scalar for breaking tied removal and infection times between different
individuals (tiles), which might occur during conversion from
|
... |
unused (argument of the generic). |
Conversion to "sts"
only makes sense if the time
intervals (BLOCK
s) 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
.
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
).
Sebastian Meyer
epidata
and twinSIR
linkS4class{sts}
and hhh4
.
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, type = observed ~ 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, type = observed ~ 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.