"epidataCS"
to "epidata"
or "sts"
"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, ...)
"epidataCS"
."sts "
class.tiles
). If missing but tiles
is given, a binary
adjacency matrix will be auto-generated from tiles
using
functionality of the "SpatialPolygons "
representing the regions in object$stgrid
(column
"tile"
). It will become the "map"
slot of the
resulting "sts"
object$stgrid
which contains the population data
(counts or densities, depending on the popdensity
argument).
This will become the "populationFrac"
popcol.stgrid
contains population densities or absolute counts.coordinates(tiles)
). Its row names must match
levels(data$stgrid$tile)
.
This will be the coordinates used for the "epidataCS"
to "epidata"
. Rather dumb, this is simply done
by subtracting 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
).
"epidataCS"
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
.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)
stopifnot(isTRUE(all.equal(colSums(imdsts@observed),
c(table(imdepi$events$tile)))))
## compare plots of monthly number of cases
opar <- par(mfrow = c(2, 1))
suppressWarnings(plot(imdepi, "time", breaks = c(0,unique(imdepi$stgrid$stop))))
plot(imdsts, type = observed ~ time, legend.opts = NULL)
par(opar)
## plot number of cases by district
plot(imdsts, type = observed ~ 1 | unit, labels = FALSE)
## also test conversion to an SIS event history ("epidata") of the "tiles"
if (requireNamespace("intervals")) {
imdepi_short <- subset(imdepi, time < 50)
imdepi_short$stgrid <- subset(imdepi_short$stgrid, start < 50)
imdepidata <- as.epidata(imdepi_short,
tileCentroids = coordinates(districtsD))
summary(imdepidata)
}
Run the code above in your browser using DataLab