Learn R Programming

surveillance (version 1.5-4)

untie: Randomly Break Ties in Data

Description

This is a generic function intended to randomly break tied data in a way similar to what jitter does: tie-breaking is performed by shifting all data points by a random amount. The surveillance package defines methods for matrices, "epidataCS", and a default method for numeric vectors.

Usage

untie(x, amount, ...)

## S3 method for class 'epidataCS': untie(x, amount = list(t = NULL, s = NULL), direction = "left", keep.sources = FALSE, ...) ## S3 method for class 'matrix': untie(x, amount = NULL, constraint = NULL, ...) ## S3 method for class 'default': untie(x, amount = NULL, direction = c("symmetric", "left", "right"), sort = NULL, ...)

Arguments

x
the data to be untied.
amount
upperbound for the random amount by which data are shifted. NULL means to use a data-driven default, which equals the minimum separation of the data points for the default method, and its half for the matrix method.
keep.sources
logical (FALSE). If TRUE, the original list of possible event sources in x$events$.sources will be preserved. For instance, events observed at the same time did by definition not trigger each other; howev
constraint
an object of class "SpatialPolygons" representing the domain which the points of the matrix should belong to -- before and after jittering.
direction
one of "symmetric" (default), "left", or "right", indicating in which direction vector elements should be shifted.
sort
logical indicating if the jittered vector should be sorted. Defaults to doing so if the original vector was already sorted.
...
currently unused.

Value

  • the untied (jittered) data.

See Also

jitter

Examples

Run this code
# vector example
set.seed(123)
untie(c(rep(1,3), rep(1.2, 4), rep(3,3)), direction="left", sort=FALSE)

# spatial example
data(imdepi)
coords <- coordinates(imdepi$events)
table(duplicated(coords))
mult <- multiplicity(coords)
plot(coords, cex=sqrt(mult))
set.seed(1)
coords_untied <- untie(coords)
stopifnot(!anyDuplicated(coords_untied))
points(coords_untied, col=2) # shifted by very small amount in this case

Run the code above in your browser using DataLab