Authors: Edith Gabriel [aut, cre],Peter J Diggle [aut],Barry Rowlingson [aut],Francisco J Rodriguez-Cortes [aut]
Version: 2.0-1
License: GPL-3
Many of the models encountered in applications of point process methods to the study of spatio-temporal phenomena are covered in ‘stpp’. This package provides statistical tools for analyzing the global and local second-order properties of spatio-temporal point processes, including estimators of the space-time inhomogeneous K-function and pair correlation function. It also includes tools to get static and dynamic display of spatio-temporal point patterns. See Gabriel et al. (2013) doi:10.18637/jss.v053.i02.
R (>= 3.4.2), splancs, KernSmooth, spatstat, rpanel, rgl, plot3D, ggplot2, gridExtra
packagedocs
This data set gives the spatial locations and reported times of food-and-mouth disease in north Cumbria (UK), 2001. It is of no scientific value, as it deliberately excludes confidential information on farms at risk in the study-region. It is included in the package purely as an illustrative example.
data(fmd)
A matrix containing (x,y,t) coordinates of the 648 observations.
Diggle, P., Rowlingson, B. and Su, T. (2005). Point process methodology for on-line spatio-temporal disease surveillance. Environmetrics, 16, 423–34.
northcumbria for boundaries of the county of north Cumbria.
This data set gives the boundary of the county of north Cumbria (UK).
data(northcumbria)
A matrix containing \((x,y)\) coordinates of the boundary.
fmd for the space-time pattern of food-and-mouth disease in this county in 2001.
Displays \((x,y,t)\) point data and enables dynamic highlighting of time slices.
stan(xyt,tlim=range(xyt[,3],na.rm=TRUE),twid=diff(tlim)/20,
persist=FALSE,states,bgpoly,bgframe=TRUE,bgimage,
bgcol=gray(seq(0,1,len=12)),axes=TRUE)
This function requires the rpanel and rgl packages. It uses rpanel for the sliders to control the graphics, and rgl for its ability to do flicker-free graphics.
The sliders set the position and width of the temporal highlight window. For time slider set to time \(T\) and width slider set to \(S\), highlighted points are those with time coordinate \(t\) such that \(T-S< t< T\).
How points are shown is configured with the states parameter. This is a list of length 3 specifying how points before the time window, inside the time window, and after the time window are displayed. Each element is a list of parameters as would be passed to material3d() together with a radius element. Points are drawn as spheres with the corresponding material and radius as a fraction of the spatial span of the data.
By default the third state is invisible, and the first two states are different. By calling with the default for states and persist=TRUE, then the first state is set to the same as the second state. This has the effect of showing all points at time \(< T\) with the same sphere type.
If the user specifies the states parameter, then persist is ignored. The user can emulate the persist behaviour by specifying a states list with identical parameters for states 1 and 2.
Note that each state element should specify all material3d parameters used in any of the state elements. This is to make sure the parameters are reset for each of the sets of points.
The background polygon must be a simple 2-column vector of \(x\) and \(y\) coordinates. When used with bgframe=TRUE, the polygon is also drawn on the front plane, and the convex hull points are connected front to back in order to visualise the space-time prism that the data are contained in.
A raster image can be displayed on the back plane by setting the bgimage parameter. This must be a list with \(x\), \(y\) and \(z\) components as needed by the image function. Note that \(x\) and \(y\) define the center of cells and so must be the same length as the dimensions of \(z\) - the image function can accept \(x\) and \(y\) values that are one longer than the dimensions of \(z\) to define the edges, but bgimage does not allow that.
Barry Rowlingson b.rowlingson@lancaster.ac.uk, Edith Gabriel
Provide an animation of spatio-temporal point patterns.
animation(xyt, s.region, t.region, runtime=1, incident="red",
prevalent="pink3", pch=19, cex=0.5, plot.s.region=TRUE,
scales=TRUE, border.frac=0.05, add=FALSE)
xyt[,1:2]. If missing, s.region is the bounding box of xyt[,1:2].
xyt[,3]. If missing, t.region is defined by the range of xyt[,3].
NULL.
xyt[i,1:2] is plotted at time xyt[i,3].
xyt[i,1:2] fades at time xyt[i+1,3].
TRUE, plot s.region as polygon.
TRUE, plot X and Y axes with scales.
s.region, as fraction of ranges of X and Y.
TRUE, add the animation to an existing plot.
Peter J Diggle, Edith Gabriel edith.gabriel@univ-avignon.fr.
Create data in spatio-temporal point format.
as.3dpoints(...)
… are: a points object: returns it unaltered; a list with \(x\), \(y\) and \(t\) elements of the same length: returns a points object with the \(x\), \(y\) and \(t\) elements as the coordinates of the points; three vectors of equal length: returns a points object with the first vector as the \(x\) coordinates, the second vector as the \(y\)-coordinates and the third vector as the \(t\)-coordinates.
stpp. as.3dpoints tries to return the argument(s) as a spatio-temporal points object.
Edith Gabriel edith.gabriel@univ-avignon.fr, Peter Diggle, Barry Rowlingson.
Compute an estimation of the Anisotropic Space-Time inhomogeneous \(K\)-function.
ASTIKhat(xyt, s.region, t.region, lambda, dist, times, ang, correction = "border")
s.region is missing, the bounding box of xyt[,1:2] is considered.
t.region is missing, the range of xyt[,3] is considered.
dist is given by \(min(S_x, S_y)/4\), where \(S_x\) and \(S_y\) represent the maximum width and height of the bounding box of s.region.
times is given by \((T_max - T_min)/4\), where \(T_min\) and \(T_max\) are the minimum and maximum of the time interval \(T\).
lambda is missing, the estimate of the anisotropic space-time \(K\)-function is computed as for the homogeneous case, i.e. considering \(n/|S x T|\) as an estimate of the space-time intensity.
ang=2*pi by default.
STIKhat). The default is “border”.
ndist x ntimes matrix containing values of \(K_\phi(u,v)\).
Illian, J. B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.
Gonzalez, J. A., Rodriguez-Cortes, F. J., Cronie, O., Mateu, J. (2016). Spatio-temporal point process statistics: a review. Spatial Statistics. Accepted.
Ohser, J. and D. Stoyan (1981). On the second-order and orientation analysis of planar stationary point processes. Biometrical Journal 23, 523-533.
Francisco J. Rodriguez-Cortes cortesf@uji.es
Tests for data in spatio-temporal point format.
is.3dpoints(x)
x is a spatio-temporal points object, FALSE otherwise.
Edith Gabriel edith.gabriel@univ-avignon.fr, Peter Diggle, Barry Rowlingson.
Compute an estimate of the space-time pair correlarion LISTA functions.
LISTAhat(xyt, s.region, t.region, dist, times, lambda,
ks = "box", hs, kt = "box", ht, correction = "isotropic")
s.region is missing, the bounding box of xyt[,1:2] is considered.
t.region is missing, the range of xyt[,3] is considered.
dist is given by \(min(S_x, S_y)/4\), where \(S_x\) and \(S_y\) represent the maximum width and height of the bounding box of s.region.
times is given by \((T_max - T_min)/4\), where \(T_min\) and \(T_max\) are the minimum and maximum of the time interval \(T\).
lambda is missing, the estimate of the space-time pair correlation function is computed as for the homogeneous case, i.e. considering \((n-1)/|S x T|\) as an estimate of the space-time intensity.
“box” kernel. Can also be “epanech” for the Epanechnikov kernel or “gaussian” or “biweight”.
ks.
“box” kernel. Can also be “epanech” for the Epanechnikov kernel or “gaussian” or “biweight”.
kt.
“isotropic”, “border”, “modified.border”, “translate” and “none” (see PCFhat). The default is “isotropic”.
An individual product density LISTA functions \(g^{(i)}(.,.)\) should reveal the extent of the contribution of the event \((u_i,t_i)\) to the global estimator of the pair correlation function \(g(.,.)\), and may provide a further description of structure in the data (e.g., determining events with similar local structure through dissimilarity measures of the individual LISTA functions), for more details see Siino et al. (2017).
ndist x ntimes matrix containing theoretical values for a Poisson process.
Baddeley, A. and Turner, J. (2005). spatstat: An R Package for Analyzing Spatial Point Pattens. Journal of Statistical Software 12, 1-42.
Cressie, N. and Collins, L. B. (2001). Analysis of spatial point patterns using bundles of product density LISA functions. Journal of Agricultural, Biological, and Environmental Statistics 6, 118-135.
Cressie, N. and Collins, L. B. (2001). Patterns in spatial point locations: Local indicators of spatial association in a minefield with clutter Naval Research Logistics (NRL), John Wiley & Sons, Inc. 48, 333-347.
Siino, M., Rodriguez-Cortes, F. J., Mateu, J. and Adelfio, G. (2017). Testing for local structure in spatio-temporal point pattern data. Environmetrics. DOI: 10.1002/env.2463.
Stoyan, D. and Stoyan, H. (1994). Fractals, random shapes, and point fields: methods of geometrical statistics. Chichester: Wiley.
Francisco J. Rodriguez-Cortes cortesf@uji.es
Compute an estimate of the space-time pair correlation function.
PCFhat(xyt, s.region, t.region, dist, times, lambda,
ks="box", hs, kt="box", ht, correction = "isotropic")
s.region is missing, the bounding box of xyt[,1:2] is considered.
t.region is missing, the range of xyt[,3] is considered.
dist is given by \(min(S_x, S_y)/4\), where \(S_x\) and \(S_y\) represent the maximum width and height of the bounding box of s.region.
times is given by \((T_max - T_min)/4\), where \(T_min\) and \(T_max\) are the minimum and maximum of the time interval \(T\).
lambda is missing, the estimate of the space-time pair correlation function is computed as for the homogeneous case, i.e. considering \(n/|S x T|\) as an estimate of the space-time intensity.
“box” kernel. Can also be “epanech” for the Epanechnikov kernel or “gaussian” or “biweight”.
ks.
“box” kernel. Can also be “epanech” for the Epanechnikov kernel or “gaussian” or “biweight”.
kt.
“isotropic”, “border”, “modified.border”, “translate” and “none” (see Details). The default is “isotropic”.
An approximately unbiased estimator for the space-time pair correlation function, based on data giving the locations of events \(x_i: i = 1,...,n\) on a spatio-temporal region \(SxT\), where \(S\) is an arbitrary polygon and \(T\) a time interval: \[\widehat{g}(u,v)=\frac{1}{4\pi u}\sum_{i=1}^{n}\sum_{j \neq i} \frac{1}{w_{ij}}\frac{k_{s}(u-\|s_i-s_j\|)k_{t}(v-|t_i-t_j|)}{\lambda(x_i) \lambda(x_j)},\] where \(lambda(x_i)\) is the intensity at \(x_i = (s_i, t_i)\) and \(w_ij\) is an edge correction factor to deal with spatial-temporal edge effects. The edge correction methods implemented are:
isotropic: \(w_ij = |S x T| w_ij^(s) w_ij^(t)\), where the temporal edge correction factor \(w_ij^(t) = 1\) if both ends of the interval of length \(2|t_i - t_j|\) centred at \(t_i\) lie within \(T\) and \(w_ij^(t) = 1/2\) otherwise and \(w_ij^(s)\) is the proportion of the circumference of a circle centred at the location \(s_i\) with radius \(||s_i - s_j||\) lying in \(S\) (also called Ripleys edge correction factor).
border: \(w_ij = (sum_{j = 1,...,n} 1{d(s_j, S) > u ; d(t_j, T) > v}/ lambda(x_j)) / 1{d(s_i, S) > u ; d(t_i, T) > v}\), where \(d(s_i, S)\) denotes the distance between \(s_i\) and the boundary of \(S\) and \(d(t_i, T)\) the distance between \(t_i\) and the boundary of \(T\).
modified.border: \(w_ij = |S_(-u) x T_(-v)| / 1{d(s_i, S) > u ; d(t_i, T) > v}\), where \(S_(-u)\) and \(T_(-v)\) are the eroded spatial and temporal region respectively, obtained by trimming off a margin of width \(u\) and \(v\) from the border of the original region.
translate: \(w_ij = |S intersect S_(s_i - s_j) x T intersect T_(t_i - t_j)|\), where \(S_(s_i - s_j)\) and \(T_(t_ i - t_j)\) are the translated spatial and temporal regions.
none: No edge correction is performed and \(w_ij = |S x T|\).
\(k_s()\) and \(k_t()\) denotes kernel functions with bandwidth \(h_s\) and \(h_t\). Experience with pair correlation function estimation recommends box kernels (the default), see Illian et al. (2008). Epanechnikov, Gaussian and biweight kernels are also implemented. Whatever the kernel function, if the bandwidth is missing, a value is obtain from the function dpik of the package KernSmooth. Note that the bandwidths play an important role and their choice is crucial in the quality of the estimators as they heavily influence their variance.
ndist x ntimes matrix containing values of \(g(u,v)\).
ndist x ntimes matrix containing theoretical values for a Poisson process.
Baddeley, A., Rubak, E., Turner, R., (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.
Gabriel E., Diggle P. (2009). Second-order analysis of inhomogeneous spatio-temporal point process data. Statistica Neerlandica, 63, 43–51.
Gabriel E., Rowlingson B., Diggle P. (2013). stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software, 53(2), 1–29.
Gabriel E. (2014). Estimating second-order characteristics of inhomogeneous spatio-temporal point processes: influence of edge correction methods and intensity estimates. Methodology and computing in Applied Probabillity, 16(2), 411–431.
Illian JB, Penttinen A, Stoyan H and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.
Edith Gabriel edith.gabriel@univ-avignon.fr
This function plot either \(xy\)-locations and cumulative distribution of the times, or a space-time 3D scatter, or the time-mark and space-mark of the spatio-temporal point pattern, through arguments style and type. It can also plot \(xy\)-locations with time treated as a quantitative mark attached to each location, as in the previous version of the function, through argument mark (see stpp version < 2.0.0).
"plot"(x, s.region=NULL, t.region=NULL, style="generic", type="projection",
mark=NULL , mark.cexmin=0.4, mark.cexmax=1.2, mark.col=1, ...)
stpp in spatio-temporal point format.
s.region is missing, the default limits are considered.
t.region is missing, the default limits are considered.
type=“projection” (default) the function plot the xy-locations and cumulative distribution of the times. If type=“mark” the function plot the time-mark and space-mark. If type=“scatter” the function plot space-time 3D scatter.
style=“generic” (default) the graphics are plot by default function plot in R and if type=“elegant” the graphics are plot based on the R packages ggplot2 and plot3D.
NULL (default), xy-locations and cumulative distribution of the times are plotted. If TRUE, the time is treated as a quantitative mark attached to each location, and the locations are plotted with the size and/or colour of the plotting symbol determined by the value of the mark.
mark=TRUE.
mark=TRUE. If mark.col=0, all locations have the same colour specified by the usual col argument. Otherwise, can be 1 or “black” (default), 2 or “red”, 3 or “green”, 4 or “blue”, in which cases symbols colour is faded, and the darker corresponds to the most recent time.
pch, theta and phi.
Gabriel E., Rowlingson B., Diggle P. (2013). stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software, 53(2), 1–29.
Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J., and Gille, W. (2017). Mark variograms for spatio-temporal point processes. Spatial Statistics. 20, 125-147.
as.3dpoints for creating data in spatio-temporal point format.
Edith Gabriel edith.gabriel@univ-avignon.fr and Francisco J. Rodriguez-Cortes.
Contour plot or perspective plot or image of the Space-Time Inhomogeneous K-function estimate.
plotK(K,n=15,L=FALSE,type="contour",legend=TRUE,which=NULL,
main=NULL,...)
STIKhat function.
contour by default, but can also be persp or image
STIKhat. If a single edge correction method was used in STIKhat, it is not necessary to specify which.
persp if persp=TRUE, such as theta and phi.
contour, persp, image and STIKhat for an example.
Edith Gabriel edith.gabriel@univ-avignon.fr
Contour, image or perspective plot of the Space-Time Inhomogeneous Pair correlation function estimate.
plotPCF(PCF,n=15,type="contour",legend=TRUE,which=NULL,
main=NULL,...)
PCFhat function.
contour by default, but can also be persp or image
PCFhat. If a single edge correction method was used in PCFhat, it is not necessary to specify which.
persp if persp=TRUE, such as theta and phi.
contour, persp, link{image} and PCFhat for an example.
Edith Gabriel edith.gabriel@univ-avignon.fr
Generate one (or several) realisation(s) of the infection process in a region \(S x T\).
rinfec(npoints, s.region, t.region, nsim=1, alpha, beta, gamma,
s.distr="exponential", t.distr="uniform", maxrad, delta, h="step",
g="min", recent=1, lambda=NULL, lmax=NULL, nx=100, ny=100, nt=1000,
t0, inhibition=FALSE, ...)
s.region is missing, the unit square is considered.
t.region is missing, the interval \([0,1]\) is considered.
h and recent. Must be choosen among “min”, “max” and “prod”.
all consider all previous events. If is an integer, say \(N\), consider only the \(N\) most recent events.
s.distr is Poisson.
t.region.
TRUE, an inhibition process is generated. Otherwise, it is a contagious process.
lambda is a function.
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.
## Not run:
# # inhibition; spatial distribution: uniform
# inf1 = rinfec(npoints=100, alpha=0.2, beta=0.6, gamma=0.5,
# maxrad=c(0.075,0.5), t.region=c(0,50), s.distr="uniform",
# t.distr="uniform", h="gaussian", p="min", recent="all", t0=0.02,
# inhibition=TRUE)
# animation(inf1$xyt, cex=0.8, runtime=10)
#
# # contagion; spatial distribution: Poisson with intensity a given 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=50, ny=50)
# inf2 = rinfec(npoints=100, alpha=4, beta=0.6, gamma=20, maxrad=c(12000,20),
# s.region=northcumbria, t.region=c(1,2000), s.distr="poisson",
# t.distr="uniform", h="step", p="min", recent=1,
# lambda=Ls$z, inhibition=FALSE)
#
#
# image(Ls$x, Ls$y, Ls$z, col=grey((1000:1)/1000)); polygon(northcumbria,lwd=2)
# animation(inf2$xyt, add=TRUE, cex=0.7, runtime=15)
# ## End(Not run)
plot.stpp, animation and stan for plotting space-time point patterns.
Edith Gabriel edith.gabriel@univ-avignon.fr, Peter J Diggle.
Generate one (or several) realisation(s) of the inhibition or contagious process in a region \(S x T\).
rinter(npoints,s.region,t.region,hs="step",gs="min",thetas=0, deltas,ht="step",gt="min",thetat=1,deltat,recent="all",nsim=1, discrete.time=FALSE,replace=FALSE,inhibition=TRUE,...)
s.region is missing, the unit square is considered.
t.region is missing, the interval \([0,1]\) is considered.
theta. Can be chosen among “step” and “gaussian” or can refer to a user defined function which only depend on d, theta, and delta (see details). If inhibition=TRUE, h is monotone, increasing, and must tend to 1 when the distance tends to infinity. 0 \(<=\)h(d,theta)\(<=\) 1. Otherwise, h is monotone, decreasing, and must tend to 1 when the distance tends to 0.
hs and ht functions.
hs or ht and recent. Must be choosen among “min”, “max” and “prod”.
all consider all previous events. If is an integer, say \(N\), consider only the \(N\) most recent events.
hs and ht are defined by the user.
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.
# simple inhibition process
inh1 = rinter(npoints=200,thetas=0,deltas=0.05,thetat=0,deltat=0.001,
inhibition=TRUE)
## Not run: stan(inh1$xyt)
# inhibition process using hs and ht defined by the user
hs = function(d,theta,delta,mus=0.1)
{
res=NULL
a=(1-theta)/mus
b=theta-a*delta
for(i in 1:length(d))
{
if (d[i]<=delta) res=c(res,theta)
if (d[i]>(delta+mus)) res=c(res,1)
if (d[i]>delta & d[i]<=(delta+mus)) res=c(res,a*d[i]+b)
}
return(res)
}
ht = function(d,theta,delta,mut=0.3)
{
res=NULL
a=(1-theta)/mut
b=theta-a*delta
for(i in 1:length(d))
{
if (d[i]<=delta) res=c(res,theta)
if (d[i]>(delta+mut)) res=c(res,1)
if (d[i]>delta & d[i]<=(delta+mut)) res=c(res,a*d[i]+b)
}
return(res)
}
d=seq(0,1,length=100)
plot(d,hs(d,theta=0.2,delta=0.1,mus=0.1),xlab="",ylab="",type="l",
ylim=c(0,1),lwd=2,las=1)
lines(d,ht(d,theta=0.1,delta=0.05,mut=0.3),col=2,lwd=2)
legend("bottomright",col=1:2,lty=1,lwd=2,legend=c(expression(h[s]),
expression(h[t])),bty="n",cex=2)
inh2 = rinter(npoints=100, hs=hs, gs="min", thetas=0.2, deltas=0.1,
ht=ht, gt="min", thetat=0.1, deltat=0.05, inhibition=TRUE)
## Not run: animation(inh2$xyt, runtime=15, cex=0.8)
# simple contagious process for given spatial and temporal regions
data(northcumbria)
cont1 = rinter(npoints=100, s.region=northcumbria, t.region=c(1,200),
thetas=0, deltas=5000, thetat=0, deltat=10, recent=1, inhibition=FALSE)
## Not run:
# plot(cont1$xyt,pch=19,s.region=cont1$s.region,mark=TRUE,mark.col=4)
# ## End(Not run)
plot.stpp, animation and stan for plotting space-time point patterns.
Edith Gabriel edith.gabriel@univ-avignon.fr, Peter J Diggle.
Generate one (or several) realisation(s) of the log-Gaussian cox process in a region \(S x T\).
rlgcp(s.region, t.region, replace=TRUE, npoints=NULL, nsim=1, nx=100, ny=100, nt=100,separable=TRUE,model="exponential", param=c(1,1,1,1,1,1), scale=c(1,1),var.grf=1,mean.grf=0, lmax=NULL,discrete.time=FALSE,exact=FALSE,anisotropy=FALSE,ani.pars=NULL)
s.region is missing, the unit square is considered.
t.region is missing, the interval \([0,1]\) is considered.
NULL, the number of points is from a Poisson distribution with mean the double integral ofs.region and t.region.
TRUE, the covariance function of the Gaussian random field is separable.
separable=TRUE and model is of length 2, then the elements of model define the spatial and temporal covariances respectively. If separable=TRUE and model is of length 1, then the spatial and temporal covariances belongs to the same class of covariances, among “matern”, “exponential”, “stable”, “cauchy” and “wave” (see Details). If separable=FALSE, model must be of length 1 and is either “gneiting” or “cesare” (see Details).
TRUE, times belong to \(N\), otherwise belong to \(R^+\).
TRUE, simulate an anisotropic point pattern. Currently only implemented for separable covariance functions.
We implemented stationary, isotropic spatio-temporal covariance functions.
Separable covariance functions
\[c(h,t) = c_s(\| h \|) \, c_t(|t|) , h \in S, t \in T\]
The purely spatial and purely temporal covariance functions can be:
\(K_\nu\) is the modified Bessel function of second kind: \[{\cal K}_{\nu}(x) = \frac{\pi}{2} \frac{I_{-\nu}(x) - I_{\nu}(x)}{\sin(\pi \nu)},\] with \(I_\nu(x) = (x/2)^\nu sum_{k=0}^{\infty} 1/(k! \Gamma(\nu+k+1)) (x/2)^(2k)\).
The parameters \(\alpha_1\) and \(\alpha_2\) correspond to the parameters of the spatial and temporal covariance respectively. For the Matern model, the parameters \(\alpha_1\), \(\alpha_3\) and \(\alpha_2\), \(\alpha_4\) correspond to the parameters \(\nu\), \(\alpha\) of the spatial and temporal covariance.
Non-separable covariance functions
The spatio-temporal covariance function can be:
The parameter \(\alpha_1\) is the respective parameter for the model of \(\phi(.)\), \(\alpha_3 in (0,1]\), \(\alpha_4 in (0,1]\) and \(\alpha_6 >= 2\).
We also implemented anisotropic Log-Gaussian Cox processes. We considered geometric spatial anisotropy (see Moller and Toftaker, 2014). In this case the covariance function is elliptical and anisotropy is characterized by two parameters: the anisotropy angle \(\pi > \theta >=0\) and the anisotropy ratio \(1 >= \delta >0\) of the minor axis \(2 \omega \delta\) and the major axis \(2 \omega\).
\[C(h,t)=C_0\left( \sqrt{h \Sigma^{-1} h},t \right), \ h \in R^2.\]
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.
nsim>1) of the intensity.
Chan, G. and Wood A. (1997). An algorithm for simulating stationary Gaussian random fields. Applied Statistics, Algorithm Section, 46, 171–181.
Chan, G. and Wood A. (1999). Simulation of stationary Gaussian vector fields. Statistics and Computing, 9, 265–268.
Gneiting T. (2002). Nonseparable, stationary covariance functions for space-time data. Journal of the American Statistical Association, 97, 590–600.
Moller J. and Toftaker H. (2014). Geometric anisotropic spatial point pattern analysis and Cox processes. Scandinavian Journal of Statistics, 41, 414–435.
## Not run:
# # non separable covariance function:
# lgcp1 <- rlgcp(npoints=200, nx=50, ny=50, nt=50, separable=FALSE,
# model="gneiting", param=c(1,1,1,1,1,2), var.grf=1, mean.grf=0)
# N <- lgcp1$Lambda[,,1];for(j in 2:(dim(lgcp1$Lambda)[3])){N <-
# N+lgcp1$Lambda[,,j]}
# image(N,col=grey((1000:1)/1000));box()
# animation(lgcp1$xyt, cex=0.8, runtime=10, add=TRUE, prevalent="orange")
#
# # separable covariance function:
# lgcp2 <- rlgcp(npoints=200, nx=50, ny=50, nt=50, separable=TRUE,
# model="exponential", param=c(1,1,1,1,1,2), var.grf=2, mean.grf=-0.5*2)
# N <- lgcp2$Lambda[,,1];for(j in 2:(dim(lgcp2$Lambda)[3])){N <-
# N+lgcp2$Lambda[,,j]}
# image(N,col=grey((1000:1)/1000));box()
# animation(lgcp2$xyt, cex=0.8, pch=20, runtime=10, add=TRUE,
# prevalent="orange")
# ## End(Not run)
plot.stpp, animation and stan for plotting space-time point patterns.
Edith Gabriel edith.gabriel@univ-avignon.fr, Peter J Diggle.
Generate one (or several) realisation(s) of the Poisson cluster process in a region \(S x T\).
rpcp(s.region, t.region, nparents=NULL, npoints=NULL, lambda=NULL, mc=NULL, nsim=1, cluster="uniform", dispersion, infectious=TRUE, edge = "larger.region", larger.region=larger.region, tronc=1,...)
s.region is missing, the unit square is considered.
t.region is missing, the interval \([0,1]\) is considered.
NULL, nparents is from a Poisson distribution with intensity lambda.
NULL (default), the number of points is from a Poisson distribution with mean the double integral of the intensity over s.region and t.region.
rpp). If NULL, it is constant and equal to nparents / volume of the domain.
npoints is NULL.
uniform,normal and ``exponential are currently implemented. Either a single value if the distribution in space and time is the same, or a vector of length 2, giving first the spatial distribution of children and then the temporal distribution.
TRUE, offsprings times are always greater than parents time.
s.region enlarged by the spatial related value of dispersion and the larger time interval is t.region enlarged by the temporal related value of dispersion. One can over-ride default using the 2-vector parameter larger.region.
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.
# homogeneous Poisson distribution of parents
data(northcumbria)
pcp1 <- rpcp(nparents=50, npoints=500, s.region=northcumbria,
t.region=c(1,365), cluster=c("normal","exponential"),
maxrad=c(5000,5))
## Not run:
# animation(pcp1$xyt, s.region=pcp1$s.region, t.region=pcp1$t.region,
# runtime=5)
# ## End(Not run)
# inhomogeneous Poisson distribution of parents
lbda <- function(x,y,t,a){a*exp(-4*y) * exp(-2*t)}
pcp2 <- rpcp(nparents=50, npoints=500, cluster="normal", lambda=lbda,
a=4000/((1-exp(-4))*(1-exp(-2))))
## Not run:
# stan(pcp2$xyt)
# ## End(Not run)
plot.stpp, animation and stan for plotting space-time point patterns.
Edith Gabriel edith.gabriel@univ-avignon.fr, Peter J Diggle.
Generate one (or several) realisation(s) of the (homogeneous or inhomogeneous) Poisson process in a region \(S x T\).
rpp(lambda, s.region, t.region, npoints=NULL, nsim=1, replace=TRUE, discrete.time=FALSE, nx=100, ny=100, nt=100, lmax=NULL, ...)
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 is missing, the unit square is considered.
t.region is missing, the interval \([0,1]\) is considered.
NULL, the number of points is from a Poisson distribution with mean the double integral of lambda over s.region and t.region.
lambda is a function.
lambda is a function.
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.
# 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)
## 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))))
# 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)
#
# 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)
plot.stpp, animation and stan for plotting space-time point patterns.
Edith Gabriel edith.gabriel@univ-avignon.fr and Peter J Diggle.
Generate one (or several) realisation(s) of a spatio-temporal point process in a region \(S x T\).
sim.stpp(class="poisson", s.region, t.region, npoints=NULL,
nsim=1, ...)
s.region is missing, the unit square is considered.
t.region is missing, the interval \([0,1]\) is considered.
class parameter. See rpp for the Poisson process; rpcp for the Poisson cluster process; rlgcp for the Log-Gaussian Cox process; rinter for the interaction (inhibition or contagious) process and rinfec for the infectious process.
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.
rpp, rinfec, rinter, rpcp and rlgcp for the simulation of Poisson, infectious, interaction, Poisson cluster and log-gaussian Cox processes respectively; and plot.stpp, animation and stan for plotting space-time point patterns.
Edith Gabriel edith.gabriel@univ-avignon.fr
Generate a realisation of the double-cluster process in a region \(S x T\).
stdcpp(lambp, a, b, c, mu, s.region, t.region)
s.region is missing, the unit square is considered.
t.region is missing, the interval \([0,1]\) is considered.
rpp).
We consider the straightforward extension of the classical Matern cluster process on the \(R^3\) case (with ellipsoid or balls) by considering the \(z\)-coordiantes as times.
Consider a Poisson point process in the plane with intensity \(\lambda_p\) as cluster centres for all times parent, as well as a ellipsoid (or ball) where the semi-axes are of lengths \(a\), \(b\) and \(c\), around of each Poisson point under a random general rotation. The scatter uniformly in all ellipsoid (or ball) of all points which are of the form \((x,y,z)\), the number of points in each cluster being random with a Poisson (\(\mu\)) distribution. The resulting point pattern is a spatio-temporal cluster point process with \(t=z\). This point process has intensity \(\lambda_{p} x \mu\).
Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.
Chiu, S. N., Stoyan, D., Kendall, W. S., and Mecke, J. (2013). Stochastic Geometry and its Applications. John Wiley & Sons.
Gabriel, E., Rowlingson, B., Diggle P J. (2013) stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software 53, 1-29.
Illian, J B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.
Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J., and Gille, W. (2017). Mark variograms for spatio-temporal point processes. Spatial Statistics. 20, 125-147.
Francisco J. Rodriguez Cortes cortesf@uji.es
Generate a realisation of the hot-spots cluster process in a region \(S x T\).
sthpcpp(lambp, r, mu, s.region, t.region)
s.region is missing, the unit square is considered.
t.region is missing, the interval \([0,1]\) is considered.
This function generates a realisation of spatio-temporal cluster process, which can be considered as generalisation of the classical Matern cluster process, inside the spatio-temporal window.
Consider a Poisson point process in the plane with intensity \(\lambda_{p}\) as cluster centres for all times parent, as well as a infinite cylinder of radius \(R\) around of each Poisson point, orthogonal to the plane. The scatter uniformly in all cylinders of all points which are of the form \((x,y,z)\), the number of points in each cluster being random with a Poisson (\(\mu\)) distribution. The resulting point pattern is a spatio-temporal cluster point process with \(t=z\). This point process has intensity \(\lambda_{p} x \mu\).
Baddeley, A., Rubak, E., Turner, R. (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.
Chiu, S. N., Stoyan, D., Kendall, W. S., and Mecke, J. (2013). Stochastic Geometry and its Applications. John Wiley & Sons.
Gabriel, E., Rowlingson, B., Diggle P J. (2013) stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software 53, 1-29.
Illian, J B., Penttinen, A., Stoyan, H. and Stoyan, D. (2008). Statistical Analysis and Modelling of Spatial Point Patterns. John Wiley and Sons, London.
Stoyan, D., Rodriguez-Cortes, F. J., Mateu, J., and Gille, W. (2017). Mark variograms for spatio-temporal point processes. Spatial Statistics. 20, 125-147.
Francisco J. Rodriguez Cortes cortesf@uji.es
Compute an estimate of the Space-Time Inhomogeneous K-function.
STIKhat(xyt, s.region, t.region, dist, times, lambda,
correction="isotropic", infectious=FALSE)
s.region is missing, the bounding box of xyt[,1:2] is considered.
t.region is missing, the range of xyt[,3] is considered.
dist is given by \(min(S_x, S_y)/4\), where \(S_x\) and \(S_y\) represent the maximum width and height of the bounding box of s.region.
times is given by \((T_max - T_min)/4\), where \(T_min\) and \(T_max\) are the minimum and maximum of the time interval \(T\).
lambda is missing, the estimate of the space-time K-function is computed as for the homogeneous case (Diggle et al., 1995), i.e. considering \(n/|S x T|\) as an estimate of the space-time intensity.
“isotropic”, “border”, “modified.border”, “translate” and “none” (see Details). The default is “isotropic”.
TRUE, only future events are considered and the isotropic edge correction method is used. See Details.
Gabriel (2014) proposes the following unbiased estimator for the STIK-function, based on data giving the locations of events \(x_i: i = 1,...,n\) on a spatio-temporal region \(SxT\), where \(S\) is an arbitrary polygon and \(T\) is a time interval: \[\widehat{K}(u,v)=\sum_{i=1}^{n}\sum_{j\neq i}\frac{1}{w_{ij}}\frac{1}{\lambda(x_i)\lambda(x_j)}\mathbf{1}_{\lbrace \|s_i - s_j\| \leq u \ ; \ |t_i - t_j| \leq v \rbrace},\] where \(lambda(x_i)\) is the intensity at \(x_i = (s_i, t_i)\) and \(w_ij\) is an edge correction factor to deal with spatial-temporal edge effects. The edge correction methods implemented are:
isotropic: \(w_ij = |S x T| w_ij^(s) w_ij^(t)\), where the temporal edge correction factor \(w_ij^(t) = 1\) if both ends of the interval of length \(2|t_i - t_j|\) centred at \(t_i\) lie within \(T\) and \(w_ij^(t) = 1/2\) otherwise and \(w_ij^(s)\) is the proportion of the circumference of a circle centred at the location \(s_i\) with radius \(||s_i - s_j||\) lying in \(S\) (also called Ripleys edge correction factor).
border: \(w_ij = (sum_{j = 1,...,n} 1{d(s_j, S) > u ; d(t_j, T) > v}/ lambda(x_j)) / 1{d(s_i, S) > u ; d(t_i, T) > v}\), where \(d(s_i, S)\) denotes the distance between \(s_i\) and the boundary of \(S\) and \(d(t_i, T)\) the distance between \(t_i\) and the boundary of \(T\).
modified.border: \(w_ij = |S_(-u) x T_(-v)| / 1{d(s_i, S) > u ; d(t_i, T) > v}\), where \(S_(-u)\) and \(T_(-v)\) are the eroded spatial and temporal region respectively, obtained by trimming off a margin of width \(u\) and \(v\) from the border of the original region.
translate: \(w_ij = |S intersect S_(s_i - s_j) x T intersect T_(t_i - t_j)|\), where \(S_(s_i - s_j)\) and \(T_(t_ i - t_j)\) are the translated spatial and temporal regions.
none: No edge correction is performed and \(w_ij = |S x T|\).
If parameter infectious = TRUE, ony future events are considered and the estimator is, using an isotropic edge correction factor (Gabriel and Diggle, 2009): \[\widehat{K}(u,v)=\frac{1}{|S\times T|}\frac{n}{n_v}\sum_{i=1}^{n_v}\sum_{j=1; j > i}^{n_v} \frac{1}{w_{ij}} \frac{1}{\lambda(x_i) \lambda(x_j)}\mathbf{1}_{\left\lbrace u_{ij} \leq u\right\rbrace}\mathbf{1}_{\left\lbrace t_j - t_i \leq v \right\rbrace}.\]
In this equation, the points \(x_i = (s_i, t_i)\) are ordered so that \(t_i < t_(i+1)\), with ties due to round-off error broken by randomly unrounding if necessary. To deal with temporal edge-effects, for each \(v\), \(n_v\) denotes the number of events for which \(t_i <= T_1 - v\), with \(T=[T_0, T_1]\). To deal with spatial edge-effects, we use Ripleys method.
If lambda is missing in argument, STIKhat computes an estimate of the space-time (homogeneous) K-function: \[\widehat{K}(u,v)=\frac{|S\times T|}{n_v(n-1)} \sum_{i=1}^{n_v}\sum_{j=1;j>i}^{n_v}\frac{1}{w_{ij}}\mathbf{1}_{\lbrace u_{ij}\leq u \rbrace}\mathbf{1}_{\lbrace t_j - t_i \leq v \rbrace}\]
ndist x ntimes matrix containing values of \(K(u,v)\).
ndist x ntimes matrix containing theoretical values for a Poisson process; \(pi u^2 v\) for K and \(2 pi u^2 v\)) for K^*.
Baddeley A., Moller J. and Waagepetersen R. (2000). Non- and semi-parametric estimation of interaction in inhomogeneous point patterns. Statistica Neerlandica, 54, 329–350.
Baddeley, A., Rubak, E., Turner, R., (2015). Spatial Point Patterns: Methodology and Applications with R. CRC Press, Boca Raton.
Diggle P. , Chedwynd A., Haggkvist R. and Morris S. (1995). Second-order analysis of space-time clustering. Statistical Methods in Medical Research, 4, 124–136.
Gabriel E., Diggle P. (2009). Second-order analysis of inhomogeneous spatio-temporal point process data. Statistica Neerlandica, 63, 43–51.
Gabriel E., Rowlingson B., Diggle P. (2013). stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software, 53(2), 1–29.
Gabriel E. (2014). Estimating second-order characteristics of inhomogeneous spatio-temporal point processes: influence of edge correction methods and intensity estimates. Methodology and computing in Applied Probabillity, 16(2), 411–431.
Edith Gabriel edith.gabriel@univ-avignon.fr
This package provides models of spatio-temporal point processes in a region \(S x T\) and statistical tools for analysing global and local second-order properties of such processes. It also includes static and dynamic (2D and 3D) plots. stpp is the first dedicated unified computational environment in the area of spatio-temporal point processes. The stpp package depends upon some other packages: splancs: spatial and space-time point pattern analysis rgl: interactive 3D plotting of densities and surfaces rpanel: simple interactive controls for R using tcltk package KernSmooth: functions for kernel smoothing for Wand & Jones (1995) plot3D: Tools for plotting 3-D and 2-D data
stpp is a package for simulating, analysing and visualising patterns of points in space and time.
Following is a summary of the main functions and the dataset in the stpp package.
To visualise a spatio-temporal point pattern
animation: space-time data animation.
as.3dpoints: create data in spatio-temporal point format.
plot.stpp: plot spatio-temporal point object. Either a two-panels plot showing spatial locations and cumulative times, or a one-panel plot showing spatial locations with times treated as a quantitative mark attached to each location.
stan: 3D space-time animation.
To simulate spatio-temporal point patterns
rinfec: simulate an infection point process,
rinter: simulate an interaction (inhibition or contagious) point process,
rlgcp: simulate a log-Gaussian Cox point process,
rpcp: simulate a Poisson cluster point process,
rpp: simulate a Poisson point process,
stdcpp: simulate a double-cluster point process,
sthpcpp: simulate a hot-spot point process.
To analyse spatio-temporal point patterns
PCFhat: space-time inhomogeneous pair correlation function,
STIKhat: space-time inhomogeneous K-function,
ASTIKhat: Anisotropic space-time inhomogeneous K-function,
LISTAhat: space-time inhomogeneous pair correlation LISTA funcrions.
Dataset
fmd: 2001 food-and-mouth epidemic in north Cumbria (UK).
Baddeley A., Moller J. and Waagepetersen R. (2000). Non- and semi-parametric estimation of interaction in inhomogeneous point patterns. Statistica Neerlandica, 54, 329–350.
Chan, G. and Wood A. (1997). An algorithm for simulating stationary Gaussian random fields. Applied Statistics, Algorithm Section, 46, 171–181.
Chan, G. and Wood A. (1999). Simulation of stationary Gaussian vector fields. Statistics and Computing, 9, 265–268.
Diggle P. , Chedwynd A., Haggkvist R. and Morris S. (1995). Second-order analysis of space-time clustering. Statistical Methods in Medical Research, 4, 124–136.
Gabriel E. (2014). Estimating second-order characteristics of inhomogeneous spatio-temporal point processes: influence ofedge correction methods and intensity estimates. Methodology and computing in Applied Probabillity, 16(1).
Gabriel E., Diggle P. (2009). Second-order analysis of inhomogeneous spatio-temporal point process data. Statistica Neerlandica, 63, 43–51.
Gabriel E., Rowlingson B., Diggle P. (2013). stpp: an R package for plotting, simulating and analyzing Spatio-Temporal Point Patterns. Journal of Statistical Software, 53(2), 1–29.
Gneiting T. (2002). Nonseparable, stationary covariance functions for space-time data. Journal of the American Statistical Association, 97, 590–600.
Gonzalez, J. A., Rodriguez-Cortes, F. J., Cronie, O. and Mateu, J. (2016). Spatio-temporal point process statistics: a review. Spatial Statiscts, 18, 505–544.
Edith Gabriel edith.gabriel@univ-avignon.fr, Barry Rowlingson, Peter J. Diggle and Francisco J. Rodriguez-Cortes