# rpp: Generate Poisson point patterns In stpp: Space-Time Point Pattern simulation, visualisation and analysis

## Description

Generate one (or several) realisation(s) of the (homogeneous or inhomogeneous) Poisson process in a region S x T.

## Usage

 ```1 2``` ```rpp(lambda, s.region, t.region, npoints=NULL, nsim=1, replace=TRUE, discrete.time=FALSE, nx=100, ny=100, nt=100, lmax=NULL, ...) ```

## Arguments

 `lambda` Spatio-temporal intensity of the Poisson process. If `lambda` is a single positive number, the function generates realisations of a homogeneous Poisson process, whilst if `lambda` is a function of the form lambda(x,y,t,...) or a 3D-array it generates realisations of an inhomogeneous Poisson process. `s.region` two-column matrix specifying polygonal region containing all data locations. If `s.region` is missing, the unit square is considered. `t.region` vector containing the minimum and maximum values of the time interval. If `t.region` is missing, the interval [0,1] is considered. `replace` logical allowing times repeat. `npoints` number of points to simulate. If `NULL`, the number of points is from a Poisson distribution with mean the double integral of `lambda` over `s.region` and `t.region`. `discrete.time` if TRUE, times belong to N, otherwise belong to R^+. `nsim` number of simulations to generate. Default is 1. `nx,ny,nt` define the size of the 3-D grid on which the intensity is evaluated. `lmax` upper bound for the value of lambda(x,y,t), if `lambda` is a function. `...` additional parameters if `lambda` is a function.

## Value

A list containing:

 `xyt` matrix (or list of matrices if `nsim`>1) containing the points (x,y,t) of the simulated point pattern. `xyt` (or any element of the list if `nsim`>1) is an object of the class `stpp`. `t.index` vector of times index. `Lambda` nx x ny x nt array of the intensity surface at each time. `s.region, t.region, lambda` parameters passed in argument.

## Author(s)

Edith Gabriel <edith.gabriel@univ-avignon.fr> and Peter J Diggle.

`plot.stpp`, `animation` and `stan` for plotting space-time point patterns.
 ``` 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 26 27 28 29 30 31 32 33 34 35 36 37 38``` ```# Homogeneous Poisson process # --------------------------- hpp1 <- rpp(lambda=200,replace=FALSE) ## Not run: stan(hpp1\$xyt) # fixed number of points, discrete time, with time repeat. data(northcumbria) hpp2 = rpp(npoints=500, s.region=northcumbria, t.region=c(1,1000), discrete.time=TRUE) ## Not run: polymap(northcumbria) animation(hpp2\$xyt, s.region=hpp2\$s.region, t.region=hpp2\$t.region, runtime=10, add=TRUE) ## End(Not run) # Inhomogeneous Poisson process # ----------------------------- # intensity defined by a function lbda1 = function(x,y,t,a){a*exp(-4*y) * exp(-2*t)} ipp1 = rpp(lambda=lbda1, npoints=400, a=3200/((1-exp(-4))*(1-exp(-2)))) ## Not run: stan(ipp1\$xyt) # intensity defined by a matrix data(fmd) data(northcumbria) h = mse2d(as.points(fmd[,1:2]), northcumbria, nsmse=30, range=3000) h = h\$h[which.min(h\$mse)] Ls = kernel2d(as.points(fmd[,1:2]), northcumbria, h, nx=100, ny=100) Lt = dim(fmd)[1]*density(fmd[,3], n=200)\$y Lst=array(0,dim=c(100,100,200)) for(k in 1:200) Lst[,,k] <- Ls\$z*Lt[k]/dim(fmd)[1] ipp2 = rpp(lambda=Lst, s.region=northcumbria, t.region=c(1,200), discrete.time=TRUE) ## Not run: par(mfrow=c(1,1)) image(Ls\$x, Ls\$y, Ls\$z, col=grey((1000:1)/1000)); polygon(northcumbria) animation(ipp2\$xyt, add=TRUE, cex=0.5, runtime=15) ## End(Not run) ```