Description Usage Arguments Details Value Warning Note Examples
Computes the expected duration of encounters at each location for every pair of IDs.
1 2 | encounterDistribution(tr, threshold, grid=NULL, timestepSize = 60,
xc=NULL, yc=NULL, grid.dim = 100, grid.pad = 0.2)
|
tr |
The trajectory for which to compute the UD |
threshold |
The maximum distance at which an encounter occurs |
grid |
a grid of class |
timestepSize |
The difference between consecutive time steps, in seconds |
xc |
The x coordinates of the vertical grid lines |
yc |
The y coordinates of the horizontal grid lines |
grid.dim |
If all of |
grid.pad |
If the grid is automatically generated, its range is the range
of the relocations extended |
One can specify the grid in three ways:
If grid
is set, the coordinates of
the grid lines are derived from there.
These coordinates can also be specified in the parameters xc
and yc
.
Otherwise, the grid is determined automatically. The grid then ranges over
a bounding box of all measurements, extended on each side by a specified fraction of the range.
The number of grid cells can be controlled via grid.dim
. The amount by which
the grid is extended is controlled via grid.pad
, which may be a vector specifying
the extension on top,right,bottom,left respectively. It is recycled as usual.
The return value is a list, indexed by two IDs.
If grid
is given, each element of the result list is an object of class
asc
, representing the same grid. Otherwise, each element of the list is
a matrix, indexed by the coordinates specified in xc
and yc
.
Element result[["id1", "id2"]]
of the result represents the distribution
of the position of id1
while it had encounters with id2
. This is
not the same as result[["id2","id1"]]
, since that is the distribution of
id2
's location during its encounters with id1
.
The diagonal entries of the result list contain the utilization distribution of each ID, since an entity is always at a distance 0 from itself.
There seems to be some problem with the result being transposed, this needs further investigation. Until then, you can plot the transpose of the result using image(t(ud[["BD","NH"]]))
.
The image
function has ugly colours, use the col
attribute to define a better colour map.
Also note that this function may take a rather long time to complete, so please be patient, specify a sufficiently small grid or use a larger time step.
1 2 3 4 5 6 7 8 9 10 11 12 13 | data("vervet_monkeys", package="moveBB")
## Define grid lines: equally spaced between the min and max coordinate in monkey.tr
#TODO: define from monkey.tr@extent
xlim <- range(monkey.data$X, na.rm=TRUE)
xc <- seq(xlim[1], xlim[2], length.out=20)
ylim <- range(monkey.data$Y, na.rm=TRUE)
yc <- seq(ylim[1], ylim[2], length.out=20)
## Compute the UD and plot the result for one ID
#ud <- encounterDistribution(monkey.tr, 100, xc=xc, yc=yc)
#image(ud[["BD","NH"]])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.