# rNeymanScott

##### Simulate Neyman-Scott Process

Generate a random point pattern, a realisation of the Neyman-Scott cluster process.

##### Usage

`rNeymanScott(kappa, rmax, rcluster, win = owin(c(0,1),c(0,1)), ..., lmax=NULL)`

##### Arguments

- kappa
- Intensity of the Poisson process of cluster centres. A single positive number, a function, or a pixel image.
- rmax
- Maximum radius of a random cluster.
- rcluster
- A function which generates random clusters.
- win
- Window in which to simulate the pattern.
An object of class
`"owin"`

or something acceptable to`as.owin`

. - ...
- Arguments passed to
`rcluster`

- lmax
- Optional. Upper bound on the values of
`kappa`

when`kappa`

is a function or pixel image.

##### Details

This algorithm generates a realisation of the
general Neyman-Scott process, with the cluster mechanism
given by the function `rcluster`

.
The clusters must have a finite maximum possible radius `rmax`

.

First, the algorithm
generates a Poisson point process of ``parent'' points
with intensity `kappa`

. Here `kappa`

may be a single
positive number, a function `kappa(x, y)`

, or a pixel image
object of class `"im"`

(see `im.object`

).
See `rpoispp`

for details.
Second, each parent point is
replaced by a random cluster of points, created by calling the
function `rcluster`

.
These clusters are combined together to yield a single point pattern
which is then returned as the result of `rNeymanScott`

.

The function `rcluster`

should expect to be called as
`rcluster(xp[i],yp[i],...)`

for each parent point at a location
`(xp[i],yp[i])`

. The return value of `rcluster`

should be a list with elements
`x,y`

which are vectors of equal length giving the absolute
$x$ and `y`

coordinates of the points in the cluster.

If the return value of `rcluster`

is a point pattern (object of
class `"ppp"`

) then it may have marks. The result of
`rNeymanScott`

will then be a marked point pattern.

If required, the intermediate stages of the simulation (the parents
and the individual clusters) can also be extracted from
the return value of `rNeymanScott`

through the attributes `"parents"`

and `"parentid"`

.
The attribute `"parents"`

is the point pattern of parent points.
The attribute `"parentid"`

is an integer vector specifying
the parent for each of the points in the simulated pattern.

##### Value

- The simulated point pattern (an object of class
`"ppp"`

). Additionally, some intermediate results of the simulation are returned as attributes of this point pattern: see Details.

##### See Also

##### Examples

```
# each cluster consist of 10 points in a disc of radius 0.2
nclust <- function(x0, y0, radius, n) {
return(runifdisc(n, radius, centre=c(x0, y0)))
}
plot(rNeymanScott(10, 0.2, nclust, radius=0.2, n=5))
# multitype Neyman-Scott process (each cluster is a multitype process)
nclust2 <- function(x0, y0, radius, n, types=c("a", "b")) {
X <- runifdisc(n, radius, centre=c(x0, y0))
M <- sample(types, n, replace=TRUE)
marks(X) <- M
return(X)
}
plot(rNeymanScott(15,0.1,nclust2, radius=0.1, n=5))
```

*Documentation reproduced from package spatstat, version 1.16-2, License: GPL (>= 2)*