spatstat (version 1.14-5)

rshift.ppp: Randomly Shift a Point Pattern

Description

Randomly shifts the points of a point pattern.

Usage

## S3 method for class 'ppp':
rshift(X, \dots, which=NULL, group)

Arguments

X
Point pattern to be subjected to a random shift. An object of class "ppp"
...
Arguments that determine the random shift. See Details.
group
Optional. Factor specifying a grouping of the points of X, or NULL indicating that all points belong to the same group. Each group will be shifted together, and separately from other groups. By default, points in
which
Optional. Identifies which groups of the pattern will be shifted, while other groups are not shifted. A vector of levels of group.

Value

  • A point pattern (object of class "ppp").

Details

This operation randomly shifts the locations of the points in a point pattern.

The function rshift is generic. This function rshift.ppp is the method for point patterns.

The most common use of this function is to shift the points in a multitype point pattern. By default, points of the same type are shifted in parallel (i.e. points of a common type are shifted by a common displacement vector), and independently of other types. This is useful for testing the hypothesis of independence of types (the null hypothesis that the sub-patterns of points of each type are independent point processes).

In general the points of X are divided into groups, then the points within a group are shifted by a common random displacement vector. Different groups of points are shifted independently. The grouping is determined as follows:

  • If the argumentgroupis present, then this determines the grouping.
  • Otherwise, ifXis a multitype point pattern, the marks determine the grouping.
  • Otherwise, all points belong to a single group.
The argument group should be a factor, of length equal to the number of points in X. Alternatively group may be NULL, which specifies that all points of X belong to a single group.

By default, every group of points will be shifted. The argument which indicates that only some of the groups should be shifted, while other groups should be left unchanged. which must be a vector of levels of group (for example, a vector of types in a multitype pattern) indicating which groups are to be shifted.

The displacement vector, i.e. the vector by which the data points are shifted, is generated at random. Parameters that control the randomisation and the handling of edge effects are passed through the ... argument. They are [object Object],[object Object],[object Object] If the window is a rectangle, the default behaviour is to generate a displacement vector at random with equal probability for all possible displacements. This means that the $x$ and $y$ coordinates of the displacement vector are independent random variables, uniformly distributed over the range of possible coordinates.

Alternatively, the displacement vector can be generated by another random mechanism, controlled by the arguments radius, width and height. [object Object],[object Object]

The argument edge controls what happens when a shifted point lies outside the window of X. Options are: [object Object],[object Object],[object Object] The optional argument clip specifies a smaller window to which the pattern should be restricted.

See Also

rshift, rshift.psp

Examples

Run this code
data(amacrine)

   # random toroidal shift
   # shift "on" and "off" points separately
   X <- rshift(amacrine)

   # shift "on" points and leave "off" points fixed
   X <- rshift(amacrine, which="on")

   # shift all points simultaneously
   X <- rshift(amacrine, group=NULL)

   # maximum displacement distance 0.1 units
   X <- rshift(amacrine, radius=0.1)

   # shift with erosion
   X <- rshift(amacrine, radius=0.1, edge="erode")

Run the code above in your browser using DataCamp Workspace