surveillance (version 1.12.1)

epidataCS_aggregate: Conversion (aggregation) of "epidataCS" to "epidata" or "sts"

Description

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.

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.
neighbourhood
binary adjacency or neighbourhood-order matrix of the regions (tiles). If missing but tiles is given, a binary adjacency matrix will be auto-generated from tiles using functionality of the spdep
tiles
object inheriting from "SpatialPolygons" representing the regions in object$stgrid (column "tile"). It will become the "map" slot of the resulting "sts"
popcol.stgrid
single character or numeric value indexing the column in object$stgrid which contains the population data (counts or densities, depending on the popdensity argument). This will become the "populationFrac"
popdensity
logical indicating if the column referenced by popcol.stgrid contains population densities or absolute counts.
tileCentroids
a coordinate matrix of the region centroids (i.e., the result of coordinates(tiles)). Its row names must match levels(data$stgrid$tile). This will be the coordinates used for the population (i.e.,
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 subtracting
...
unused (argument of the generic).

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).

Details

Some comments on the conversion from "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.

See Also

epidata and twinSIR

linkS4class{sts} and hhh4.

Examples

Run this code
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