Description Slots Methods Author(s) Examples
This is a lightweight S4 class to implement multivariate time series of counts used for public health surveillance data. The class captures the time series data as well as the spatial layout of the regions, where the data originate from.
epoch
:Object of class numeric
or specifying
the time of observation. In old versions of the package this used to
be the week numbers. However, depending on
the freq
argument, it can now be day or month as
well. Furthermore, if epochAsDate=TRUE
then
it is the as.numeric
representation of Date
objects
giving the exact date of the observation. Note: This slot used to be
called week
in earlier versions of the package, but has now been
renamed to reflect the greater
flexibility in the choice of observation time.
freq
:If weekly data freq
corresponds to 52, in
case of monthly data freq
is 12.
start
:vector of length two denoting the year and the sample number (week, month, etc.) of the first observation
observed
:A matrix of size length(epoch)
times the
number of regions containing the weekly/monthly number of counts in
each region. The colnames of the matrix should match the ID values of
the shapes in the map
slot.
state
:Matrix with the same dimension as observed
containing booleans whether at the specific time point there was an
outbreak in the region
alarm
:Matrix with the same dimension as
observed
specifying whether an outbreak detection algorithm
declared a specific time point in the region as having an alarm. If
the object containins just observations then this slot is null.
upperbound
:Matrix with upper bound values
neighbourhood
:Symmetric matrix of size (number of regions)^2 describing the neighbourhood structure. It may either be a binary adjacency matrix or contain neighbourhood orders.
populationFrac
:A matrix
of population
fractions (with dimensions dim(observed)
).
map
:Object of class SpatialPolygonsDataFrame
providing a shape of the areas which are monitored.
control
:Object of class list
, this is a
rather free data type to be returned by the surveillance algorithms.
epochAsDate
:Object of class "logical"
stating
whether to use a ISO 8601 representation of the epoch
slot using
the Date
class (epochAsDate=TRUE
) or just to
interpret the epochs as numerics (epochAsDate=FALSE
).
multinomialTS
:Object of class "logical"
stating whether to interpret the object as observed
out of
population
, i.e. a multinomial interpretation instead of a
count interpretation.
signature(x = "sts")
: extract matrix dimensions of
observed
using dim
.
signature(x = "sts")
: extract the observed
slot of an sts
object.
signature(x = "sts")
: extract the population
slot of an sts
object.
signature(x = "sts")
: extract the
multinomialTS
slot of an sts
object.
signature(x = "sts")
: extract the
neighbourhood
slot of an sts
object.
signature(x = "sts")
: extract the alarm
slot of an sts
object.
signature(x = "sts")
: extract the upperbound
slot of an sts
object.
signature(x = "sts")
: extract the control
slot of an sts
object.
signature(x = "sts")
: extract the epoch
slot of an sts
object. If ISO dates are used then the
returned object is of class Date
.
signature(x = "sts")
: Returns the epoch
number within the year of the epoch
slot.
signature(x="sts")
: extract the dimnames
of the observed
matrix.
signature(x="sts")
: the internal function
init.sts
is called, which assigns all slots.
signature(x="sts")
: see
aggregate,sts-method
signature(x = "sts")
:
extracts the corresponding year of each observation of x
signature(x = "sts")
:
converts the observed
, epoch
, state
and
alarm
slots of x
into a data frame with column names
matching the colnames of the respective slots. Useful when one wants
to fit a model based on the object
signature(x="sts",y="missing")
: this method is
the entry point to a collection of plot variants. It is also
the successor of the plot.disProg
and
plot.survRes
functions. The type of plot is
specified using a formula type
.
See stsplot
for details.
M. Höhle
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | if (requireNamespace("maptools")) {
# load disProg-object "ha" and convert to S4-class "sts"
data("ha")
shpfile <- system.file("shapes/berlin.shp",package="surveillance")
ha.sts <- disProg2sts(ha, map=maptools::readShapePoly(shpfile,IDvar="SNAME"))
} else {
data("ha.sts")
# is almost identical to the above except that German umlauts
# have been replaced in 'ha.sts@map@data$BEZIRK' for compatibility reasons
}
ha.sts
plot(ha.sts, type = observed ~ 1 | unit)
## convert ts/mts object to sts
z <- ts(matrix(rpois(300,10), 100, 3), start = c(1961, 1), frequency = 12)
z.sts <- as(z, "sts")
plot(z.sts)
## conversion to the quasi-standard "xts" class is also possible
## -> enables interactive time series plots using package "dygraphs"
if (require("xts")) {
z.xts <- as.xts(z.sts)
plot(z.xts)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.